#IGNITE-106: Renaming.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2a26d960 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2a26d960 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2a26d960 Branch: refs/heads/ignite-61 Commit: 2a26d960f2bf7433a27588a674dab65dd3c7b612 Parents: cb4a2f5 Author: ivasilinets <ivasilin...@gridgain.com> Authored: Tue Feb 3 16:35:16 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Tue Feb 3 16:35:16 2015 +0300 ---------------------------------------------------------------------- examples/config/filesystem/core-site.xml | 10 +- examples/config/filesystem/example-ggfs.xml | 165 ------------ examples/config/filesystem/example-ignitefs.xml | 162 ++++++++++++ examples/config/filesystem/readme.txt | 8 +- .../ignite/examples/ComputeNodeStartup.java | 4 +- .../compute/ComputeBroadcastExample.java | 2 +- .../compute/ComputeContinuousMapperExample.java | 4 +- .../compute/ComputeExecutorServiceExample.java | 2 +- .../ComputeFibonacciContinuationExample.java | 5 +- .../compute/ComputeProjectionExample.java | 2 +- .../examples/compute/ComputeReducerExample.java | 4 +- .../compute/ComputeRunnableExample.java | 4 +- .../compute/ComputeScheduleExample.java | 4 +- .../examples/compute/ComputeTaskMapExample.java | 4 +- .../compute/ComputeTaskSplitExample.java | 4 +- .../failover/ComputeFailoverNodeStartup.java | 8 +- .../compute/montecarlo/CreditRiskExample.java | 4 +- .../examples/datagrid/CacheAffinityExample.java | 4 +- .../examples/datagrid/CacheApiExample.java | 45 ++-- .../datagrid/CacheDataLoaderExample.java | 2 +- .../examples/datagrid/CacheEventsExample.java | 4 +- .../examples/datagrid/CacheNodeStartup.java | 4 +- .../datagrid/CachePopularNumbersExample.java | 2 +- .../examples/datagrid/CachePutGetExample.java | 11 +- .../examples/datagrid/CacheQueryExample.java | 2 +- .../datagrid/CacheTransactionExample.java | 10 +- .../datastructures/CacheAtomicLongExample.java | 2 +- .../CacheCountDownLatchExample.java | 2 +- .../datastructures/CacheQueueExample.java | 8 +- .../datastructures/CacheSetExample.java | 6 +- .../hibernate/HibernateL2CacheExample.java | 4 +- .../HibernateL2CacheExampleNodeStartup.java | 10 +- .../starschema/CacheStarSchemaExample.java | 44 +++- .../store/CacheNodeWithStoreStartup.java | 8 +- .../datagrid/store/CacheStoreExample.java | 3 +- .../store/CacheStoreLoadDataExample.java | 3 +- .../store/jdbc/CacheJdbcPersonStore.java | 10 +- .../ignite/examples/events/EventsExample.java | 4 +- .../examples/fs/IgniteFsMapReduceExample.java | 249 +++++++++++++++++++ .../ignite/examples/fs/IgniteFsNodeStartup.java | 41 +++ .../org/apache/ignite/examples/fs/package.html | 23 ++ .../examples/ggfs/GgfsMapReduceExample.java | 249 ------------------- .../ignite/examples/ggfs/GgfsNodeStartup.java | 41 --- .../apache/ignite/examples/ggfs/package.html | 23 -- .../examples/messaging/MessagingExample.java | 2 +- .../messaging/MessagingPingPongExample.java | 2 +- .../MemcacheRestExampleNodeStartup.java | 12 +- .../misc/lifecycle/LifecycleExample.java | 4 +- .../misc/springbean/SpringBeanExample.java | 2 +- .../streaming/StreamingCheckInExample.java | 6 +- .../streaming/StreamingNodeStartup.java | 4 +- .../StreamingPopularNumbersExample.java | 6 +- .../streaming/StreamingPriceBarsExample.java | 2 +- .../apache/ignite/examples/ComputeExample.java | 3 +- .../ignite/examples/MessagingExample.java | 14 +- .../examples/ScalarCacheAffinityExample1.scala | 10 +- .../examples/ScalarCacheAffinityExample2.scala | 8 +- .../ScalarCacheAffinitySimpleExample.scala | 4 +- .../scalar/examples/ScalarCacheExample.scala | 2 +- .../ScalarCachePopularNumbersExample.scala | 14 +- .../examples/ScalarCacheQueryExample.scala | 6 +- .../scalar/examples/ScalarClosureExample.scala | 16 +- .../examples/ScalarContinuationExample.scala | 23 +- .../examples/ScalarCreditRiskExample.scala | 2 +- .../scalar/examples/ScalarJvmCloudExample.scala | 8 +- .../examples/ScalarPiCalculationExample.scala | 4 +- .../scalar/examples/ScalarPingPongExample.scala | 12 +- .../scalar/examples/ScalarPrimeExample.scala | 6 +- .../scalar/examples/ScalarScheduleExample.scala | 4 +- .../examples/ScalarSnowflakeSchemaExample.scala | 42 +++- .../scalar/examples/ScalarTaskExample.scala | 6 +- .../examples/ScalarWorldShortestMapReduce.scala | 2 +- .../examples/IgniteFsExamplesSelfTest.java | 14 +- .../ScalarExamplesSelfTestSuite.scala | 6 +- .../src/main/java/org/apache/ignite/Ignite.java | 4 +- .../apache/ignite/internal/IgniteKernal.java | 2 +- .../hadoop/core-site-loopback-secondary.xml | 2 +- .../test/config/hadoop/core-site-loopback.xml | 2 +- .../test/config/hadoop/core-site-secondary.xml | 2 +- .../core/src/test/config/hadoop/core-site.xml | 2 +- .../testframework/junits/GridTestIgnite.java | 2 +- ...ridGgfsHadoopFileSystemAbstractSelfTest.java | 2 +- ...idGgfsHadoopFileSystemHandshakeSelfTest.java | 2 +- .../hadoop/GridHadoopAbstractSelfTest.java | 2 +- .../processors/hadoop/GridHadoopStartup.java | 2 +- .../scala/org/apache/ignite/scalar/scalar.scala | 10 +- .../tests/ScalarAffinityRoutingSpec.scala | 12 +- .../tests/ScalarCacheProjectionSpec.scala | 2 +- .../ignite/scalar/tests/ScalarCacheSpec.scala | 2 +- .../org/apache/ignite/IgniteSpringBean.java | 2 +- 90 files changed, 779 insertions(+), 729 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/config/filesystem/core-site.xml ---------------------------------------------------------------------- diff --git a/examples/config/filesystem/core-site.xml b/examples/config/filesystem/core-site.xml index 58ae948..b5a8dae 100644 --- a/examples/config/filesystem/core-site.xml +++ b/examples/config/filesystem/core-site.xml @@ -25,18 +25,18 @@ <configuration> <property> <name>fs.default.name</name> - <value>ggfs:///</value> + <value>ignitefs:///</value> </property> <property> - <!-- FS driver class for the 'ggfs://' URIs. --> - <name>fs.ggfs.impl</name> + <!-- FS driver class for the 'ignitefs://' URIs. --> + <name>fs.ignitefs.impl</name> <value>org.apache.ignite.fs.hadoop.v1.GridGgfsHadoopFileSystem</value> </property> <property> - <!-- FS driver class for the 'ggfs://' URIs in Hadoop2.x --> - <name>fs.AbstractFileSystem.ggfs.impl</name> + <!-- FS driver class for the 'ignitefs://' URIs in Hadoop2.x --> + <name>fs.AbstractFileSystem.ignitefs.impl</name> <value>org.apache.ignite.fs.hadoop.v2.GridGgfsHadoopFileSystem</value> </property> </configuration> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/config/filesystem/example-ggfs.xml ---------------------------------------------------------------------- diff --git a/examples/config/filesystem/example-ggfs.xml b/examples/config/filesystem/example-ggfs.xml deleted file mode 100644 index 08f18a1..0000000 --- a/examples/config/filesystem/example-ggfs.xml +++ /dev/null @@ -1,165 +0,0 @@ -<?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. - --> - -<!-- - Ignite Spring configuration file to startup ignite cache. - - When starting a standalone node, you need to execute the following command: - {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/filesystem/example-ggfs.xml - - When starting Ignite from Java IDE, pass path to this file into Ignition: - Ignition.start("examples/config/filesystem/example-ggfs.xml"); ---> -<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"> - - <!-- - Optional description. - --> - <description> - Spring file for ignite configuration with client available endpoints. - </description> - - <!-- - Initialize property configurer so we can reference environment variables. - --> - <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> - <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK"/> - <property name="searchSystemEnvironment" value="true"/> - </bean> - - <!-- - Configuration below demonstrates how to setup a GGFS node with file data. - --> - <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> - <!-- Set to true to enable cluster-aware class loading for examples, default is false. --> - <property name="peerClassLoadingEnabled" value="true"/> - - <property name="marshaller"> - <bean class="org.apache.ignite.marshaller.optimized.IgniteOptimizedMarshaller"> - <!-- Set to false to allow non-serializable objects in examples, default is true. --> - <property name="requireSerializable" value="false"/> - </bean> - </property> - - <property name="ggfsConfiguration"> - <list> - <bean class="org.apache.ignite.fs.IgniteFsConfiguration"> - <property name="name" value="ggfs"/> - <property name="metaCacheName" value="ggfs-meta"/> - <property name="dataCacheName" value="ggfs-data"/> - - <!-- Must correlate with cache affinity mapper. --> - <property name="blockSize" value="#{128 * 1024}"/> - <property name="perNodeBatchSize" value="512"/> - <property name="perNodeParallelBatchCount" value="16"/> - - <!-- Set number of prefetch blocks. --> - <property name="prefetchBlocks" value="32"/> - - <!-- - This will disable IPC endpoint binding thus preventing Hadoop clients from connecting to GGFS. - With this option set to false the only possible way to interact with GGFS is through - Ignite API. - --> - <property name="ipcEndpointEnabled" value="false"/> - - <!-- - Example of configured IPC loopback endpoint. - --> - <!-- - <property name="ipcEndpointConfiguration"> - <map> - <entry key="type" value="tcp"/> - </map> - </property> - --> - - <!-- - Example of configured shared memory endpoint. - --> - <!-- - <property name="ipcEndpointConfiguration"> - <map> - <entry key="type" value="shmem"/> - <entry key="port" value="10500"/> - </map> - </property> - --> - </bean> - </list> - </property> - - <property name="cacheConfiguration"> - <list> - <bean class="org.apache.ignite.cache.CacheConfiguration"> - <property name="name" value="ggfs-data"/> - <property name="cacheMode" value="PARTITIONED"/> - <property name="atomicityMode" value="TRANSACTIONAL"/> - <property name="queryIndexEnabled" value="false"/> - <property name="writeSynchronizationMode" value="FULL_SYNC"/> - <property name="distributionMode" value="PARTITIONED_ONLY"/> - <property name="backups" value="0"/> - <property name="affinityMapper"> - <bean class="org.apache.ignite.fs.IgniteFsGroupDataBlocksKeyMapper"> - <!-- Haw many blocks in row will be stored on the same node. --> - <constructor-arg value="512"/> - </bean> - </property> - </bean> - - <bean class="org.apache.ignite.cache.CacheConfiguration"> - <property name="name" value="ggfs-meta"/> - <property name="cacheMode" value="REPLICATED"/> - <property name="atomicityMode" value="TRANSACTIONAL"/> - <property name="queryIndexEnabled" value="false"/> - <property name="writeSynchronizationMode" value="FULL_SYNC"/> - </bean> - </list> - </property> - - <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. --> - <property name="discoverySpi"> - <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> - <property name="ipFinder"> - <!-- - Ignition provides several options for automatic discovery that can be used - instead os static IP based discovery. For information on all options refer - to our documentation: http://doc.gridgain.org/latest/Automatic+Node+Discovery - --> - <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. --> - <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">--> - <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder"> - <property name="addresses"> - <list> - <!-- In distributed environment, replace with actual host IP address. --> - <value>127.0.0.1:47500..47509</value> - </list> - </property> - </bean> - </property> - </bean> - </property> - </bean> -</beans> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/config/filesystem/example-ignitefs.xml ---------------------------------------------------------------------- diff --git a/examples/config/filesystem/example-ignitefs.xml b/examples/config/filesystem/example-ignitefs.xml new file mode 100644 index 0000000..8bdcfb8 --- /dev/null +++ b/examples/config/filesystem/example-ignitefs.xml @@ -0,0 +1,162 @@ +<?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. + --> + +<!-- + Ignite Spring configuration file to startup ignite cache. + + When starting a standalone node, you need to execute the following command: + {IGNITE_HOME}/bin/ignite.{bat|sh} examples/config/filesystem/example-ignitefs.xml + + When starting Ignite from Java IDE, pass path to this file into Ignition: + Ignition.start("examples/config/filesystem/example-ignitefs.xml"); +--> +<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.xsd"> + + <!-- + Optional description. + --> + <description> + Spring file for ignite configuration with client available endpoints. + </description> + + <!-- + Initialize property configurer so we can reference environment variables. + --> + <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK"/> + <property name="searchSystemEnvironment" value="true"/> + </bean> + + <!-- + Configuration below demonstrates how to setup a IgniteFs node with file data. + --> + <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> + <!-- Set to true to enable cluster-aware class loading for examples, default is false. --> + <property name="peerClassLoadingEnabled" value="true"/> + + <property name="marshaller"> + <bean class="org.apache.ignite.marshaller.optimized.IgniteOptimizedMarshaller"> + <!-- Set to false to allow non-serializable objects in examples, default is true. --> + <property name="requireSerializable" value="false"/> + </bean> + </property> + + <property name="igniteFsConfiguration"> + <list> + <bean class="org.apache.ignite.fs.IgniteFsConfiguration"> + <property name="name" value="ignitefs"/> + <property name="metaCacheName" value="ignitefs-meta"/> + <property name="dataCacheName" value="ignitefs-data"/> + + <!-- Must correlate with cache affinity mapper. --> + <property name="blockSize" value="#{128 * 1024}"/> + <property name="perNodeBatchSize" value="512"/> + <property name="perNodeParallelBatchCount" value="16"/> + + <!-- Set number of prefetch blocks. --> + <property name="prefetchBlocks" value="32"/> + + <!-- + This will disable IPC endpoint binding thus preventing Hadoop clients from connecting to IgniteFs. + With this option set to false the only possible way to interact with IgniteFs is through + Ignite API. + --> + <property name="ipcEndpointEnabled" value="false"/> + + <!-- + Example of configured IPC loopback endpoint. + --> + <!-- + <property name="ipcEndpointConfiguration"> + <map> + <entry key="type" value="tcp"/> + </map> + </property> + --> + + <!-- + Example of configured shared memory endpoint. + --> + <!-- + <property name="ipcEndpointConfiguration"> + <map> + <entry key="type" value="shmem"/> + <entry key="port" value="10500"/> + </map> + </property> + --> + </bean> + </list> + </property> + + <property name="cacheConfiguration"> + <list> + <bean class="org.apache.ignite.cache.CacheConfiguration"> + <property name="name" value="ignitefs-data"/> + <property name="cacheMode" value="PARTITIONED"/> + <property name="atomicityMode" value="TRANSACTIONAL"/> + <property name="queryIndexEnabled" value="false"/> + <property name="writeSynchronizationMode" value="FULL_SYNC"/> + <property name="distributionMode" value="PARTITIONED_ONLY"/> + <property name="backups" value="0"/> + <property name="affinityMapper"> + <bean class="org.apache.ignite.fs.IgniteFsGroupDataBlocksKeyMapper"> + <!-- Haw many blocks in row will be stored on the same node. --> + <constructor-arg value="512"/> + </bean> + </property> + </bean> + + <bean class="org.apache.ignite.cache.CacheConfiguration"> + <property name="name" value="ignitefs-meta"/> + <property name="cacheMode" value="REPLICATED"/> + <property name="atomicityMode" value="TRANSACTIONAL"/> + <property name="queryIndexEnabled" value="false"/> + <property name="writeSynchronizationMode" value="FULL_SYNC"/> + </bean> + </list> + </property> + + <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. --> + <property name="discoverySpi"> + <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> + <property name="ipFinder"> + <!-- + Ignition provides several options for automatic discovery that can be used + instead os static IP based discovery. For information on all options refer + to our documentation: http://doc.gridgain.org/latest/Automatic+Node+Discovery + --> + <!-- Uncomment static IP finder to enable static-based discovery of initial nodes. --> + <!--<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">--> + <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder"> + <property name="addresses"> + <list> + <!-- In distributed environment, replace with actual host IP address. --> + <value>127.0.0.1:47500..47509</value> + </list> + </property> + </bean> + </property> + </bean> + </property> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/config/filesystem/readme.txt ---------------------------------------------------------------------- diff --git a/examples/config/filesystem/readme.txt b/examples/config/filesystem/readme.txt index c69b8fd..e2b1e44 100644 --- a/examples/config/filesystem/readme.txt +++ b/examples/config/filesystem/readme.txt @@ -1,8 +1,8 @@ FileSystem Configuration Example -------------------------------- -This folder contains configuration files for GGFS examples located in -org.apache.ignite.examples.ggfs package. +This folder contains configuration files for IgniteFs examples located in +org.apache.ignite.examples.fs package. -- example-ggfs.xml file is used to start Apache Ignite nodes with GGFS configured -- core-site.xml file is used to run Hadoop FS driver over GGFS +- example-ignitefs.xml file is used to start Apache Ignite nodes with IgniteFS configured +- core-site.xml file is used to run Hadoop FS driver over IgniteFs http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/ComputeNodeStartup.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/ComputeNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/ComputeNodeStartup.java index 4c4678a..7c03dad 100644 --- a/examples/src/main/java/org/apache/ignite/examples/ComputeNodeStartup.java +++ b/examples/src/main/java/org/apache/ignite/examples/ComputeNodeStartup.java @@ -27,9 +27,9 @@ public class ComputeNodeStartup { * Start up an empty node with example compute configuration. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { Ignition.start("examples/config/example-compute.xml"); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/compute/ComputeBroadcastExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeBroadcastExample.java b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeBroadcastExample.java index 397f8cd..cdd7241 100644 --- a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeBroadcastExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeBroadcastExample.java @@ -38,7 +38,7 @@ public class ComputeBroadcastExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ public static void main(String[] args) throws Exception { try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/compute/ComputeContinuousMapperExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeContinuousMapperExample.java b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeContinuousMapperExample.java index 3f9704f..760703b 100644 --- a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeContinuousMapperExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeContinuousMapperExample.java @@ -50,9 +50,9 @@ public class ComputeContinuousMapperExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { System.out.println(); System.out.println(">>> Compute continuous mapper example started."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/compute/ComputeExecutorServiceExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeExecutorServiceExample.java b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeExecutorServiceExample.java index a7e180f..db5938a 100644 --- a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeExecutorServiceExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeExecutorServiceExample.java @@ -37,7 +37,7 @@ public final class ComputeExecutorServiceExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ @SuppressWarnings({"TooBroadScope"}) public static void main(String[] args) throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/compute/ComputeFibonacciContinuationExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeFibonacciContinuationExample.java b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeFibonacciContinuationExample.java index 024f565..2cdc84c 100644 --- a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeFibonacciContinuationExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeFibonacciContinuationExample.java @@ -21,7 +21,6 @@ import org.apache.ignite.*; import org.apache.ignite.cluster.*; import org.apache.ignite.compute.*; import org.apache.ignite.examples.*; -import org.apache.ignite.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.resources.*; import org.jetbrains.annotations.*; @@ -47,9 +46,9 @@ public final class ComputeFibonacciContinuationExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { System.out.println(); System.out.println("Compute Fibonacci continuation example started."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/compute/ComputeProjectionExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeProjectionExample.java b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeProjectionExample.java index 18cf485..e6c19de 100644 --- a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeProjectionExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeProjectionExample.java @@ -36,7 +36,7 @@ public class ComputeProjectionExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ public static void main(String[] args) throws Exception { try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/compute/ComputeReducerExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeReducerExample.java b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeReducerExample.java index a77d915..1f020c4 100644 --- a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeReducerExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeReducerExample.java @@ -41,9 +41,9 @@ public class ComputeReducerExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { System.out.println(); System.out.println("Compute reducer example started."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/compute/ComputeRunnableExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeRunnableExample.java b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeRunnableExample.java index 4af838b..6dce1bf 100644 --- a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeRunnableExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeRunnableExample.java @@ -37,9 +37,9 @@ public class ComputeRunnableExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { System.out.println(); System.out.println("Compute runnable example started."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/compute/ComputeScheduleExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeScheduleExample.java b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeScheduleExample.java index 0f7a34e..6dc3892 100644 --- a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeScheduleExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeScheduleExample.java @@ -40,9 +40,9 @@ public class ComputeScheduleExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { System.out.println(); System.out.println("Compute schedule example started."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/compute/ComputeTaskMapExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeTaskMapExample.java b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeTaskMapExample.java index a290c31..a4ef155 100644 --- a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeTaskMapExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeTaskMapExample.java @@ -44,9 +44,9 @@ public class ComputeTaskMapExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { System.out.println(); System.out.println("Compute task map example started."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/compute/ComputeTaskSplitExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeTaskSplitExample.java b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeTaskSplitExample.java index ad76892..7c4c8a7 100644 --- a/examples/src/main/java/org/apache/ignite/examples/compute/ComputeTaskSplitExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/compute/ComputeTaskSplitExample.java @@ -42,9 +42,9 @@ public class ComputeTaskSplitExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { System.out.println(); System.out.println("Compute task split example started."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/compute/failover/ComputeFailoverNodeStartup.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/compute/failover/ComputeFailoverNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/compute/failover/ComputeFailoverNodeStartup.java index 0c64c83..9eba616 100644 --- a/examples/src/main/java/org/apache/ignite/examples/compute/failover/ComputeFailoverNodeStartup.java +++ b/examples/src/main/java/org/apache/ignite/examples/compute/failover/ComputeFailoverNodeStartup.java @@ -36,9 +36,9 @@ public class ComputeFailoverNodeStartup { * Start up an empty node with specified configuration. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { Ignition.start(configuration()); } @@ -46,9 +46,9 @@ public class ComputeFailoverNodeStartup { * Create Ignite configuration with configured checkpoints. * * @return Ignite configuration. - * @throws IgniteCheckedException If configuration creation failed. + * @throws IgniteException If configuration creation failed. */ - public static IgniteConfiguration configuration() throws IgniteCheckedException { + public static IgniteConfiguration configuration() throws IgniteException { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setLocalHost("127.0.0.1"); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/compute/montecarlo/CreditRiskExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/compute/montecarlo/CreditRiskExample.java b/examples/src/main/java/org/apache/ignite/examples/compute/montecarlo/CreditRiskExample.java index 5b2ee04..3db5b33 100644 --- a/examples/src/main/java/org/apache/ignite/examples/compute/montecarlo/CreditRiskExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/compute/montecarlo/CreditRiskExample.java @@ -37,9 +37,9 @@ public final class CreditRiskExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { System.out.println(); System.out.println("Credit risk example started."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java index d917624..2b717ec 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheAffinityExample.java @@ -45,9 +45,9 @@ public final class CacheAffinityExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) { System.out.println(); System.out.println(">>> Cache affinity example started."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java index 68c4333..1b9aee6 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheApiExample.java @@ -18,6 +18,7 @@ package org.apache.ignite.examples.datagrid; import org.apache.ignite.*; +import org.apache.ignite.lang.*; import javax.cache.processor.*; import java.util.concurrent.*; @@ -39,9 +40,9 @@ public class CacheApiExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) { System.out.println(); System.out.println(">>> Cache API example started."); @@ -58,13 +59,13 @@ public class CacheApiExample { * Demonstrates cache operations similar to {@link ConcurrentMap} API. Note that * cache API is a lot richer than the JDK {@link ConcurrentMap}. * - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ - private static void atomicMapOperations() throws IgniteCheckedException { + private static void atomicMapOperations() throws IgniteException { System.out.println(); System.out.println(">>> Cache atomic map operation examples."); - IgniteCache<Integer, String> cache = Ignition.ignite().jcache(CACHE_NAME); + final IgniteCache<Integer, String> cache = Ignition.ignite().jcache(CACHE_NAME); // Put and return previous value. String v = cache.getAndPut(1, "1"); @@ -75,21 +76,25 @@ public class CacheApiExample { cache.put(2, "2"); - // Put asynchronously (every cache operation has async counterpart). - // TODO IGNITE-60: uncomment when implemented. -// IgniteFuture<String> fut = cache.putAsync(3, "3"); -// -// // Asynchronously wait for result. -// fut.listenAsync(new IgniteInClosure<IgniteFuture<String>>() { -// @Override public void apply(IgniteFuture<String> fut) { -// try { -// System.out.println("Put operation completed [previous-value=" + fut.get() + ']'); -// } -// catch (IgniteCheckedException e) { -// e.printStackTrace(); -// } -// } -// }); + // Put asynchronously. + final IgniteCache<Integer, String> asyncCache = cache.withAsync(); + + asyncCache.put(3, "3"); + + IgniteFuture<String> fut = asyncCache.future(); + + //Asynchronously wait for result. + fut.listenAsync(new IgniteInClosure<IgniteFuture<String>>() { + @Override + public void apply(IgniteFuture<String> fut) { + try { + System.out.println("Put operation completed [previous-value=" + fut.get(3) + ']'); + } + catch (IgniteException e) { + e.printStackTrace(); + } + } + }); // Put-if-absent. boolean b1 = cache.putIfAbsent(4, "4"); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java index 7d6f8b6..5fd0b96 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheDataLoaderExample.java @@ -46,7 +46,7 @@ public class CacheDataLoaderExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ public static void main(String[] args) throws Exception { ExamplesUtils.checkMinMemory(MIN_MEMORY); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java index c9d1883..24e039d 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheEventsExample.java @@ -43,9 +43,9 @@ public class CacheEventsExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException, InterruptedException { + public static void main(String[] args) throws IgniteException, InterruptedException { try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) { System.out.println(); System.out.println(">>> Cache events example started."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheNodeStartup.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheNodeStartup.java index 3f664b3..c89fd96 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheNodeStartup.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheNodeStartup.java @@ -27,9 +27,9 @@ public class CacheNodeStartup { * Start up an empty node with specified cache configuration. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { Ignition.start("examples/config/example-cache.xml"); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java index 32b8535..96a21c7 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePopularNumbersExample.java @@ -55,7 +55,7 @@ public class CachePopularNumbersExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ public static void main(String[] args) throws Exception { Timer popularNumbersQryTimer = new Timer("numbers-query-worker"); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePutGetExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePutGetExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePutGetExample.java index 14a76ec..cadc24f 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePutGetExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CachePutGetExample.java @@ -18,7 +18,6 @@ package org.apache.ignite.examples.datagrid; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import java.util.*; @@ -39,7 +38,7 @@ public class CachePutGetExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws Exception If example execution failed. */ public static void main(String[] args) throws Exception { try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) { @@ -57,9 +56,9 @@ public class CachePutGetExample { /** * Execute individual puts and gets. * - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ - private static void putGet() throws IgniteCheckedException { + private static void putGet() throws IgniteException { System.out.println(); System.out.println(">>> Cache put-get example started."); @@ -82,9 +81,9 @@ public class CachePutGetExample { /** * Execute bulk {@code putAll(...)} and {@code getAll(...)} operations. * - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ - private static void putAllGetAll() throws IgniteCheckedException { + private static void putAllGetAll() throws IgniteException { System.out.println(); System.out.println(">>> Starting putAll-getAll example."); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java index 495fa43..4429138 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java @@ -72,7 +72,7 @@ public class CacheQueryExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ public static void main(String[] args) throws Exception { try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheTransactionExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheTransactionExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheTransactionExample.java index 6df8e50..6710ebc 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheTransactionExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheTransactionExample.java @@ -18,12 +18,10 @@ package org.apache.ignite.examples.datagrid; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.transactions.*; import java.io.*; -import static org.apache.ignite.internal.processors.cache.CacheFlag.*; import static org.apache.ignite.transactions.IgniteTxConcurrency.*; import static org.apache.ignite.transactions.IgniteTxIsolation.*; @@ -44,9 +42,9 @@ public class CacheTransactionExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) { System.out.println(); System.out.println(">>> Cache transaction example started."); @@ -83,9 +81,9 @@ public class CacheTransactionExample { * * @param acctId Account ID. * @param amount Amount to deposit. - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ - private static void deposit(int acctId, double amount) throws IgniteCheckedException { + private static void deposit(int acctId, double amount) throws IgniteException { // Clone every object we get from cache, so we can freely update it. IgniteCache<Integer, Account> cache = Ignition.ignite().jcache(CACHE_NAME); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheAtomicLongExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheAtomicLongExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheAtomicLongExample.java index a2a0b1e..8511696 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheAtomicLongExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheAtomicLongExample.java @@ -44,7 +44,7 @@ public final class CacheAtomicLongExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ public static void main(String[] args) throws IgniteCheckedException { try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheCountDownLatchExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheCountDownLatchExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheCountDownLatchExample.java index 3ee9c6a..d93244c 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheCountDownLatchExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheCountDownLatchExample.java @@ -44,7 +44,7 @@ public class CacheCountDownLatchExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ public static void main(String[] args) throws Exception { try (Ignite ignite = Ignition.start("examples/config/example-cache.xml")) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheQueueExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheQueueExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheQueueExample.java index 0a08743..a2d2b55 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheQueueExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheQueueExample.java @@ -96,9 +96,9 @@ public class CacheQueueExample { * Read items from head and tail of queue. * * @param ignite Ignite. - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ - private static void readFromQueue(Ignite ignite) throws IgniteCheckedException { + private static void readFromQueue(Ignite ignite) throws IgniteException { final String queueName = queue.name(); // Read queue items on each node. @@ -111,9 +111,9 @@ public class CacheQueueExample { * Write items into queue. * * @param ignite Ignite. - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ - private static void writeToQueue(Ignite ignite) throws IgniteCheckedException { + private static void writeToQueue(Ignite ignite) throws IgniteException { final String queueName = queue.name(); // Write queue items on each node. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheSetExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheSetExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheSetExample.java index 0d97a6c..6de65c9 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheSetExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/datastructures/CacheSetExample.java @@ -70,7 +70,7 @@ public class CacheSetExample { * @param ignite Ignite. * @param setName Name of set. * @return Set. - * @throws IgniteCheckedException If execution failed. + * @throws IgniteException If execution failed. */ private static CacheSet<String> initializeSet(Ignite ignite, String setName) throws IgniteCheckedException { // Initialize new set. @@ -89,9 +89,9 @@ public class CacheSetExample { * Write items into set. * * @param ignite Ignite. - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ - private static void writeToSet(Ignite ignite) throws IgniteCheckedException { + private static void writeToSet(Ignite ignite) throws IgniteException { final String setName = set.name(); // Write set items on each node. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java index e674502..36370b9 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java @@ -80,9 +80,9 @@ public class HibernateL2CacheExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { // Start the node, run the example, and stop the node when finished. try (Ignite ignite = Ignition.start(HibernateL2CacheExampleNodeStartup.configuration())) { // We use a single session factory, but create a dedicated session http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExampleNodeStartup.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExampleNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExampleNodeStartup.java index 9f5bdf3..c4daa8b 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExampleNodeStartup.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExampleNodeStartup.java @@ -37,19 +37,19 @@ public class HibernateL2CacheExampleNodeStartup { * Start up an empty node with specified cache configuration. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { Ignition.start(configuration()); } /** - * Create Grid configuration with GGFS and enabled IPC. + * Create Grid configuration with IgniteFs and enabled IPC. * * @return Grid configuration. - * @throws IgniteCheckedException If configuration creation failed. + * @throws IgniteException If configuration creation failed. */ - public static IgniteConfiguration configuration() throws IgniteCheckedException { + public static IgniteConfiguration configuration() throws IgniteException { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setGridName("hibernate-grid"); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/starschema/CacheStarSchemaExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/starschema/CacheStarSchemaExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/starschema/CacheStarSchemaExample.java index 6a0688a..46c3506 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/starschema/CacheStarSchemaExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/starschema/CacheStarSchemaExample.java @@ -57,11 +57,17 @@ public class CacheStarSchemaExample { /** ID generator. */ private static int idGen = (int)System.currentTimeMillis(); + /** DimStore data. */ + private static Map<Integer, DimStore> dataStore = new HashMap<>(); + + /** DimProduct data. */ + private static Map<Integer, DimProduct> dataProduct = new HashMap<>(); + /** * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ public static void main(String[] args) throws Exception { Ignite ignite = Ignition.start("examples/config/example-cache.xml"); @@ -75,6 +81,7 @@ public class CacheStarSchemaExample { try { populateDimensions(); + populateFacts(); queryStorePurchases(); queryProductPurchases(); @@ -88,9 +95,9 @@ public class CacheStarSchemaExample { * Populate cache with {@code 'dimensions'} which in our case are * {@link DimStore} and {@link DimProduct} instances. * - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ - private static void populateDimensions() throws IgniteCheckedException { + private static void populateDimensions() throws IgniteException { IgniteCache<Integer, Object> cache = Ignition.ignite().jcache(REPLICATED_CACHE_NAME); DimStore store1 = new DimStore(idGen++, "Store1", "12345", "321 Chilly Dr, NY"); @@ -100,11 +107,36 @@ public class CacheStarSchemaExample { cache.put(store1.getId(), store1); cache.put(store2.getId(), store2); + dataStore.put(store1.getId(), store1); + dataStore.put(store2.getId(), store2); + // Populate products for (int i = 0; i < 20; i++) { int id = idGen++; - cache.put(id, new DimProduct(id, "Product" + i, i + 1, (i + 1) * 10)); + DimProduct product = new DimProduct(id, "Product" + i, i + 1, (i + 1) * 10); + + cache.put(id, product); + + dataProduct.put(id, product); + } + } + + /** + * Populate cache with {@code 'facts'}, which in our case are {@link FactPurchase} objects. + * + * @throws IgniteException If failed. + */ + private static void populateFacts() throws IgniteException { + IgniteCache<Integer, Object> factCache = Ignition.ignite().jcache(PARTITIONED_CACHE_NAME); + + for (int i = 0; i < 100; i++) { + int id = idGen++; + + DimStore store = rand(dataStore.values()); + DimProduct prod = rand(dataProduct.values()); + + factCache.put(id, new FactPurchase(id, prod.getId(), store.getId(), (i + 1))); } } @@ -113,7 +145,7 @@ public class CacheStarSchemaExample { * between {@link DimStore} objects stored in {@code 'replicated'} cache and * {@link FactPurchase} objects stored in {@code 'partitioned'} cache. * - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ private static void queryStorePurchases() throws IgniteCheckedException { GridCache<Integer, FactPurchase> factCache = Ignition.ignite().cache(PARTITIONED_CACHE_NAME); @@ -137,7 +169,7 @@ public class CacheStarSchemaExample { * objects stored in {@code 'replicated'} cache and {@link FactPurchase} objects * stored in {@code 'partitioned'} cache. * - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ private static void queryProductPurchases() throws IgniteCheckedException { GridCache<Integer, Object> dimCache = Ignition.ignite().cache(REPLICATED_CACHE_NAME); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java index 8f55bbf..4f0c654 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java @@ -39,9 +39,9 @@ public class CacheNodeWithStoreStartup { * Start up an empty node with specified cache configuration. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ - public static void main(String[] args) throws IgniteCheckedException { + public static void main(String[] args) throws IgniteException { Ignition.start(configure()); } @@ -49,9 +49,9 @@ public class CacheNodeWithStoreStartup { * Configure ignite. * * @return Ignite configuration. - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ - public static IgniteConfiguration configure() throws IgniteCheckedException { + public static IgniteConfiguration configure() throws IgniteException { IgniteConfiguration cfg = new IgniteConfiguration(); cfg.setLocalHost("127.0.0.1"); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreExample.java index 65c4190..0f57a4f 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreExample.java @@ -18,7 +18,6 @@ package org.apache.ignite.examples.datagrid.store; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.configuration.*; import org.apache.ignite.transactions.*; @@ -39,7 +38,7 @@ public class CacheStoreExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ public static void main(String[] args) throws Exception { IgniteConfiguration cfg = CacheNodeWithStoreStartup.configure(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java index 4ff8691..f3aab21 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java @@ -18,7 +18,6 @@ package org.apache.ignite.examples.datagrid.store; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.examples.*; import org.apache.ignite.lang.*; @@ -42,7 +41,7 @@ public class CacheStoreLoadDataExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ public static void main(String[] args) throws Exception { ExamplesUtils.checkMinMemory(MIN_MEMORY); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java index 6e84a40..0a7cfd1 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java @@ -41,9 +41,9 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> { /** * Constructor. * - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ - public CacheJdbcPersonStore() throws IgniteCheckedException { + public CacheJdbcPersonStore() throws IgniteException { prepareDb(); } @@ -51,9 +51,9 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> { * Prepares database for example execution. This method will create a * table called "PERSONS" so it can be used by store implementation. * - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ - private void prepareDb() throws IgniteCheckedException { + private void prepareDb() throws IgniteException { try (Connection conn = openConnection(false); Statement st = conn.createStatement()) { st.execute("create table if not exists PERSONS (id number unique, firstName varchar(255), " + "lastName varchar(255))"); @@ -61,7 +61,7 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> { conn.commit(); } catch (SQLException e) { - throw new IgniteCheckedException("Failed to create database table.", e); + throw new IgniteException("Failed to create database table.", e); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java b/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java index 75e2907..bb15413 100644 --- a/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/events/EventsExample.java @@ -43,7 +43,7 @@ public class EventsExample { * Executes example. * * @param args Command line arguments, none required. - * @throws IgniteCheckedException If example execution failed. + * @throws IgniteException If example execution failed. */ public static void main(String[] args) throws Exception { try (Ignite ignite = Ignition.start("examples/config/example-compute.xml")) { @@ -64,7 +64,7 @@ public class EventsExample { /** * Listen to events that happen only on local node. * - * @throws IgniteCheckedException If failed. + * @throws IgniteException If failed. */ private static void localListen() throws Exception { System.out.println(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/fs/IgniteFsMapReduceExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/fs/IgniteFsMapReduceExample.java b/examples/src/main/java/org/apache/ignite/examples/fs/IgniteFsMapReduceExample.java new file mode 100644 index 0000000..0a02d7a --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/fs/IgniteFsMapReduceExample.java @@ -0,0 +1,249 @@ +/* + * 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.examples.fs; + +import org.apache.ignite.*; +import org.apache.ignite.compute.*; +import org.apache.ignite.fs.*; +import org.apache.ignite.fs.mapreduce.*; +import org.apache.ignite.fs.mapreduce.records.*; + +import java.io.*; +import java.util.*; + +/** + * Example that shows how to use {@link org.apache.ignite.fs.mapreduce.IgniteFsTask} to find lines matching particular pattern in the file in pretty + * the same way as {@code grep} command does. + * <p> + * Remote nodes should always be started with configuration file which includes + * IgniteFs: {@code 'ignite.sh examples/config/filesystem/example-ignitefs.xml'}. + * <p> + * Alternatively you can run {@link IgniteFsNodeStartup} in another JVM which will start + * node with {@code examples/config/filesystem/example-ignitefs.xml} configuration. + */ +public class IgniteFsMapReduceExample { + /** + * Executes example. + * + * @param args Command line arguments. First argument is file name, second argument is regex to look for. + * @throws Exception If failed. + */ + public static void main(String[] args) throws Exception { + if (args.length == 0) + System.out.println("Please provide file name and regular expression."); + else if (args.length == 1) + System.out.println("Please provide regular expression."); + else { + try (Ignite ignite = Ignition.start("examples/config/filesystem/example-ignitefs.xml")) { + System.out.println(); + System.out.println(">>> IgniteFs map reduce example started."); + + // Prepare arguments. + String fileName = args[0]; + + File file = new File(fileName); + + String regexStr = args[1]; + + // Get an instance of Ignite File System. + IgniteFs fs = ignite.fileSystem("ignitefs"); + + // Working directory path. + IgniteFsPath workDir = new IgniteFsPath("/examples/fs"); + + // Write file to GGFS. + IgniteFsPath fsPath = new IgniteFsPath(workDir, file.getName()); + + writeFile(fs, fsPath, file); + + Collection<Line> lines = fs.execute(new GrepTask(), IgniteFsNewLineRecordResolver.NEW_LINE, + Collections.singleton(fsPath), regexStr); + + if (lines.isEmpty()) { + System.out.println(); + System.out.println("No lines were found."); + } + else { + for (Line line : lines) + print(line.fileLine()); + } + } + } + } + + /** + * Write file to the Ignite file system. + * + * @param fs Ignite file system. + * @param fsPath Ignite file system path. + * @param file File to write. + * @throws Exception In case of exception. + */ + private static void writeFile(IgniteFs fs, IgniteFsPath fsPath, File file) throws Exception { + System.out.println(); + System.out.println("Copying file to IgniteFs: " + file); + + try ( + IgniteFsOutputStream os = fs.create(fsPath, true); + FileInputStream fis = new FileInputStream(file) + ) { + byte[] buf = new byte[2048]; + + int read = fis.read(buf); + + while (read != -1) { + os.write(buf, 0, read); + + read = fis.read(buf); + } + } + } + + /** + * Print particular string. + * + * @param str String. + */ + private static void print(String str) { + System.out.println(">>> " + str); + } + + /** + * Grep task. + */ + private static class GrepTask extends IgniteFsTask<String, Collection<Line>> { + /** {@inheritDoc} */ + @Override public IgniteFsJob createJob(IgniteFsPath path, IgniteFsFileRange range, + IgniteFsTaskArgs<String> args) { + return new GrepJob(args.userArgument()); + } + + /** {@inheritDoc} */ + @Override public Collection<Line> reduce(List<ComputeJobResult> results) { + Collection<Line> lines = new TreeSet<>(new Comparator<Line>() { + @Override public int compare(Line line1, Line line2) { + return line1.rangePosition() < line2.rangePosition() ? -1 : + line1.rangePosition() > line2.rangePosition() ? 1 : line1.lineIndex() - line2.lineIndex(); + } + }); + + for (ComputeJobResult res : results) { + if (res.getException() != null) + throw res.getException(); + + Collection<Line> line = res.getData(); + + if (line != null) + lines.addAll(line); + } + + return lines; + } + } + + /** + * Grep job. + */ + private static class GrepJob extends IgniteFsInputStreamJobAdapter { + /** Regex string. */ + private final String regex; + + /** + * Constructor. + * + * @param regex Regex string. + */ + private GrepJob(String regex) { + this.regex = regex; + } + + /** {@inheritDoc} */ + @Override public Object execute(IgniteFs igniteFs, IgniteFsRangeInputStream in) throws IgniteException, IOException { + Collection<Line> res = null; + + long start = in.startOffset(); + + try (BufferedReader br = new BufferedReader(new InputStreamReader(in))) { + int ctr = 0; + + String line = br.readLine(); + + while (line != null) { + if (line.matches(".*" + regex + ".*")) { + if (res == null) + res = new HashSet<>(); + + res.add(new Line(start, ctr++, line)); + } + + line = br.readLine(); + } + } + + return res; + } + } + + /** + * Single file line with it's position. + */ + private static class Line { + /** Line start position in the file. */ + private long rangePos; + + /** Matching line index within the range. */ + private final int lineIdx; + + /** File line. */ + private String line; + + /** + * Constructor. + * + * @param rangePos Range position. + * @param lineIdx Matching line index within the range. + * @param line File line. + */ + private Line(long rangePos, int lineIdx, String line) { + this.rangePos = rangePos; + this.lineIdx = lineIdx; + this.line = line; + } + + /** + * @return Range position. + */ + public long rangePosition() { + return rangePos; + } + + /** + * @return Matching line index within the range. + */ + public int lineIndex() { + return lineIdx; + } + + /** + * @return File line. + */ + public String fileLine() { + return line; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2a26d960/examples/src/main/java/org/apache/ignite/examples/fs/IgniteFsNodeStartup.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/fs/IgniteFsNodeStartup.java b/examples/src/main/java/org/apache/ignite/examples/fs/IgniteFsNodeStartup.java new file mode 100644 index 0000000..0e7d19f --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/fs/IgniteFsNodeStartup.java @@ -0,0 +1,41 @@ +/* + * 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.examples.fs; + +import org.apache.ignite.*; + +/** + * Starts up an empty node with IgniteFs configuration. + * You can also start a stand-alone Ignite instance by passing the path + * to configuration file to {@code 'ignite.{sh|bat}'} script, like so: + * {@code 'ignite.sh examples/config/filesystem/example-ignitefs.xml'}. + * <p> + * The difference is that running this class from IDE adds all example classes to classpath + * but running from command line doesn't. + */ +public class IgniteFsNodeStartup { + /** + * Start up an empty node with specified cache configuration. + * + * @param args Command line arguments, none required. + * @throws IgniteException If example execution failed. + */ + public static void main(String[] args) throws IgniteException { + Ignition.start("examples/config/filesystem/example-ignitefs.xml"); + } +}