ignite-1060
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/d685e82a Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d685e82a Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d685e82a Branch: refs/heads/ignite-950 Commit: d685e82a5f4858a79e40a39eeb45c42ba9713f70 Parents: 3a0ccb5 Author: avinogradov <avinogra...@gridgain.com> Authored: Tue Jun 30 16:40:22 2015 +0300 Committer: avinogradov <avinogra...@gridgain.com> Committed: Tue Jun 30 16:40:22 2015 +0300 ---------------------------------------------------------------------- assembly/dependencies-fabric.xml | 1 + modules/core/src/test/resources/helloworld.gar | Bin 6092 -> 0 bytes modules/core/src/test/resources/helloworld1.gar | Bin 6092 -> 0 bytes modules/core/src/test/resources/readme.txt | 6 -- modules/extdata/uri/META-INF/ignite.xml | 38 +++++++++ .../extdata/uri/modules/uri-dependency/pom.xml | 42 ++++++++++ .../deployment/uri/tasks/GarHelloWorldBean.java | 61 ++++++++++++++ .../src/main/resources/gar-example.properties | 18 ++++ modules/extdata/uri/pom.xml | 60 +++++++++++++- .../deployment/uri/tasks/GarHelloWorldTask.java | 82 +++++++++++++++++++ .../deployment/uri/tasks/gar-spring-bean.xml | 29 +++++++ modules/urideploy/pom.xml | 14 ++++ .../GridTaskUriDeploymentDeadlockSelfTest.java | 13 +-- 13 files changed, 344 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/assembly/dependencies-fabric.xml ---------------------------------------------------------------------- diff --git a/assembly/dependencies-fabric.xml b/assembly/dependencies-fabric.xml index c6668f6..b4808e7 100644 --- a/assembly/dependencies-fabric.xml +++ b/assembly/dependencies-fabric.xml @@ -110,6 +110,7 @@ <exclude>org.apache.ignite:ignite-tools</exclude> <exclude>org.apache.ignite:ignite-extdata-p2p</exclude> <exclude>org.apache.ignite:ignite-extdata-uri</exclude> + <exclude>org.apache.ignite:ignite-extdata-uri-dep</exclude> <exclude>org.apache.ignite:ignite-examples</exclude> <exclude>org.apache.ignite:ignite-indexing</exclude> <exclude>org.apache.ignite:ignite-visor-console</exclude> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/modules/core/src/test/resources/helloworld.gar ---------------------------------------------------------------------- diff --git a/modules/core/src/test/resources/helloworld.gar b/modules/core/src/test/resources/helloworld.gar deleted file mode 100644 index 3b4555a..0000000 Binary files a/modules/core/src/test/resources/helloworld.gar and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/modules/core/src/test/resources/helloworld1.gar ---------------------------------------------------------------------- diff --git a/modules/core/src/test/resources/helloworld1.gar b/modules/core/src/test/resources/helloworld1.gar deleted file mode 100644 index 3b4555a..0000000 Binary files a/modules/core/src/test/resources/helloworld1.gar and /dev/null differ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/modules/core/src/test/resources/readme.txt ---------------------------------------------------------------------- diff --git a/modules/core/src/test/resources/readme.txt b/modules/core/src/test/resources/readme.txt deleted file mode 100644 index 195d655..0000000 --- a/modules/core/src/test/resources/readme.txt +++ /dev/null @@ -1,6 +0,0 @@ -This folder is created for test GridTaskUriDeploymentDeadlockSelfTest. It contains helloworld.gar and helloworld1.gar -which are the same and were copied from Apache Ignite GAR example. - -We put two files here to have a collision and make deployment SPI to unregister class loaders. - -This is intended to test GG-2852 issue. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/modules/extdata/uri/META-INF/ignite.xml ---------------------------------------------------------------------- diff --git a/modules/extdata/uri/META-INF/ignite.xml b/modules/extdata/uri/META-INF/ignite.xml new file mode 100644 index 0000000..5ac671a --- /dev/null +++ b/modules/extdata/uri/META-INF/ignite.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- + Spring configuration file for test classes in gar-file. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> + <description>Ignite Spring configuration file in gar-file.</description> + + <!-- + Optional test tasks specification. If not provided, then all + tasks found inside GAR will be deployed. + --> + <util:list id="tasks"> + <value>org.apache.ignite.spi.deployment.uri.tasks.GarHelloWorldTask</value> + </util:list> +</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/modules/extdata/uri/modules/uri-dependency/pom.xml ---------------------------------------------------------------------- diff --git a/modules/extdata/uri/modules/uri-dependency/pom.xml b/modules/extdata/uri/modules/uri-dependency/pom.xml new file mode 100644 index 0000000..5f45bbe --- /dev/null +++ b/modules/extdata/uri/modules/uri-dependency/pom.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache License, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-parent</artifactId> + <version>1</version> + <relativePath>../../../../../parent</relativePath> + </parent> + + <artifactId>ignite-extdata-uri-dep</artifactId> + <packaging>jar</packaging> + + <version>1.1.6-SNAPSHOT</version> + <modelVersion>4.0.0</modelVersion> + + <dependencies> + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-core</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/modules/extdata/uri/modules/uri-dependency/src/main/java/org/apache/ignite/spi/deployment/uri/tasks/GarHelloWorldBean.java ---------------------------------------------------------------------- diff --git a/modules/extdata/uri/modules/uri-dependency/src/main/java/org/apache/ignite/spi/deployment/uri/tasks/GarHelloWorldBean.java b/modules/extdata/uri/modules/uri-dependency/src/main/java/org/apache/ignite/spi/deployment/uri/tasks/GarHelloWorldBean.java new file mode 100644 index 0000000..bf329be --- /dev/null +++ b/modules/extdata/uri/modules/uri-dependency/src/main/java/org/apache/ignite/spi/deployment/uri/tasks/GarHelloWorldBean.java @@ -0,0 +1,61 @@ +package org.apache.ignite.spi.deployment.uri.tasks; +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.ignite.internal.util.typedef.internal.*; +import org.jetbrains.annotations.*; + +import java.io.*; +import java.util.*; + +/** + * Imported class which should be placed in JAR file in GAR/lib folder. + * Loads message resource file via class loader. + */ +public class GarHelloWorldBean { + /** */ + public static final String RESOURCE = "gar-example.properties"; + + /** + * Gets keyed message. + * + * @param key Message key. + * @return Keyed message. + */ + @Nullable + public String getMessage(String key) { + InputStream in = null; + + try { + in = getClass().getClassLoader().getResourceAsStream(RESOURCE); + + Properties props = new Properties(); + + props.load(in); + + return props.getProperty(key); + } + catch (IOException e) { + e.printStackTrace(); + } + finally { + U.close(in, null); + } + + return null; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/modules/extdata/uri/modules/uri-dependency/src/main/resources/gar-example.properties ---------------------------------------------------------------------- diff --git a/modules/extdata/uri/modules/uri-dependency/src/main/resources/gar-example.properties b/modules/extdata/uri/modules/uri-dependency/src/main/resources/gar-example.properties new file mode 100644 index 0000000..e892a3c --- /dev/null +++ b/modules/extdata/uri/modules/uri-dependency/src/main/resources/gar-example.properties @@ -0,0 +1,18 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +HELLOWORLD.MSG=Hello World! \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/modules/extdata/uri/pom.xml ---------------------------------------------------------------------- diff --git a/modules/extdata/uri/pom.xml b/modules/extdata/uri/pom.xml index 3d43040..a88bced 100644 --- a/modules/extdata/uri/pom.xml +++ b/modules/extdata/uri/pom.xml @@ -20,8 +20,10 @@ <!-- POM file. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <packaging>pom</packaging> <parent> <groupId>org.apache.ignite</groupId> @@ -51,8 +53,18 @@ <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-extdata-uri-dep</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> + <modules> + <module>modules/uri-dependency</module> + </modules> + <build> <resources> <resource> @@ -86,6 +98,21 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <executions> + <execution> + <id>compile</id> + <phase>compile</phase> + <goals> + <!-- need to compile sources. pom packaging will not compile automatically. --> + <goal>compile</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <dependencies> @@ -110,11 +137,36 @@ <phase>compile</phase> <configuration> <target> - <copy file="${settings.localRepository}/com/sun/mail/javax.mail/1.5.2/javax.mail-1.5.2.jar" todir="${basedir}/target/classes/lib" /> + <!-- copying resources to classes --> + <copy todir="${basedir}/target/classes"> + <fileset dir="${basedir}/src/main/java"> + <include name="**/*.xml"/> + <include name="**/*.properties"/> + </fileset> + </copy> + + <copy + file="${settings.localRepository}/com/sun/mail/javax.mail/1.5.2/javax.mail-1.5.2.jar" + todir="${basedir}/target/classes/lib"/> + + <zip destfile="${basedir}/target/classes/lib/depend.jar" encoding="UTF-8"> + <zipfileset dir="modules/uri-dependency/target/classes"/> + </zip> + + <taskdef name="gar" + classname="org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask"/> - <taskdef name="gar" classname="org.apache.ignite.util.antgar.IgniteDeploymentGarAntTask" /> + <gar destfile="${basedir}/target/deploy/uri.gar" basedir="${basedir}/target/classes"/> - <gar destfile="${basedir}/target/deploy/uri.gar" basedir="${basedir}/target/classes" /> + <!-- + This is created for test GridTaskUriDeploymentDeadlockSelfTest. + We put two files here to have a collision and make deployment SPI to unregister class loaders. + This is intended to test GG-2852 issue. + --> + <gar destfile="${basedir}/target/resources/helloworld.gar" + descrdir="${basedir}/META-INF" basedir="${basedir}/target/classes"/> + <gar destfile="${basedir}/target/resources/helloworld1.gar" + descrdir="${basedir}/META-INF" basedir="${basedir}/target/classes"/> </target> </configuration> </execution> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/modules/extdata/uri/src/main/java/org/apache/ignite/spi/deployment/uri/tasks/GarHelloWorldTask.java ---------------------------------------------------------------------- diff --git a/modules/extdata/uri/src/main/java/org/apache/ignite/spi/deployment/uri/tasks/GarHelloWorldTask.java b/modules/extdata/uri/src/main/java/org/apache/ignite/spi/deployment/uri/tasks/GarHelloWorldTask.java new file mode 100644 index 0000000..13b2641 --- /dev/null +++ b/modules/extdata/uri/src/main/java/org/apache/ignite/spi/deployment/uri/tasks/GarHelloWorldTask.java @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.spi.deployment.uri.tasks; + +import org.apache.ignite.*; +import org.apache.ignite.compute.*; +import org.jetbrains.annotations.*; +import org.springframework.beans.factory.support.*; +import org.springframework.beans.factory.xml.*; +import org.springframework.core.io.*; + +import java.io.*; +import java.util.*; + +/** + * This class defines grid task for this example. Grid task is responsible for splitting the task into jobs. This + * particular implementation splits given string into individual words and creates grid jobs for each word. Task class + * in that example should be placed in GAR file. + */ +@ComputeTaskName("GarHelloWorldTask") +public class GarHelloWorldTask extends ComputeTaskSplitAdapter<String, String> { + /** {@inheritDoc} */ + @Override public Collection<? extends ComputeJob> split(int gridSize, String arg) throws IgniteException { + // Create Spring context. + AbstractBeanFactory fac = new XmlBeanFactory( + new ClassPathResource("org/apache/ignite/spi/deployment/uri/tasks/gar-spring-bean.xml", getClass().getClassLoader())); + + fac.setBeanClassLoader(getClass().getClassLoader()); + + // Load imported bean from GAR/lib folder. + GarHelloWorldBean bean = (GarHelloWorldBean)fac.getBean("example.bean"); + + String msg = bean.getMessage(arg); + + assert msg != null; + + // Split the passed in phrase into multiple words separated by spaces. + List<String> words = Arrays.asList(msg.split(" ")); + + Collection<ComputeJob> jobs = new ArrayList<>(words.size()); + + // Use imperative OOP APIs. + for (String word : words) { + // Every job gets its own word as an argument. + jobs.add(new ComputeJobAdapter(word) { + /* + * Simply prints the job's argument. + */ + @Nullable + @Override public Serializable execute() { + System.out.println(">>>"); + System.out.println(">>> Printing '" + argument(0) + "' on this node from grid job."); + System.out.println(">>>"); + + // This job does not return any result. + return null; + } + }); + } + + return jobs; + } + + @Nullable @Override public String reduce(List<ComputeJobResult> results) throws IgniteException { + return String.valueOf(results.size()); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/modules/extdata/uri/src/main/java/org/apache/ignite/spi/deployment/uri/tasks/gar-spring-bean.xml ---------------------------------------------------------------------- diff --git a/modules/extdata/uri/src/main/java/org/apache/ignite/spi/deployment/uri/tasks/gar-spring-bean.xml b/modules/extdata/uri/src/main/java/org/apache/ignite/spi/deployment/uri/tasks/gar-spring-bean.xml new file mode 100644 index 0000000..c3cf3e4 --- /dev/null +++ b/modules/extdata/uri/src/main/java/org/apache/ignite/spi/deployment/uri/tasks/gar-spring-bean.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache License, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> + <description>Spring file for GAR example.</description> + + <!-- + Bean used from imported jar file from GAR/lib. + --> + <bean id="example.bean" class="org.apache.ignite.spi.deployment.uri.tasks.GarHelloWorldBean" scope="singleton"/> +</beans> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/modules/urideploy/pom.xml ---------------------------------------------------------------------- diff --git a/modules/urideploy/pom.xml b/modules/urideploy/pom.xml index 0add261..d14cff7 100644 --- a/modules/urideploy/pom.xml +++ b/modules/urideploy/pom.xml @@ -143,5 +143,19 @@ <artifactId>log4j</artifactId> <scope>test</scope> </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-extdata-uri</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-extdata-p2p</artifactId> + <version>${project.version}</version> + <scope>test</scope> + </dependency> </dependencies> </project> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d685e82a/modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java index a060868..d41542f 100644 --- a/modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java +++ b/modules/urideploy/src/test/java/org/apache/ignite/internal/GridTaskUriDeploymentDeadlockSelfTest.java @@ -44,7 +44,7 @@ public class GridTaskUriDeploymentDeadlockSelfTest extends GridCommonAbstractTes UriDeploymentSpi deploymentSpi = new UriDeploymentSpi(); deploymentSpi.setUriList( - Arrays.asList(U.resolveIgniteUrl("modules/core/src/test/resources/").toURI().toString())); + Arrays.asList(U.resolveIgniteUrl("modules/extdata/uri/target/resources/").toURI().toString())); if (gridName.endsWith("2")) { // Delay deployment for 2nd grid only. @@ -91,18 +91,11 @@ public class GridTaskUriDeploymentDeadlockSelfTest extends GridCommonAbstractTes info(">>> Starting task."); - executeAsync(compute(g.cluster().forPredicate(F.equalTo(F.first(g.cluster().forRemotes().nodes())))), - "GridGarHelloWorldTask", "HELLOWORLD.MSG").get(60000); + assert "2".equals(executeAsync(compute(g.cluster().forPredicate(F.equalTo(F.first(g.cluster().forRemotes().nodes())))), + "GarHelloWorldTask", "HELLOWORLD.MSG").get(60000)); f.get(); } - catch (Exception e) { - error("Test failed.", e); - - // With former version of GridDeploymentLocalStore test hangs forever. - // So, we need to forcibly exit. - // System.exit(1); - } finally { stopAllGrids(); }