You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/07/20 16:55:04 UTC

[01/24] incubator-ignite git commit: Merge branch 'master' into ignite-788

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-788-last-review [created] 83e0a6893


Merge branch 'master' into ignite-788


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/0839e8d3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0839e8d3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0839e8d3

Branch: refs/heads/ignite-788-last-review
Commit: 0839e8d37fccf5f36dda3f2e61919b158999d11d
Parents: a79d2b4 d52fe87
Author: ashutak <as...@gridgain.com>
Authored: Tue Jul 14 18:41:11 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Tue Jul 14 18:41:11 2015 +0300

----------------------------------------------------------------------
 .gitignore                                      |    3 +-
 DEVNOTES.txt                                    |   63 +-
 LICENSE                                         |  238 +
 LICENSE.txt                                     |  238 -
 NOTICE                                          |   12 +
 NOTICE.txt                                      |   12 -
 RELEASE_NOTES.txt                               |   24 +
 assembly/dependencies-fabric.xml                |    2 +
 assembly/dependencies-visor-console.xml         |    3 +
 assembly/release-base.xml                       |    8 +-
 bin/ignite-schema-import.bat                    |    2 +-
 bin/ignite-schema-import.sh                     |    2 +-
 bin/ignite.bat                                  |   10 +-
 bin/ignite.sh                                   |    8 +-
 bin/ignitevisorcmd.bat                          |    2 +-
 bin/ignitevisorcmd.sh                           |    2 +-
 bin/include/build-classpath.bat                 |   46 +
 bin/include/build-classpath.sh                  |   71 +
 bin/include/functions.sh                        |    2 +-
 bin/include/parseargs.bat                       |    1 +
 bin/include/parseargs.sh                        |    3 +
 bin/include/target-classpath.bat                |   46 -
 bin/include/target-classpath.sh                 |   71 -
 dev-tools/build.gradle                          |   35 +-
 .../gradle/wrapper/gradle-wrapper.properties    |   20 +
 dev-tools/gradlew                               |  233 +
 dev-tools/slurp.sh                              |   76 +
 dev-tools/src/main/groovy/jiraslurp.groovy      |  592 +-
 examples/config/example-cache.xml               |    2 +
 examples/pom.xml                                |   36 +-
 .../hibernate/CacheHibernatePersonStore.java    |  202 +-
 .../hibernate/CacheHibernateStoreExample.java   |   17 +
 .../store/jdbc/CacheJdbcPersonStore.java        |  180 +-
 .../store/jdbc/CacheJdbcStoreExample.java       |   13 +
 .../store/spring/CacheSpringPersonStore.java    |  128 +
 .../store/spring/CacheSpringStoreExample.java   |  143 +
 .../datagrid/store/spring/package-info.java     |   22 +
 .../client/memcache/MemcacheRestExample.java    |   32 +-
 .../streaming/StreamTransformerExample.java     |    4 +-
 .../streaming/StreamVisitorExample.java         |    4 +-
 .../ignite/examples/streaming/package-info.java |    1 -
 .../streaming/wordcount/CacheConfig.java        |    2 +-
 .../streaming/wordcount/QueryWords.java         |   12 +-
 .../streaming/wordcount/StreamWords.java        |   12 +-
 .../streaming/wordcount/package-info.java       |    1 -
 .../socket/WordsSocketStreamerClient.java       |   82 +
 .../socket/WordsSocketStreamerServer.java       |  124 +
 .../wordcount/socket/package-info.java          |   21 +
 .../examples/ScalarCacheAffinityExample.scala   |    2 +-
 .../scalar/examples/ScalarCacheExample.scala    |    2 +-
 .../ScalarCachePopularNumbersExample.scala      |    2 +-
 .../examples/ScalarCacheQueryExample.scala      |    2 +-
 .../examples/ScalarSnowflakeSchemaExample.scala |    4 +-
 idea/ignite_codeStyle.xml                       |  147 +
 modules/aop/pom.xml                             |    2 +-
 modules/aws/pom.xml                             |    2 +-
 .../s3/S3CheckpointManagerSelfTest.java         |    2 +-
 .../checkpoint/s3/S3CheckpointSpiSelfTest.java  |    4 +-
 .../s3/S3CheckpointSpiStartStopSelfTest.java    |    2 +-
 .../s3/S3SessionCheckpointSelfTest.java         |    2 +-
 .../s3/TcpDiscoveryS3IpFinderSelfTest.java      |    2 +-
 modules/clients/pom.xml                         |    2 +-
 .../ClientAbstractConnectivitySelfTest.java     |   18 +-
 .../client/router/TcpSslRouterSelfTest.java     |    5 +
 .../client/suite/IgniteClientTestSuite.java     |    3 +-
 modules/cloud/pom.xml                           |    2 +-
 .../cloud/TcpDiscoveryCloudIpFinder.java        |   25 +-
 .../TcpDiscoveryCloudIpFinderSelfTest.java      |    3 +-
 modules/codegen/pom.xml                         |    2 +-
 modules/core/pom.xml                            |   14 +-
 modules/core/src/main/java/META-INF/LICENSE     |  238 +
 modules/core/src/main/java/META-INF/NOTICE      |   12 +
 .../src/main/java/org/apache/ignite/Ignite.java |   10 +-
 .../java/org/apache/ignite/IgniteCache.java     |   60 +-
 .../java/org/apache/ignite/IgniteServices.java  |    5 +-
 .../apache/ignite/IgniteSystemProperties.java   |    9 +
 .../main/java/org/apache/ignite/Ignition.java   |   18 +-
 .../org/apache/ignite/cache/CacheManager.java   |   13 +-
 .../org/apache/ignite/cache/CacheMetrics.java   |  187 +-
 .../affinity/fair/FairAffinityFunction.java     |    5 +-
 .../ignite/cache/eviction/EvictableEntry.java   |    7 +
 .../ignite/cache/eviction/EvictionPolicy.java   |    2 +
 .../cache/eviction/fifo/FifoEvictionPolicy.java |  112 +-
 .../eviction/fifo/FifoEvictionPolicyMBean.java  |   22 +
 .../cache/eviction/lru/LruEvictionPolicy.java   |  130 +-
 .../eviction/lru/LruEvictionPolicyMBean.java    |   38 +
 .../eviction/random/RandomEvictionPolicy.java   |   10 +-
 .../eviction/sorted/SortedEvictionPolicy.java   |  146 +-
 .../sorted/SortedEvictionPolicyMBean.java       |   22 +
 .../apache/ignite/cache/query/QueryMetrics.java |    6 +-
 .../apache/ignite/cache/query/ScanQuery.java    |   48 +-
 .../apache/ignite/cache/store/CacheStore.java   |    2 +
 .../ignite/cache/store/CacheStoreSession.java   |   22 +
 .../cache/store/CacheStoreSessionListener.java  |  133 +
 .../cache/store/jdbc/CacheJdbcBlobStore.java    |   22 +-
 .../store/jdbc/CacheJdbcBlobStoreFactory.java   |  290 +
 .../cache/store/jdbc/CacheJdbcPojoStore.java    |    6 +-
 .../store/jdbc/CacheJdbcPojoStoreFactory.java   |  148 +
 .../jdbc/CacheJdbcStoreSessionListener.java     |  141 +
 .../org/apache/ignite/cluster/ClusterGroup.java |   18 +-
 .../org/apache/ignite/cluster/ClusterNode.java  |   26 +-
 .../configuration/CacheConfiguration.java       |  179 +-
 .../configuration/IgniteConfiguration.java      |   48 +-
 .../configuration/IgniteReflectionFactory.java  |   81 +-
 .../configuration/NearCacheConfiguration.java   |   10 +-
 .../configuration/TransactionConfiguration.java |   23 +
 .../org/apache/ignite/igfs/IgfsUserContext.java |  119 +
 .../igfs/secondary/IgfsSecondaryFileSystem.java |    7 +
 .../ignite/internal/ClusterMetricsSnapshot.java |   14 +
 .../internal/GridEventConsumeHandler.java       |  126 +-
 .../ignite/internal/GridKernalContext.java      |    5 +
 .../ignite/internal/GridKernalContextImpl.java  |   13 +-
 .../ignite/internal/GridPluginContext.java      |    6 +
 .../apache/ignite/internal/IgniteKernal.java    |  118 +-
 .../ignite/internal/IgniteNodeAttributes.java   |    5 +-
 .../org/apache/ignite/internal/IgnitionEx.java  |  166 +-
 .../internal/MarshallerContextAdapter.java      |   82 +-
 .../ignite/internal/MarshallerContextImpl.java  |   38 +-
 .../client/GridClientConfiguration.java         |    2 +-
 .../GridClientOptimizedMarshaller.java          |   26 +
 .../impl/GridTcpRouterNioListenerAdapter.java   |    2 +-
 .../internal/cluster/ClusterGroupAdapter.java   |   50 +-
 .../cluster/IgniteClusterAsyncImpl.java         |   12 +-
 .../internal/direct/DirectByteBufferStream.java |    4 +-
 .../internal/events/DiscoveryCustomEvent.java   |   18 +-
 .../internal/igfs/common/IgfsMarshaller.java    |   35 +-
 .../igfs/common/IgfsPathControlRequest.java     |   22 +
 .../interop/InteropAwareEventFilter.java        |   37 +
 .../internal/interop/InteropBootstrap.java      |   35 +
 .../interop/InteropBootstrapFactory.java        |   39 +
 .../internal/interop/InteropException.java      |   71 +
 .../internal/interop/InteropIgnition.java       |  241 +
 .../interop/InteropLocalEventListener.java      |   28 +
 .../interop/InteropNoCallbackException.java     |   50 +
 .../internal/interop/InteropProcessor.java      |   51 +
 .../internal/managers/GridManagerAdapter.java   |   76 +-
 .../checkpoint/GridCheckpointManager.java       |   52 +-
 .../managers/communication/GridIoManager.java   |  294 +-
 .../managers/communication/GridIoMessage.java   |   15 +-
 .../managers/communication/GridIoPolicy.java    |   32 +-
 .../GridLifecycleAwareMessageFilter.java        |    5 +-
 .../managers/discovery/CustomEventListener.java |   31 +
 .../discovery/CustomMessageWrapper.java         |   63 +
 .../discovery/DiscoveryCustomMessage.java       |   54 +
 .../discovery/GridDiscoveryManager.java         |  364 +-
 .../eventstorage/GridEventStorageManager.java   |   31 +-
 .../managers/indexing/GridIndexingManager.java  |    4 -
 .../affinity/AffinityTopologyVersion.java       |    7 -
 .../affinity/GridAffinityAssignment.java        |   12 +
 .../affinity/GridAffinityAssignmentCache.java   |   40 +-
 .../affinity/GridAffinityProcessor.java         |   23 +-
 .../cache/CacheEvictableEntryImpl.java          |   31 +
 .../processors/cache/CacheMetricsImpl.java      |  367 +-
 .../cache/CacheMetricsMXBeanImpl.java           |  100 +
 .../processors/cache/CacheMetricsSnapshot.java  |  380 +-
 .../processors/cache/CacheObjectImpl.java       |    1 -
 .../processors/cache/CacheOperationContext.java |   44 +-
 .../internal/processors/cache/CacheType.java    |    8 +-
 .../cache/DynamicCacheChangeBatch.java          |   29 +-
 .../cache/DynamicCacheChangeRequest.java        |   39 +-
 .../cache/DynamicCacheDescriptor.java           |   19 +
 .../processors/cache/GridCacheAdapter.java      |  297 +-
 .../cache/GridCacheAffinityManager.java         |   14 +
 .../processors/cache/GridCacheAtomicFuture.java |   12 +-
 .../processors/cache/GridCacheAttributes.java   |    3 +
 .../cache/GridCacheConcurrentMap.java           |   21 +-
 .../processors/cache/GridCacheContext.java      |   57 +-
 .../cache/GridCacheDeploymentManager.java       |   10 +-
 .../processors/cache/GridCacheEntryEx.java      |    6 +
 .../processors/cache/GridCacheGateway.java      |    6 +-
 .../processors/cache/GridCacheIoManager.java    |   96 +-
 .../processors/cache/GridCacheMapEntry.java     |  172 +-
 .../processors/cache/GridCacheMessage.java      |   51 -
 .../processors/cache/GridCacheMvccManager.java  |   44 +-
 .../GridCachePartitionExchangeManager.java      |  184 +-
 .../processors/cache/GridCachePreloader.java    |    6 +-
 .../cache/GridCachePreloaderAdapter.java        |   11 +-
 .../processors/cache/GridCacheProcessor.java    |  436 +-
 .../processors/cache/GridCacheProxyImpl.java    |   36 +-
 .../cache/GridCacheSharedContext.java           |   61 +-
 .../processors/cache/GridCacheSwapManager.java  |  394 +-
 .../processors/cache/GridCacheTtlManager.java   |    9 +-
 .../processors/cache/GridCacheUtils.java        |  337 +-
 .../processors/cache/IgniteCacheFutureImpl.java |   42 +
 .../processors/cache/IgniteCacheProxy.java      |  527 +-
 .../processors/cache/IgniteInternalCache.java   |   43 +-
 .../processors/cache/KeyCacheObjectImpl.java    |   11 +-
 .../processors/cache/QueryCursorImpl.java       |   23 +-
 .../cache/affinity/GridCacheAffinityImpl.java   |   10 +-
 .../CacheDataStructuresManager.java             |    2 +-
 .../distributed/GridCacheTxRecoveryRequest.java |   26 +-
 .../GridCacheTxRecoveryResponse.java            |   14 +-
 .../distributed/GridDistributedBaseMessage.java |   77 +-
 .../GridDistributedCacheAdapter.java            |  210 +-
 .../distributed/GridDistributedCacheEntry.java  |    7 -
 .../distributed/GridDistributedLockRequest.java |  123 +-
 .../GridDistributedLockResponse.java            |   14 +-
 .../GridDistributedTxFinishRequest.java         |  101 +-
 .../distributed/GridDistributedTxMapping.java   |   22 +-
 .../GridDistributedTxPrepareRequest.java        |  137 +-
 .../GridDistributedTxPrepareResponse.java       |   64 +-
 .../GridDistributedTxRemoteAdapter.java         |   33 +-
 .../GridDistributedUnlockRequest.java           |    6 +-
 .../dht/GridClientPartitionTopology.java        |   10 +-
 .../dht/GridDhtAssignmentFetchFuture.java       |    4 +-
 .../distributed/dht/GridDhtCacheAdapter.java    |   49 +-
 .../distributed/dht/GridDhtCacheEntry.java      |   10 +-
 .../cache/distributed/dht/GridDhtGetFuture.java |   11 +-
 .../distributed/dht/GridDhtLocalPartition.java  |   66 +-
 .../distributed/dht/GridDhtLockFuture.java      |   14 +-
 .../distributed/dht/GridDhtLockRequest.java     |  101 +-
 .../distributed/dht/GridDhtLockResponse.java    |   18 +-
 .../dht/GridDhtOffHeapCacheEntry.java           |   63 +
 .../dht/GridDhtPartitionTopologyImpl.java       |   42 +-
 .../dht/GridDhtPartitionsReservation.java       |  292 +
 .../dht/GridDhtTransactionalCacheAdapter.java   |  239 +-
 .../distributed/dht/GridDhtTxFinishFuture.java  |    3 -
 .../distributed/dht/GridDhtTxFinishRequest.java |   46 +-
 .../cache/distributed/dht/GridDhtTxLocal.java   |   41 +-
 .../distributed/dht/GridDhtTxLocalAdapter.java  |  106 +-
 .../cache/distributed/dht/GridDhtTxMapping.java |    2 +-
 .../distributed/dht/GridDhtTxPrepareFuture.java |  103 +-
 .../dht/GridDhtTxPrepareRequest.java            |   60 +-
 .../dht/GridDhtTxPrepareResponse.java           |   22 +-
 .../cache/distributed/dht/GridDhtTxRemote.java  |   13 +-
 .../distributed/dht/GridDhtUnlockRequest.java   |    6 +-
 .../distributed/dht/GridNoStorageCacheMap.java  |    4 +-
 .../dht/GridPartitionedGetFuture.java           |   13 +-
 .../cache/distributed/dht/GridReservable.java   |   35 +
 .../dht/atomic/GridDhtAtomicCache.java          |   69 +-
 .../atomic/GridDhtAtomicOffHeapCacheEntry.java  |   63 +
 .../dht/atomic/GridDhtAtomicUpdateFuture.java   |   23 +-
 .../dht/atomic/GridNearAtomicUpdateFuture.java  |  283 +-
 .../dht/atomic/GridNearAtomicUpdateRequest.java |  134 +-
 .../dht/colocated/GridDhtColocatedCache.java    |   17 +-
 .../colocated/GridDhtColocatedLockFuture.java   |  210 +-
 .../GridDhtColocatedOffHeapCacheEntry.java      |   63 +
 .../colocated/GridDhtDetachedCacheEntry.java    |    4 +-
 .../dht/preloader/GridDhtForceKeysFuture.java   |   44 +-
 .../preloader/GridDhtPartitionDemandPool.java   |   26 +-
 .../dht/preloader/GridDhtPartitionMap.java      |   28 +-
 .../preloader/GridDhtPartitionSupplyPool.java   |   29 +-
 .../GridDhtPartitionsExchangeFuture.java        |  531 +-
 .../preloader/GridDhtPartitionsFullMessage.java |    4 +-
 .../GridDhtPartitionsSingleMessage.java         |   33 +-
 .../dht/preloader/GridDhtPreloader.java         |   41 +-
 .../preloader/GridDhtPreloaderAssignments.java  |    3 +-
 .../distributed/near/GridNearAtomicCache.java   |    5 +
 .../distributed/near/GridNearCacheAdapter.java  |    5 +-
 .../distributed/near/GridNearCacheEntry.java    |    6 +-
 .../distributed/near/GridNearGetFuture.java     |    6 +-
 .../distributed/near/GridNearLockFuture.java    |  280 +-
 .../distributed/near/GridNearLockRequest.java   |   91 +-
 .../distributed/near/GridNearLockResponse.java  |   30 +-
 .../near/GridNearOffHeapCacheEntry.java         |   60 +
 .../near/GridNearOptimisticTxPrepareFuture.java |  815 +++
 .../GridNearPessimisticTxPrepareFuture.java     |  350 ++
 .../near/GridNearTransactionalCache.java        |    8 +-
 .../near/GridNearTxFinishRequest.java           |   31 +-
 .../cache/distributed/near/GridNearTxLocal.java |  155 +-
 .../near/GridNearTxPrepareFuture.java           | 1050 ----
 .../near/GridNearTxPrepareFutureAdapter.java    |  231 +
 .../near/GridNearTxPrepareRequest.java          |   86 +-
 .../near/GridNearTxPrepareResponse.java         |   94 +-
 .../distributed/near/GridNearTxRemote.java      |   29 +-
 .../distributed/near/GridNearUnlockRequest.java |    2 +-
 .../cache/jta/CacheJtaManagerAdapter.java       |   17 +-
 .../cache/jta/CacheNoopJtaManager.java          |    2 +-
 .../processors/cache/local/GridLocalCache.java  |    6 +-
 .../cache/local/GridLocalCacheEntry.java        |   18 +
 .../local/atomic/GridLocalAtomicCache.java      |   31 +-
 .../processors/cache/query/CacheQuery.java      |    2 +-
 .../query/GridCacheDistributedQueryManager.java |    3 +
 .../cache/query/GridCacheQueryAdapter.java      |  200 +-
 .../cache/query/GridCacheQueryErrorFuture.java  |    2 +
 .../cache/query/GridCacheQueryManager.java      |  243 +-
 .../cache/query/GridCacheQueryRequest.java      |   47 +-
 .../cache/query/GridCacheTwoStepQuery.java      |   22 +-
 .../processors/cache/query/QueryCursorEx.java   |    8 +
 .../continuous/CacheContinuousQueryHandler.java |   12 +-
 .../continuous/CacheContinuousQueryManager.java |   28 +-
 .../cache/store/CacheOsStoreManager.java        |    1 -
 .../cache/store/CacheStoreManager.java          |    7 +-
 .../store/GridCacheStoreManagerAdapter.java     |  202 +-
 .../cache/transactions/IgniteInternalTx.java    |   22 +-
 .../transactions/IgniteTransactionsImpl.java    |    4 +-
 .../cache/transactions/IgniteTxAdapter.java     |  127 +-
 .../cache/transactions/IgniteTxEntry.java       |   48 +-
 .../cache/transactions/IgniteTxHandler.java     |  225 +-
 .../transactions/IgniteTxLocalAdapter.java      |  348 +-
 .../cache/transactions/IgniteTxLocalEx.java     |   21 +-
 .../cache/transactions/IgniteTxManager.java     |  101 +-
 .../cacheobject/IgniteCacheObjectProcessor.java |   14 +-
 .../IgniteCacheObjectProcessorImpl.java         |   14 +-
 .../processors/clock/GridClockServer.java       |   21 +-
 .../continuous/AbstractContinuousMessage.java   |   63 +
 .../continuous/GridContinuousMessageType.java   |   12 -
 .../continuous/GridContinuousProcessor.java     |  853 +--
 .../processors/continuous/StartRequestData.java |  267 +
 .../StartRoutineAckDiscoveryMessage.java        |   63 +
 .../StartRoutineDiscoveryMessage.java           |   85 +
 .../StopRoutineAckDiscoveryMessage.java         |   49 +
 .../continuous/StopRoutineDiscoveryMessage.java |   49 +
 .../datastreamer/DataStreamProcessor.java       |    3 +
 .../datastreamer/DataStreamerCacheUpdaters.java |    2 +-
 .../datastreamer/DataStreamerImpl.java          |  102 +-
 .../datastructures/DataStructuresProcessor.java |  273 +-
 .../datastructures/GridCacheAtomicLongImpl.java |   25 +-
 .../GridCacheAtomicSequenceImpl.java            |   11 +-
 .../GridCacheAtomicStampedImpl.java             |   21 +-
 .../GridCacheCountDownLatchImpl.java            |   31 +-
 .../datastructures/GridCacheSetImpl.java        |    4 +-
 .../dr/IgniteDrDataStreamerCacheUpdater.java    |    7 +-
 .../internal/processors/hadoop/HadoopJob.java   |    2 +-
 .../processors/hadoop/HadoopJobInfo.java        |    4 +-
 .../processors/hadoop/HadoopTaskContext.java    |   14 +-
 .../hadoop/counter/HadoopCounterWriter.java     |    5 +-
 .../internal/processors/igfs/IgfsContext.java   |    5 +-
 .../ignite/internal/processors/igfs/IgfsEx.java |    8 +-
 .../internal/processors/igfs/IgfsImpl.java      |    8 +-
 .../processors/igfs/IgfsIpcHandler.java         |  184 +-
 .../processors/igfs/IgfsMetaManager.java        |    2 +-
 .../igfs/IgfsSecondaryFileSystemImpl.java       |    9 +-
 .../internal/processors/igfs/IgfsServer.java    |    4 +-
 .../internal/processors/igfs/IgfsUtils.java     |   16 +
 .../offheap/GridOffHeapProcessor.java           |   19 +-
 .../processors/plugin/CachePluginManager.java   |   10 +-
 .../plugin/IgnitePluginProcessor.java           |   19 +-
 .../portable/GridPortableInputStream.java       |   10 +
 .../processors/query/GridQueryIndexing.java     |   34 +-
 .../processors/query/GridQueryProcessor.java    |  435 +-
 .../messages/GridQueryNextPageResponse.java     |   35 +-
 .../h2/twostep/messages/GridQueryRequest.java   |  111 +-
 .../processors/resource/GridResourceField.java  |    5 +-
 .../processors/resource/GridResourceIoc.java    |   20 +-
 .../resource/GridResourceProcessor.java         |   16 +-
 .../processors/rest/GridRestProcessor.java      |    4 +-
 .../rest/client/message/GridRouterRequest.java  |   18 +
 .../rest/client/message/GridRouterResponse.java |   18 +
 .../handlers/task/GridTaskCommandHandler.java   |   12 +-
 .../rest/protocols/tcp/GridTcpRestProtocol.java |    3 +-
 .../service/GridServiceProcessor.java           |  125 +-
 .../processors/task/GridTaskProcessor.java      |   23 +-
 .../processors/task/GridTaskWorker.java         |    4 +-
 .../timeout/GridSpiTimeoutObject.java           |   73 +
 .../timeout/GridTimeoutProcessor.java           |  105 +-
 .../IgniteTxRollbackCheckedException.java       |    9 +
 .../internal/util/GridConfigurationFinder.java  |   55 +-
 .../apache/ignite/internal/util/GridDebug.java  |   48 +-
 .../ignite/internal/util/GridJavaProcess.java   |   30 +-
 .../ignite/internal/util/IgniteUtils.java       |   47 +-
 .../internal/util/future/GridFutureAdapter.java |    4 +-
 .../internal/util/future/IgniteFutureImpl.java  |   18 +-
 .../shmem/IpcSharedMemoryClientEndpoint.java    |    2 +-
 .../ipc/shmem/IpcSharedMemoryNativeLoader.java  |  151 +-
 .../shmem/IpcSharedMemoryServerEndpoint.java    |   14 +-
 .../util/ipc/shmem/IpcSharedMemoryUtils.java    |    4 +-
 .../util/lang/GridComputeJobWrapper.java        |   96 -
 .../internal/util/nio/GridBufferedParser.java   |    4 -
 .../util/nio/GridCommunicationClient.java       |   30 +-
 .../internal/util/nio/GridDelimitedParser.java  |   91 +
 .../util/nio/GridNioDelimitedBuffer.java        |  106 +
 .../util/nio/GridNioMessageTracker.java         |   23 +-
 .../util/nio/GridNioRecoveryDescriptor.java     |   13 +-
 .../ignite/internal/util/nio/GridNioServer.java |   64 +-
 .../util/nio/GridShmemCommunicationClient.java  |  146 +
 .../util/nio/GridTcpCommunicationClient.java    |  554 --
 .../util/nio/GridTcpNioCommunicationClient.java |    8 -
 .../util/spring/IgniteSpringHelper.java         |   10 +
 .../apache/ignite/internal/visor/VisorJob.java  |    2 +
 .../internal/visor/VisorMultiNodeTask.java      |    2 +-
 .../ignite/internal/visor/cache/VisorCache.java |    2 +-
 .../visor/cache/VisorCacheConfiguration.java    |   11 -
 .../VisorCacheConfigurationCollectorJob.java    |    6 +-
 .../internal/visor/cache/VisorCacheMetrics.java |   19 +-
 .../cache/VisorCacheMetricsCollectorTask.java   |   10 +-
 .../visor/cache/VisorCacheStopTask.java         |    2 +-
 .../cache/VisorCacheStoreConfiguration.java     |    5 +-
 .../internal/visor/log/VisorLogSearchTask.java  |    2 +-
 .../visor/node/VisorNodeDataCollectorJob.java   |    4 +
 .../visor/node/VisorNodeDataCollectorTask.java  |    9 +-
 .../node/VisorNodeDataCollectorTaskResult.java  |   17 +-
 .../node/VisorNodeSuppressedErrorsTask.java     |   12 +-
 .../visor/query/VisorQueryCleanupTask.java      |   14 +
 .../internal/visor/query/VisorQueryJob.java     |   13 +-
 .../internal/visor/query/VisorQueryTask.java    |    3 +-
 .../util/VisorClusterGroupEmptyException.java   |   37 +
 .../visor/util/VisorExceptionWrapper.java       |   81 +
 .../internal/visor/util/VisorTaskUtils.java     |    6 +-
 .../ignite/marshaller/MarshallerContext.java    |    8 +
 .../ignite/mxbean/CacheMetricsMXBean.java       |   80 +
 .../org/apache/ignite/plugin/PluginContext.java |    6 +
 .../apache/ignite/plugin/PluginProvider.java    |   26 +-
 .../plugin/extensions/communication/IoPool.java |   42 +
 .../SpringApplicationContextResource.java       |    4 +-
 .../apache/ignite/resources/SpringResource.java |    6 +-
 .../org/apache/ignite/services/Service.java     |    5 +-
 .../org/apache/ignite/spi/IgniteSpiAdapter.java |  105 +-
 .../org/apache/ignite/spi/IgniteSpiContext.java |   66 +-
 .../ignite/spi/IgniteSpiTimeoutObject.java      |   44 +
 .../spi/checkpoint/noop/NoopCheckpointSpi.java  |    3 +-
 .../communication/tcp/TcpCommunicationSpi.java  |  965 +--
 .../tcp/TcpCommunicationSpiMBean.java           |   29 +-
 .../ignite/spi/discovery/DiscoverySpi.java      |   23 +-
 .../discovery/DiscoverySpiCustomMessage.java    |   40 +
 .../spi/discovery/DiscoverySpiListener.java     |    5 +-
 .../ignite/spi/discovery/tcp/ClientImpl.java    | 1722 ++++++
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 4896 +++++++++++++++
 .../discovery/tcp/TcpClientDiscoverySpi.java    | 1264 ----
 .../tcp/TcpClientDiscoverySpiMBean.java         |  164 -
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     |  279 +
 .../spi/discovery/tcp/TcpDiscoverySpi.java      | 5818 ++++--------------
 .../discovery/tcp/TcpDiscoverySpiAdapter.java   | 1160 ----
 .../spi/discovery/tcp/TcpDiscoverySpiMBean.java |    9 +
 .../tcp/internal/TcpDiscoveryNode.java          |   35 +-
 .../tcp/internal/TcpDiscoveryNodesRing.java     |   10 +-
 .../tcp/internal/TcpDiscoveryStatistics.java    |   10 +-
 .../tcp/ipfinder/TcpDiscoveryIpFinder.java      |   10 +-
 .../ipfinder/TcpDiscoveryIpFinderAdapter.java   |   34 +-
 .../TcpDiscoveryMulticastIpFinder.java          |  114 +-
 .../messages/TcpDiscoveryAbstractMessage.java   |   34 +-
 .../TcpDiscoveryClientHeartbeatMessage.java     |   67 +
 .../messages/TcpDiscoveryClientPingRequest.java |   56 +
 .../TcpDiscoveryClientPingResponse.java         |   67 +
 .../TcpDiscoveryCustomEventMessage.java         |   41 +-
 .../messages/TcpDiscoveryHeartbeatMessage.java  |   28 +-
 .../TcpDiscoveryNodeAddFinishedMessage.java     |   43 +
 .../messages/TcpDiscoveryNodeAddedMessage.java  |    2 +-
 .../messages/TcpDiscoveryNodeFailedMessage.java |   18 +
 .../tcp/messages/TcpDiscoveryPingRequest.java   |    6 +
 .../tcp/messages/TcpDiscoveryPingResponse.java  |   15 +-
 .../RoundRobinGlobalLoadBalancer.java           |    2 +-
 .../spi/swapspace/file/FileSwapSpaceSpi.java    |    8 +-
 .../startup/cmdline/CommandLineStartup.java     |    3 +-
 .../startup/cmdline/CommandLineTransformer.java |    9 +
 .../org/apache/ignite/stream/StreamAdapter.java |  111 +
 .../ignite/stream/StreamTupleExtractor.java     |   33 +
 .../stream/socket/SocketMessageConverter.java   |   31 +
 .../ignite/stream/socket/SocketStreamer.java    |  218 +
 .../ignite/stream/socket/package-info.java      |   21 +
 .../java/org/jsr166/ConcurrentHashMap8.java     |    8 +-
 .../java/org/jsr166/ConcurrentLinkedDeque8.java |  586 +-
 .../src/main/java/org/jsr166/LongAdder8.java    |   35 +-
 .../core/src/main/java/org/jsr166/README.txt    |   11 +
 .../src/main/java/org/jsr166/Striped64_8.java   |   22 +-
 .../java/org/jsr166/ThreadLocalRandom8.java     |   19 +-
 .../src/main/java/org/jsr166/package-info.java  |   12 +-
 .../META-INF/classnames-jdk.properties          |    3 +
 .../resources/META-INF/classnames.properties    |    1 -
 .../core/src/main/resources/ignite.properties   |    2 +-
 .../core/src/test/config/spark/spark-config.xml |   46 +
 modules/core/src/test/config/tests.properties   |    8 +-
 .../ignite/GridSuppressedExceptionSelfTest.java |    4 +-
 .../affinity/IgniteClientNodeAffinityTest.java  |  192 +
 .../IgniteFairAffinityDynamicCacheSelfTest.java |    3 +-
 ...cheStoreSessionListenerAbstractSelfTest.java |  333 +
 ...heStoreSessionListenerLifecycleSelfTest.java |  395 ++
 .../CacheJdbcStoreSessionListenerSelfTest.java  |  175 +
 .../internal/ClusterGroupAbstractTest.java      |  777 +++
 .../internal/ClusterGroupHostsSelfTest.java     |  141 +
 .../ignite/internal/ClusterGroupSelfTest.java   |  251 +
 .../ignite/internal/GridAffinitySelfTest.java   |    1 +
 .../internal/GridDiscoveryEventSelfTest.java    |   13 +-
 ...ridFailFastNodeFailureDetectionSelfTest.java |   22 +-
 .../GridFailoverTaskWithPredicateSelfTest.java  |    3 -
 .../GridJobMasterLeaveAwareSelfTest.java        |    2 -
 .../internal/GridJobStealingSelfTest.java       |    3 -
 .../internal/GridProjectionAbstractTest.java    |  768 ---
 .../GridProjectionForCachesSelfTest.java        |   11 +-
 ...ectionLocalJobMultipleArgumentsSelfTest.java |    2 -
 .../ignite/internal/GridProjectionSelfTest.java |  251 -
 .../internal/GridReleaseTypeSelfTest.java       |   77 +-
 .../apache/ignite/internal/GridSelfTest.java    |   30 +-
 .../GridTaskExecutionContextSelfTest.java       |    9 -
 .../GridTaskFailoverAffinityRunTest.java        |  170 +
 .../IgniteComputeEmptyClusterGroupTest.java     |    3 -
 .../IgniteComputeTopologyExceptionTest.java     |    9 -
 .../IgniteSlowClientDetectionSelfTest.java      |  187 +
 .../communication/GridIoManagerSelfTest.java    |    2 +-
 .../GridDiscoveryManagerAliveCacheSelfTest.java |   82 +-
 .../GridDiscoveryManagerAttributesSelfTest.java |  122 +-
 .../discovery/GridDiscoveryManagerSelfTest.java |   46 +-
 .../IgniteTopologyPrintFormatSelfTest.java      |  289 +
 .../GridCacheTxLoadFromStoreOnLockSelfTest.java |   34 +-
 .../GridAffinityProcessorAbstractSelfTest.java  |    1 +
 .../cache/CacheClientStoreSelfTest.java         |  228 +
 .../cache/CacheFutureExceptionSelfTest.java     |  158 +
 .../CacheMetricsForClusterGroupSelfTest.java    |   10 +-
 .../cache/CacheOffheapMapEntrySelfTest.java     |  173 +
 .../CacheReadThroughAtomicRestartSelfTest.java  |   32 +
 ...heReadThroughLocalAtomicRestartSelfTest.java |   32 +
 .../CacheReadThroughLocalRestartSelfTest.java   |   32 +
 ...dThroughReplicatedAtomicRestartSelfTest.java |   32 +
 ...cheReadThroughReplicatedRestartSelfTest.java |   32 +
 .../cache/CacheReadThroughRestartSelfTest.java  |  133 +
 .../cache/CacheRemoveAllSelfTest.java           |   81 +
 .../cache/CacheStopAndDestroySelfTest.java      |  859 +++
 .../CacheStoreUsageMultinodeAbstractTest.java   |  305 +
 ...eUsageMultinodeDynamicStartAbstractTest.java |  169 +
 ...oreUsageMultinodeDynamicStartAtomicTest.java |   32 +
 ...heStoreUsageMultinodeDynamicStartTxTest.java |   32 +
 ...reUsageMultinodeStaticStartAbstractTest.java |  158 +
 ...toreUsageMultinodeStaticStartAtomicTest.java |   32 +
 ...cheStoreUsageMultinodeStaticStartTxTest.java |   32 +
 .../GridCacheAbstractFailoverSelfTest.java      |   12 +-
 .../cache/GridCacheAbstractFullApiSelfTest.java |  475 +-
 .../cache/GridCacheAbstractMetricsSelfTest.java |   48 +-
 .../GridCacheAbstractRemoveFailureTest.java     |   23 +
 .../cache/GridCacheAbstractSelfTest.java        |   21 +-
 .../cache/GridCacheAffinityRoutingSelfTest.java |    4 +-
 .../GridCacheAtomicMessageCountSelfTest.java    |    1 +
 .../GridCacheConcurrentTxMultiNodeTest.java     |    8 +-
 ...idCacheConfigurationConsistencySelfTest.java |   14 +-
 .../cache/GridCacheDeploymentSelfTest.java      |    3 -
 .../cache/GridCacheEntryMemorySizeSelfTest.java |   91 +-
 .../GridCacheExAbstractFullApiSelfTest.java     |  103 -
 .../cache/GridCacheMemoryModeSelfTest.java      |   25 +-
 ...GridCacheMixedPartitionExchangeSelfTest.java |    2 +-
 ...ridCacheMultinodeUpdateAbstractSelfTest.java |    9 +
 ...inodeUpdateNearEnabledNoBackupsSelfTest.java |    2 +-
 ...CacheMultinodeUpdateNearEnabledSelfTest.java |    2 +-
 .../processors/cache/GridCacheOffHeapTest.java  |   33 +-
 .../cache/GridCachePutAllFailoverSelfTest.java  |    1 +
 .../GridCacheReferenceCleanupSelfTest.java      |    3 -
 .../cache/GridCacheReloadSelfTest.java          |    6 +-
 .../GridCacheReturnValueTransferSelfTest.java   |    3 +
 .../processors/cache/GridCacheStopSelfTest.java |    5 +
 ...acheTcpClientDiscoveryMultiThreadedTest.java |  190 +
 .../processors/cache/GridCacheTestEntryEx.java  |    4 +
 .../GridCacheVariableTopologySelfTest.java      |   12 +-
 .../cache/GridCacheVersionMultinodeTest.java    |    6 +-
 ...ProjectionForCachesOnDaemonNodeSelfTest.java |    2 +-
 .../IgniteCacheAbstractStopBusySelfTest.java    |   36 +-
 .../cache/IgniteCacheAbstractTest.java          |    5 +-
 .../IgniteCacheAtomicStopBusySelfTest.java      |    8 +-
 .../IgniteCacheConfigurationTemplateTest.java   |   28 +-
 .../IgniteCacheEntryListenerAbstractTest.java   |   14 +-
 .../IgniteCacheInterceptorSelfTestSuite.java    |    2 +-
 .../cache/IgniteCacheInvokeReadThroughTest.java |    5 +
 .../cache/IgniteCacheNearLockValueSelfTest.java |  148 +
 .../IgniteCacheP2pUnmarshallingErrorTest.java   |   29 +-
 ...gniteCacheP2pUnmarshallingNearErrorTest.java |   13 +-
 ...CacheP2pUnmarshallingRebalanceErrorTest.java |   15 +-
 .../IgniteCacheP2pUnmarshallingTxErrorTest.java |   25 +-
 .../IgniteCachePartitionMapUpdateTest.java      |  226 +
 .../cache/IgniteCachePeekModesAbstractTest.java |    5 +-
 ...gniteCacheTransactionalStopBusySelfTest.java |   13 +-
 .../IgniteDaemonNodeMarshallerCacheTest.java    |  192 +
 ...eDynamicCacheStartNoExchangeTimeoutTest.java |  466 ++
 .../cache/IgniteDynamicCacheStartSelfTest.java  |  286 +-
 ...niteDynamicCacheWithConfigStartSelfTest.java |   97 +
 .../IgniteDynamicClientCacheStartSelfTest.java  |  284 +
 .../cache/IgniteInternalCacheTypesTest.java     |    3 +-
 ...teStartCacheInTransactionAtomicSelfTest.java |   32 +
 .../IgniteStartCacheInTransactionSelfTest.java  |  254 +
 .../cache/IgniteSystemCacheOnClientTest.java    |   97 +
 .../IgniteTxMultiThreadedAbstractTest.java      |    4 +-
 ...cheAtomicReferenceMultiNodeAbstractTest.java |   11 -
 .../GridCacheQueueApiSelfAbstractTest.java      |    4 +-
 ...GridCacheQueueMultiNodeAbstractSelfTest.java |    6 +-
 ...dCacheQueueMultiNodeConsistencySelfTest.java |    5 +
 ...CacheQueueRotativeMultiNodeAbstractTest.java |   10 -
 .../GridCacheSetAbstractSelfTest.java           |   31 +-
 .../IgniteClientDataStructuresAbstractTest.java |  340 +
 .../IgniteClientDataStructuresTest.java         |   28 +
 ...IgniteClientDiscoveryDataStructuresTest.java |   28 +
 .../IgniteCountDownLatchAbstractSelfTest.java   |  114 +-
 .../IgniteDataStructureWithJobTest.java         |  111 +
 ...omicOffheapQueueCreateMultiNodeSelfTest.java |    5 +
 ...ionedAtomicQueueCreateMultiNodeSelfTest.java |    5 +
 ...rtitionedDataStructuresFailoverSelfTest.java |    5 +
 ...edOffheapDataStructuresFailoverSelfTest.java |    5 +
 ...PartitionedQueueCreateMultiNodeSelfTest.java |    5 +
 ...dCachePartitionedQueueEntryMoveSelfTest.java |    5 +
 ...nedQueueFailoverDataConsistencySelfTest.java |    5 +
 ...eplicatedDataStructuresFailoverSelfTest.java |    5 +
 ...CacheLoadingConcurrentGridStartSelfTest.java |    5 +
 .../GridCacheAbstractJobExecutionTest.java      |    3 -
 .../GridCacheAbstractNodeRestartSelfTest.java   |   11 +-
 .../GridCacheClientModesAbstractSelfTest.java   |   94 +-
 ...ientModesTcpClientDiscoveryAbstractTest.java |  168 +
 .../distributed/GridCacheLockAbstractTest.java  |    2 -
 .../distributed/GridCacheMixedModeSelfTest.java |    3 +
 ...ridCachePartitionNotLoadedEventSelfTest.java |   82 +
 .../GridCachePreloadLifecycleAbstractTest.java  |    2 -
 .../distributed/IgniteCache150ClientsTest.java  |  189 +
 ...niteCacheClientNodeChangingTopologyTest.java | 1803 ++++++
 .../IgniteCacheClientNodeConcurrentStart.java   |  113 +
 ...teCacheClientNodePartitionsExchangeTest.java |  656 ++
 .../distributed/IgniteCacheManyClientsTest.java |  318 +
 .../IgniteCacheMessageRecoveryAbstractTest.java |    1 +
 .../IgniteCacheTxMessageRecoveryTest.java       |    5 +
 .../IgniteCrossCacheTxStoreSelfTest.java        |  147 +-
 .../distributed/IgniteTxGetAfterStopTest.java   |  131 +
 ...heAbstractTransformWriteThroughSelfTest.java |    3 -
 .../dht/GridCacheClientOnlySelfTest.java        |   60 +-
 .../GridCacheColocatedTxExceptionSelfTest.java  |    5 +
 .../GridCacheDhtClientRemoveFailureTest.java    |   28 +
 ...GridCacheDhtEvictionNearReadersSelfTest.java |   11 +-
 .../dht/GridCacheDhtEvictionSelfTest.java       |   11 +-
 .../GridCacheExColocatedFullApiSelfTest.java    |   33 -
 ...achePartitionedNearDisabledLockSelfTest.java |   47 +
 ...ePartitionedNearDisabledMetricsSelfTest.java |    4 +-
 ...dCachePartitionedTopologyChangeSelfTest.java |    5 +
 .../dht/IgniteCacheMultiTxLockSelfTest.java     |   53 +-
 ...ePrimaryNodeFailureRecoveryAbstractTest.java |    4 +-
 .../IgniteCachePutRetryAbstractSelfTest.java    |  147 +
 .../dht/IgniteCachePutRetryAtomicSelfTest.java  |   34 +
 ...gniteCachePutRetryTransactionalSelfTest.java |   74 +
 ...cClientInvalidPartitionHandlingSelfTest.java |   29 +
 .../GridCacheAtomicClientRemoveFailureTest.java |   28 +
 ...eAtomicInvalidPartitionHandlingSelfTest.java |   28 +-
 ...idCacheAtomicReplicatedFailoverSelfTest.java |    6 +
 ...unctionExcludeNeighborsAbstractSelfTest.java |    3 +-
 ...eAtomicNearOnlyMultiNodeFullApiSelfTest.java |    3 +
 .../near/GridCacheAtomicNearOnlySelfTest.java   |   32 -
 .../near/GridCacheExNearFullApiSelfTest.java    |   39 -
 .../near/GridCacheNearEvictionSelfTest.java     |    3 -
 ...idCacheNearOnlyMultiNodeFullApiSelfTest.java |   12 +-
 .../near/GridCacheNearOnlySelfTest.java         |   63 +-
 .../near/GridCacheNearOnlyTopologySelfTest.java |    1 +
 .../near/GridCacheNearTxExceptionSelfTest.java  |    5 +
 .../near/GridCacheNearTxMultiNodeSelfTest.java  |   10 +-
 ...ionedClientOnlyNoPrimaryFullApiSelfTest.java |    5 +-
 .../GridCachePartitionedEvictionSelfTest.java   |   11 +-
 .../GridCachePartitionedFailoverSelfTest.java   |    5 +
 ...PartitionedFullApiMultithreadedSelfTest.java |    5 +
 .../GridCachePartitionedFullApiSelfTest.java    |   32 +
 ...idCachePartitionedHitsAndMissesSelfTest.java |    3 -
 ...achePartitionedMultiNodeFullApiSelfTest.java |   99 +-
 ...ePartitionedMultiThreadedPutGetSelfTest.java |    6 +-
 ...edOffHeapTieredMultiNodeFullApiSelfTest.java |    2 +-
 ...ePartitionedOptimisticTxNodeRestartTest.java |    5 +
 ...achePartitionedPreloadLifecycleSelfTest.java |    2 +-
 ...CachePartitionedTxMultiThreadedSelfTest.java |    5 +
 .../GridCachePartitionedTxSalvageSelfTest.java  |   54 +-
 ...idCacheRendezvousAffinityClientSelfTest.java |    4 +
 .../near/IgniteCacheNearOnlyTxTest.java         |  190 +
 .../near/NoneRebalanceModeSelfTest.java         |   67 +
 .../GridCacheExReplicatedFullApiSelfTest.java   |   33 -
 .../GridCacheReplicatedClientOnlySelfTest.java  |   43 -
 .../GridCacheReplicatedFailoverSelfTest.java    |    6 +
 ...eReplicatedFullApiMultithreadedSelfTest.java |    5 +
 .../GridCacheReplicatedInvalidateSelfTest.java  |    4 +-
 .../GridCacheReplicatedLockSelfTest.java        |    5 +
 ...ridCacheReplicatedMultiNodeLockSelfTest.java |    5 +
 .../GridCacheReplicatedMultiNodeSelfTest.java   |    5 +
 .../GridCacheReplicatedNearOnlySelfTest.java    |   43 -
 .../GridCacheReplicatedNodeRestartSelfTest.java |   80 +
 .../GridCacheReplicatedTxExceptionSelfTest.java |    5 +
 .../GridCacheSyncReplicatedPreloadSelfTest.java |    1 -
 .../replicated/GridReplicatedTxPreloadTest.java |    2 +
 ...acheAtomicReplicatedNodeRestartSelfTest.java |   15 +
 ...CacheReplicatedPreloadLifecycleSelfTest.java |    6 +-
 .../cache/eviction/EvictionAbstractTest.java    | 1056 ++++
 .../GridCacheBatchEvictUnswapSelfTest.java      |    5 +-
 ...heConcurrentEvictionConsistencySelfTest.java |   97 +-
 .../GridCacheConcurrentEvictionsSelfTest.java   |   29 +-
 .../GridCacheDistributedEvictionsSelfTest.java  |    5 +-
 .../GridCacheEmptyEntriesAbstractSelfTest.java  |   11 +-
 .../eviction/GridCacheEvictionAbstractTest.java |  484 --
 .../GridCacheEvictionFilterSelfTest.java        |    2 +-
 .../GridCacheEvictionTouchSelfTest.java         |   22 +-
 .../cache/eviction/GridCacheMockEntry.java      |    5 +
 ...cheSynchronousEvictionsFailoverSelfTest.java |    5 +
 .../fifo/FifoEvictionPolicySelfTest.java        |  262 +
 ...ridCacheFifoBatchEvictionPolicySelfTest.java |  384 --
 .../GridCacheFifoEvictionPolicySelfTest.java    |  372 --
 .../lru/GridCacheLruEvictionPolicySelfTest.java |  417 --
 .../GridCacheLruNearEvictionPolicySelfTest.java |  136 -
 ...heNearOnlyLruNearEvictionPolicySelfTest.java |  171 -
 .../eviction/lru/LruEvictionPolicySelfTest.java |  353 ++
 .../lru/LruNearEvictionPolicySelfTest.java      |  140 +
 .../LruNearOnlyNearEvictionPolicySelfTest.java  |  172 +
 .../GridCacheRandomEvictionPolicySelfTest.java  |  258 -
 .../RandomEvictionPolicyCacheSizeSelfTest.java  |   78 +
 .../random/RandomEvictionPolicySelfTest.java    |  357 ++
 ...dCacheSortedBatchEvictionPolicySelfTest.java |  385 --
 ...acheSortedEvictionPolicyPerformanceTest.java |  135 -
 .../GridCacheSortedEvictionPolicySelfTest.java  |  373 --
 .../SortedEvictionPolicyPerformanceTest.java    |  134 +
 .../sorted/SortedEvictionPolicySelfTest.java    |  266 +
 .../IgniteCacheClientNearCacheExpiryTest.java   |  103 +
 .../IgniteCacheExpiryPolicyAbstractTest.java    |   10 +-
 .../IgniteCacheExpiryPolicyTestSuite.java       |    2 +
 ...eCacheExpiryPolicyWithStoreAbstractTest.java |    4 +-
 .../IgniteCacheTxStoreSessionTest.java          |    4 +
 ...CacheLocalOffHeapAndSwapMetricsSelfTest.java |  412 ++
 .../local/GridCacheExLocalFullApiSelfTest.java  |   30 -
 ...dCacheLocalFullApiMultithreadedSelfTest.java |    5 +
 .../GridCacheLocalIsolatedNodesSelfTest.java    |   18 +-
 .../GridCacheLocalTxExceptionSelfTest.java      |    5 +
 ...OnlyFairAffinityMultiJvmFullApiSelfTest.java |   31 +
 ...AtomicClientOnlyMultiJvmFullApiSelfTest.java |   31 +
 ...tOnlyMultiJvmP2PDisabledFullApiSelfTest.java |   31 +
 ...pyOnReadDisabledMultiJvmFullApiSelfTest.java |   31 +
 ...omicFairAffinityMultiJvmFullApiSelfTest.java |   31 +
 .../GridCacheAtomicMultiJvmFullApiSelfTest.java |   30 +
 ...tomicMultiJvmP2PDisabledFullApiSelfTest.java |   31 +
 ...bledFairAffinityMultiJvmFullApiSelfTest.java |   31 +
 ...tomicNearEnabledMultiJvmFullApiSelfTest.java |   31 +
 ...rimaryWriteOrderMultiJvmFullApiSelfTest.java |   31 +
 ...heAtomicNearOnlyMultiJvmFullApiSelfTest.java |   31 +
 ...rOnlyMultiJvmP2PDisabledFullApiSelfTest.java |   31 +
 ...cheAtomicOffHeapMultiJvmFullApiSelfTest.java |   31 +
 ...micOffHeapTieredMultiJvmFullApiSelfTest.java |   36 +
 ...rderFairAffinityMultiJvmFullApiSelfTest.java |   31 +
 ...rimaryWriteOrderMultiJvmFullApiSelfTest.java |   31 +
 ...OrderMultiJvmP2PDisabledFullApiSelfTest.java |   31 +
 ...rityOrderOffHeapMultiJvmFullApiSelfTest.java |   31 +
 ...derOffHeapTieredMultiJvmFullApiSelfTest.java |   36 +
 ...OnlyFairAffinityMultiJvmFullApiSelfTest.java |   31 +
 ...ridCacheNearOnlyMultiJvmFullApiSelfTest.java |   30 +
 ...rOnlyMultiJvmP2PDisabledFullApiSelfTest.java |   31 +
 ...pyOnReadDisabledMultiJvmFullApiSelfTest.java |   31 +
 ...onedFairAffinityMultiJvmFullApiSelfTest.java |   31 +
 ...CachePartitionedMultiJvmFullApiSelfTest.java |   30 +
 ...ionedMultiJvmP2PDisabledFullApiSelfTest.java |   31 +
 ...micOffHeapTieredMultiJvmFullApiSelfTest.java |   36 +
 ...bledFairAffinityMultiJvmFullApiSelfTest.java |   31 +
 ...onedNearDisabledMultiJvmFullApiSelfTest.java |   31 +
 ...abledMultiJvmP2PDisabledFullApiSelfTest.java |   31 +
 ...rDisabledOffHeapMultiJvmFullApiSelfTest.java |   31 +
 ...ledOffHeapTieredMultiJvmFullApiSelfTest.java |   36 +
 ...rtitionedOffHeapMultiJvmFullApiSelfTest.java |   31 +
 ...nedOffHeapTieredMultiJvmFullApiSelfTest.java |   36 +
 ...ReplicatedAtomicMultiJvmFullApiSelfTest.java |   31 +
 ...rimaryWriteOrderMultiJvmFullApiSelfTest.java |   31 +
 ...dCacheReplicatedMultiJvmFullApiSelfTest.java |   30 +
 ...catedMultiJvmP2PDisabledFullApiSelfTest.java |   31 +
 ...plicatedNearOnlyMultiJvmFullApiSelfTest.java |   37 +
 ...eplicatedOffHeapMultiJvmFullApiSelfTest.java |   31 +
 ...tedOffHeapTieredMultiJvmFullApiSelfTest.java |   36 +
 .../GridCacheSwapScanQueryAbstractSelfTest.java |  115 +-
 ...ridCacheContinuousQueryAbstractSelfTest.java |    8 +-
 ...CacheClientWriteBehindStoreAbstractTest.java |  104 +
 ...teCacheClientWriteBehindStoreAtomicTest.java |   38 +
 .../IgnteCacheClientWriteBehindStoreTxTest.java |   32 +
 .../closure/GridClosureProcessorSelfTest.java   |   29 +-
 .../continuous/GridEventConsumeSelfTest.java    |   98 +-
 .../DataStreamProcessorSelfTest.java            |   48 +-
 .../DataStreamerMultiThreadedSelfTest.java      |   62 +-
 .../DataStreamerMultinodeCreateCacheTest.java   |   99 +
 .../igfs/IgfsClientCacheSelfTest.java           |   12 +-
 .../processors/igfs/IgfsCommonAbstractTest.java |   10 -
 .../processors/igfs/IgfsModesSelfTest.java      |    4 +-
 .../processors/igfs/IgfsOneClientNodeTest.java  |    8 +-
 .../service/ClosureServiceClientsNodesTest.java |  251 +
 .../service/GridServiceClientNodeTest.java      |   81 +
 .../internal/util/IgniteUtilsSelfTest.java      |   22 +
 .../ipc/shmem/IgfsSharedMemoryTestServer.java   |    2 +
 .../IpcSharedMemoryCrashDetectionSelfTest.java  |    2 +-
 .../ipc/shmem/IpcSharedMemorySpaceSelfTest.java |    2 +-
 .../ipc/shmem/IpcSharedMemoryUtilsSelfTest.java |    2 +-
 .../LoadWithCorruptedLibFileTestRunner.java     |    2 +-
 .../IpcSharedMemoryBenchmarkReader.java         |    2 +-
 .../IpcSharedMemoryBenchmarkWriter.java         |    2 +-
 .../nio/GridNioDelimitedBufferSelfTest.java     |  112 +
 .../internal/util/nio/GridNioSelfTest.java      |   15 +-
 .../internal/util/nio/GridNioSslSelfTest.java   |    2 +
 .../unsafe/GridUnsafeMemorySelfTest.java        |    4 +-
 .../tostring/GridToStringBuilderSelfTest.java   |    4 +-
 .../loadtests/GridCacheMultiNodeLoadTest.java   |    5 +-
 .../communication/GridIoManagerBenchmark0.java  |    1 +
 .../GridCachePartitionedAtomicLongLoadTest.java |    6 +-
 .../loadtests/hashmap/GridCacheTestContext.java |    6 +-
 .../swap/GridSwapEvictAllBenchmark.java         |    6 +-
 .../marshaller/MarshallerContextTestImpl.java   |   29 +-
 .../OptimizedMarshallerNodeFailoverTest.java    |    4 +-
 ...GridMessagingNoPeerClassLoadingSelfTest.java |    7 +-
 .../ignite/messaging/GridMessagingSelfTest.java |   16 +-
 .../IgniteMessagingWithClientTest.java          |  166 +
 .../p2p/GridP2PLocalDeploymentSelfTest.java     |    6 +-
 .../p2p/GridP2PRemoteClassLoadersSelfTest.java  |   31 +-
 .../spi/GridTcpSpiForwardingSelfTest.java       |    4 +-
 .../GridTcpCommunicationSpiAbstractTest.java    |   17 +-
 ...mmunicationSpiConcurrentConnectSelfTest.java |    6 +-
 .../GridTcpCommunicationSpiConfigSelfTest.java  |    3 -
 ...cpCommunicationSpiMultithreadedSelfTest.java |   23 +-
 ...pCommunicationSpiMultithreadedShmemTest.java |   28 +
 ...dTcpCommunicationSpiRecoveryAckSelfTest.java |    1 +
 ...GridTcpCommunicationSpiRecoverySelfTest.java |    1 +
 .../GridTcpCommunicationSpiShmemSelfTest.java   |   38 +
 .../tcp/GridTcpCommunicationSpiTcpSelfTest.java |    7 +
 .../discovery/AbstractDiscoverySelfTest.java    |   21 +-
 ...pClientDiscoveryMarshallerCheckSelfTest.java |   76 +
 .../tcp/TcpClientDiscoverySelfTest.java         |  700 ---
 .../tcp/TcpClientDiscoverySpiMulticastTest.java |  129 +
 .../tcp/TcpClientDiscoverySpiSelfTest.java      | 1632 +++++
 .../tcp/TcpDiscoveryConcurrentStartTest.java    |   61 +-
 .../tcp/TcpDiscoveryMultiThreadedTest.java      |   56 +-
 .../TcpDiscoveryNodeConsistentIdSelfTest.java   |   80 +
 .../discovery/tcp/TcpDiscoveryRestartTest.java  |  199 +
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java |   46 +-
 .../inmemory/GridTestSwapSpaceSpi.java          |    3 +-
 .../GridCommandLineTransformerSelfTest.java     |   12 +-
 .../stream/socket/SocketStreamerSelfTest.java   |  310 +
 .../ignite/stream/socket/package-info.java      |   21 +
 .../testframework/GridSpiTestContext.java       |   42 +-
 .../ignite/testframework/GridTestUtils.java     |   31 +-
 .../config/GridTestProperties.java              |   14 +-
 .../testframework/junits/GridAbstractTest.java  |  410 +-
 .../junits/GridTestKernalContext.java           |    3 +-
 .../junits/IgniteTestResources.java             |   16 +-
 .../junits/cache/TestCacheSession.java          |   18 +
 .../cache/TestThreadLocalCacheSession.java      |   15 +
 .../junits/common/GridCommonAbstractTest.java   |  148 +-
 .../junits/multijvm/AffinityProcessProxy.java   |  195 +
 .../multijvm/IgniteCacheProcessProxy.java       |  602 ++
 .../multijvm/IgniteClusterProcessProxy.java     |  320 +
 .../multijvm/IgniteEventsProcessProxy.java      |  148 +
 .../junits/multijvm/IgniteNodeRunner.java       |  184 +
 .../junits/multijvm/IgniteProcessProxy.java     |  571 ++
 .../ignite/testsuites/IgniteBasicTestSuite.java |   37 +-
 .../IgniteCacheDataStructuresSelfTestSuite.java |   28 +-
 .../IgniteCacheEvictionSelfTestSuite.java       |   18 +-
 .../IgniteCacheFailoverTestSuite.java           |   29 +-
 .../IgniteCacheFailoverTestSuite2.java          |   47 +
 ...IgniteCacheFullApiMultiJvmSelfTestSuite.java |   89 +
 .../IgniteCacheFullApiSelfTestSuite.java        |   14 +-
 .../IgniteCacheMetricsSelfTestSuite.java        |    1 +
 .../IgniteCacheNearOnlySelfTestSuite.java       |   16 +-
 ...gniteCacheP2pUnmarshallingErrorTestSuit.java |   41 -
 ...niteCacheP2pUnmarshallingErrorTestSuite.java |   53 +
 .../testsuites/IgniteCacheRestartTestSuite.java |   10 +-
 .../IgniteCacheTcpClientDiscoveryTestSuite.java |   47 +
 .../ignite/testsuites/IgniteCacheTestSuite.java |   56 +-
 .../testsuites/IgniteCacheTestSuite2.java       |   18 +-
 .../testsuites/IgniteCacheTestSuite3.java       |   16 +-
 .../testsuites/IgniteCacheTestSuite4.java       |   41 +-
 .../IgniteCacheWriteBehindTestSuite.java        |    2 +
 .../testsuites/IgniteClientTestSuite.java       |   38 +
 .../testsuites/IgniteComputeGridTestSuite.java  |    1 +
 .../testsuites/IgniteKernalSelfTestSuite.java   |   24 +-
 .../IgniteMarshallerSelfTestSuite.java          |   28 +-
 .../IgniteSpiCommunicationSelfTestSuite.java    |    2 +
 .../IgniteSpiDiscoverySelfTestSuite.java        |    9 +-
 .../testsuites/IgniteStreamSelfTestSuite.java   |   39 +
 .../testsuites/IgniteUtilSelfTestSuite.java     |   19 +-
 .../apache/ignite/util/GridRandomSelfTest.java  |    4 +-
 .../ignite/util/TestTcpCommunicationSpi.java    |   21 +
 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/docker/Dockerfile                       |   55 +
 modules/docker/README.txt                       |   11 +
 modules/docker/build_users_libs.sh              |   39 +
 modules/docker/download_ignite.sh               |   49 +
 modules/docker/execute.sh                       |   62 +
 modules/docker/run.sh                           |   34 +
 modules/extdata/p2p/pom.xml                     |    4 +-
 .../p2p/GridP2PContinuousDeploymentTask1.java   |    2 +-
 .../tests/p2p/P2PTestTaskExternalPath1.java     |   10 +-
 .../tests/p2p/P2PTestTaskExternalPath2.java     |    8 +-
 .../CacheConfigurationP2PTestClient.java        |    4 +-
 modules/extdata/uri/META-INF/ignite.xml         |   38 +
 .../extdata/uri/modules/uri-dependency/pom.xml  |   40 +
 .../deployment/uri/tasks/GarHelloWorldBean.java |   60 +
 .../src/main/resources/gar-example.properties   |   18 +
 modules/extdata/uri/pom.xml                     |   50 +-
 .../deployment/uri/tasks/GarHelloWorldTask.java |   81 +
 .../deployment/uri/tasks/gar-spring-bean.xml    |   29 +
 modules/gce/pom.xml                             |    2 +-
 .../gce/TcpDiscoveryGoogleStorageIpFinder.java  |   43 +-
 modules/geospatial/pom.xml                      |    2 +-
 .../query/h2/GridH2IndexingGeoSelfTest.java     |   20 +-
 modules/hadoop/pom.xml                          |   81 +-
 .../fs/IgniteHadoopFileSystemCounterWriter.java |   21 +-
 .../fs/IgniteHadoopIgfsSecondaryFileSystem.java |  165 +-
 .../hadoop/fs/v1/IgniteHadoopFileSystem.java    |  137 +-
 .../hadoop/fs/v2/IgniteHadoopFileSystem.java    |   32 +-
 .../processors/hadoop/HadoopClassLoader.java    |   29 +
 .../processors/hadoop/HadoopDefaultJobInfo.java |   27 +-
 .../internal/processors/hadoop/HadoopUtils.java |   51 +-
 .../hadoop/SecondaryFileSystemProvider.java     |   58 +-
 .../hadoop/fs/HadoopDistributedFileSystem.java  |   91 -
 .../hadoop/fs/HadoopFileSystemCacheUtils.java   |  241 +
 .../hadoop/fs/HadoopFileSystemsUtils.java       |   26 +-
 .../hadoop/fs/HadoopLazyConcurrentMap.java      |  209 +
 .../processors/hadoop/igfs/HadoopIgfsEx.java    |    6 +
 .../hadoop/igfs/HadoopIgfsInProc.java           |  170 +-
 .../processors/hadoop/igfs/HadoopIgfsIpcIo.java |    2 +-
 .../hadoop/igfs/HadoopIgfsOutProc.java          |   33 +-
 .../hadoop/igfs/HadoopIgfsWrapper.java          |   19 +-
 .../hadoop/jobtracker/HadoopJobTracker.java     |   25 +-
 .../hadoop/taskexecutor/HadoopRunnableTask.java |   20 +-
 .../child/HadoopChildProcessRunner.java         |    3 +-
 .../processors/hadoop/v2/HadoopV2Context.java   |   10 +-
 .../processors/hadoop/v2/HadoopV2Job.java       |  111 +-
 .../hadoop/v2/HadoopV2JobResourceManager.java   |   40 +-
 .../hadoop/v2/HadoopV2TaskContext.java          |   85 +-
 .../hadoop/HadoopClientProtocolSelfTest.java    |    6 +-
 .../HadoopIgfs20FileSystemAbstractSelfTest.java |   73 +-
 ...oopSecondaryFileSystemConfigurationTest.java |   18 +-
 .../apache/ignite/igfs/IgfsEventsTestSuite.java |    5 +-
 .../igfs/IgfsNearOnlyMultiNodeSelfTest.java     |    5 +-
 .../IgniteHadoopFileSystemAbstractSelfTest.java |   65 +-
 .../IgniteHadoopFileSystemClientSelfTest.java   |    2 +-
 ...IgniteHadoopFileSystemHandshakeSelfTest.java |    7 +
 .../IgniteHadoopFileSystemIpcCacheSelfTest.java |    9 +
 .../hadoop/HadoopAbstractSelfTest.java          |   19 +-
 .../hadoop/HadoopCommandLineTest.java           |   14 +-
 .../hadoop/HadoopFileSystemsTest.java           |   23 +-
 .../processors/hadoop/HadoopMapReduceTest.java  |  185 +-
 .../hadoop/HadoopTaskExecutionSelfTest.java     |    2 +-
 .../hadoop/HadoopTasksAllVersionsTest.java      |   15 +-
 .../processors/hadoop/HadoopTasksV1Test.java    |    8 +-
 .../processors/hadoop/HadoopTasksV2Test.java    |    8 +-
 .../processors/hadoop/HadoopV2JobSelfTest.java  |    8 +-
 .../collections/HadoopAbstractMapTest.java      |   15 +-
 .../collections/HadoopHashMapSelfTest.java      |    4 +-
 .../collections/HadoopSkipListSelfTest.java     |    4 +-
 .../HadoopExternalTaskExecutionSelfTest.java    |    2 +
 .../HadoopExternalCommunicationSelfTest.java    |    5 +
 .../testsuites/IgniteHadoopTestSuite.java       |   11 +-
 .../IgniteIgfsLinuxAndMacOSTestSuite.java       |    3 +-
 modules/hibernate/pom.xml                       |   16 +-
 .../HibernateTransactionalDataRegion.java       |   12 +-
 .../hibernate/CacheHibernateBlobStore.java      |   87 +-
 .../CacheHibernateBlobStoreFactory.java         |  235 +
 .../CacheHibernateStoreSessionListener.java     |  216 +
 .../hibernate/src/test/config/factory-cache.xml |   59 +
 .../src/test/config/factory-cache1.xml          |   61 +
 .../config/factory-incorrect-store-cache.xml    |   56 +
 .../hibernate/HibernateL2CacheSelfTest.java     |    2 +
 .../CacheHibernateStoreFactorySelfTest.java     |  273 +
 ...heHibernateStoreSessionListenerSelfTest.java |  228 +
 .../testsuites/IgniteHibernateTestSuite.java    |    8 +-
 modules/indexing/pom.xml                        |   18 +-
 .../processors/query/h2/IgniteH2Indexing.java   |  142 +-
 .../query/h2/opt/GridH2AbstractKeyValueRow.java |   18 +-
 .../query/h2/opt/GridH2KeyValueRowOffheap.java  |   12 +-
 .../processors/query/h2/opt/GridH2Table.java    |    2 +-
 .../query/h2/sql/GridSqlOperationType.java      |    2 +-
 .../query/h2/sql/GridSqlQuerySplitter.java      |   53 +-
 .../query/h2/twostep/GridMapQueryExecutor.java  |  321 +-
 .../query/h2/twostep/GridMergeIndex.java        |   17 +-
 .../h2/twostep/GridMergeIndexUnsorted.java      |    7 +-
 .../h2/twostep/GridReduceQueryExecutor.java     |  656 +-
 .../query/h2/twostep/GridResultPage.java        |   21 +-
 .../CacheAbstractQueryMetricsSelfTest.java      |  358 ++
 .../cache/CacheLocalQueryMetricsSelfTest.java   |   33 +
 ...titionedQueryMetricsDistributedSelfTest.java |   33 +
 ...chePartitionedQueryMetricsLocalSelfTest.java |   33 +
 ...plicatedQueryMetricsDistributedSelfTest.java |   33 +
 ...acheReplicatedQueryMetricsLocalSelfTest.java |   33 +
 ...CacheScanPartitionQueryFallbackSelfTest.java |  408 ++
 .../cache/GridCacheCrossCacheQuerySelfTest.java |   25 +-
 .../cache/GridCacheOffHeapSelfTest.java         |    1 -
 .../GridCacheOffheapIndexEntryEvictTest.java    |  200 +
 .../cache/GridCacheOffheapIndexGetSelfTest.java |  183 +
 .../cache/GridCacheQueryMetricsSelfTest.java    |  152 -
 ...idCacheReduceQueryMultithreadedSelfTest.java |   10 -
 .../processors/cache/GridCacheSwapSelfTest.java |    3 -
 .../cache/GridIndexingWithNoopSwapSelfTest.java |    6 +-
 .../IgniteCacheAbstractFieldsQuerySelfTest.java |   13 +-
 .../cache/IgniteCacheAbstractQuerySelfTest.java |   85 +-
 ...acheConfigurationPrimitiveTypesSelfTest.java |  104 +
 .../cache/IgniteCacheOffheapEvictQueryTest.java |  196 +
 ...niteCacheP2pUnmarshallingQueryErrorTest.java |    3 +-
 ...hePartitionedQueryMultiThreadedSelfTest.java |   40 +-
 ...QueryMultiThreadedOffHeapTieredSelfTest.java |   37 +
 ...eQueryMultiThreadedOffHeapTiredSelfTest.java |   37 -
 .../IgniteCacheQueryMultiThreadedSelfTest.java  |   19 +-
 ...lientQueryReplicatedNodeRestartSelfTest.java |  419 ++
 .../IgniteCacheQueryNodeRestartSelfTest.java    |   41 +-
 .../IgniteCacheQueryNodeRestartSelfTest2.java   |  388 ++
 .../local/IgniteCacheLocalQuerySelfTest.java    |    6 +
 ...dCacheAbstractReduceFieldsQuerySelfTest.java |    1 -
 .../cache/ttl/CacheTtlAbstractSelfTest.java     |    6 +-
 .../h2/GridIndexingSpiAbstractSelfTest.java     |    4 +-
 .../query/h2/sql/BaseH2CompareQueryTest.java    |   22 +-
 .../query/h2/sql/GridQueryParsingTest.java      |    5 +-
 .../IgniteCacheQuerySelfTestSuite.java          |   16 +-
 .../IgniteCacheWithIndexingTestSuite.java       |    5 +
 modules/jcl/pom.xml                             |    2 +-
 modules/jta/pom.xml                             |    2 +-
 .../apache/ignite/cache/jta/CacheTmLookup.java  |    3 +-
 .../processors/cache/jta/CacheJtaManager.java   |   76 +-
 .../cache/jta/GridCacheXAResource.java          |   34 +-
 .../processors/cache/GridCacheJtaSelfTest.java  |   52 +-
 .../GridTmLookupLifecycleAwareSelfTest.java     |   29 +-
 modules/kafka/licenses/apache-2.0.txt           |  202 +
 modules/kafka/pom.xml                           |  105 +
 .../ignite/stream/kafka/KafkaStreamer.java      |  220 +
 .../kafka/IgniteKafkaStreamerSelfTestSuite.java |   37 +
 .../stream/kafka/KafkaEmbeddedBroker.java       |  378 ++
 .../kafka/KafkaIgniteStreamerSelfTest.java      |  227 +
 .../ignite/stream/kafka/SimplePartitioner.java  |   53 +
 modules/log4j/pom.xml                           |    2 +-
 modules/mesos/README.txt                        |   28 +
 modules/mesos/licenses/apache-2.0.txt           |  202 +
 modules/mesos/licenses/jetty-epl-license.txt    |   69 +
 modules/mesos/pom.xml                           |  100 +
 .../apache/ignite/mesos/ClusterProperties.java  |  534 ++
 .../apache/ignite/mesos/IgniteFramework.java    |  119 +
 .../apache/ignite/mesos/IgniteScheduler.java    |  365 ++
 .../org/apache/ignite/mesos/IgniteTask.java     |   86 +
 .../org/apache/ignite/mesos/package-info.java   |   22 +
 .../ignite/mesos/resource/IgniteProvider.java   |  234 +
 .../ignite/mesos/resource/JettyServer.java      |   61 +
 .../ignite/mesos/resource/ResourceHandler.java  |  142 +
 .../ignite/mesos/resource/ResourceProvider.java |  120 +
 .../ignite/mesos/resource/package-info.java     |   22 +
 .../main/resources/ignite-default-config.xml    |   35 +
 .../org/apache/ignite/IgniteMesosTestSuite.java |   38 +
 .../ignite/mesos/IgniteSchedulerSelfTest.java   |  464 ++
 modules/rest-http/pom.xml                       |   16 +-
 modules/scalar-2.10/README.txt                  |    4 +
 modules/scalar-2.10/licenses/apache-2.0.txt     |  202 +
 .../scalar-2.10/licenses/scala-bsd-license.txt  |   18 +
 modules/scalar-2.10/pom.xml                     |  197 +
 modules/scalar/pom.xml                          |    2 +-
 .../scalar/tests/ScalarCacheQueriesSpec.scala   |  154 +-
 .../ignite/scalar/tests/ScalarCacheSpec.scala   |   23 +-
 .../scalar/tests/ScalarConversionsSpec.scala    |   43 +-
 .../scalar/tests/ScalarProjectionSpec.scala     |  128 +-
 .../scalar/tests/ScalarReturnableSpec.scala     |   41 +-
 modules/schedule/pom.xml                        |    2 +-
 modules/schema-import/pom.xml                   |    2 +-
 .../ignite/schema/model/PojoDescriptor.java     |    2 +
 .../apache/ignite/schema/model/PojoField.java   |    1 +
 .../parser/dialect/OracleMetadataDialect.java   |    2 +-
 modules/slf4j/pom.xml                           |    2 +-
 modules/spark-2.10/README.txt                   |    4 +
 modules/spark-2.10/licenses/apache-2.0.txt      |  202 +
 .../spark-2.10/licenses/scala-bsd-license.txt   |   18 +
 modules/spark-2.10/pom.xml                      |  120 +
 modules/spark/README.txt                        |    8 +
 modules/spark/licenses/apache-2.0.txt           |  202 +
 modules/spark/licenses/scala-bsd-license.txt    |   18 +
 modules/spark/pom.xml                           |  110 +
 .../org/apache/ignite/spark/IgniteContext.scala |  161 +
 .../org/apache/ignite/spark/IgniteRDD.scala     |  244 +
 .../apache/ignite/spark/JavaIgniteContext.scala |   63 +
 .../org/apache/ignite/spark/JavaIgniteRDD.scala |   99 +
 .../ignite/spark/impl/IgniteAbstractRDD.scala   |   39 +
 .../ignite/spark/impl/IgnitePartition.scala     |   24 +
 .../ignite/spark/impl/IgniteQueryIterator.scala |   27 +
 .../apache/ignite/spark/impl/IgniteSqlRDD.scala |   41 +
 .../spark/impl/JavaIgniteAbstractRDD.scala      |   34 +
 .../ignite/spark/JavaIgniteRDDSelfTest.java     |  298 +
 .../scala/org/apache/ignite/spark/Entity.scala  |   28 +
 .../org/apache/ignite/spark/IgniteRddSpec.scala |  249 +
 modules/spring/pom.xml                          |   23 +-
 .../spring/CacheSpringStoreSessionListener.java |  207 +
 .../GridResourceSpringBeanInjector.java         |    2 +-
 .../util/spring/IgniteSpringHelperImpl.java     |   89 +-
 .../src/test/config/incorrect-store-cache.xml   |   57 +
 modules/spring/src/test/config/node.xml         |   43 +
 modules/spring/src/test/config/node1.xml        |   45 +
 .../test/config/pojo-incorrect-store-cache.xml  |   56 +
 modules/spring/src/test/config/store-cache.xml  |   59 +
 modules/spring/src/test/config/store-cache1.xml |   62 +
 .../jdbc/CacheJdbcBlobStoreFactorySelfTest.java |  172 +
 .../jdbc/CacheJdbcPojoStoreFactorySelfTest.java |  193 +
 ...CacheSpringStoreSessionListenerSelfTest.java |  197 +
 .../IgniteExcludeInConfigurationTest.java       |   81 +
 .../org/apache/ignite/spring/sprint-exclude.xml |   76 +
 .../testsuites/IgniteSpringTestSuite.java       |   10 +
 modules/ssh/pom.xml                             |    2 +-
 modules/tools/pom.xml                           |    2 +-
 .../ignite/tools/classgen/ClassesGenerator.java |   30 +-
 modules/urideploy/pom.xml                       |   10 +-
 .../GridTaskUriDeploymentDeadlockSelfTest.java  |   13 +-
 .../ignite/p2p/GridP2PDisabledSelfTest.java     |    2 +-
 modules/visor-console-2.10/README.txt           |    4 +
 modules/visor-console-2.10/pom.xml              |  174 +
 .../licenses/jcraft-revised-bsd.txt             |   28 -
 modules/visor-console/pom.xml                   |    4 +-
 .../ignite/visor/commands/VisorConsole.scala    |    3 +-
 .../commands/cache/VisorCacheCommand.scala      |    9 +-
 .../commands/cache/VisorCacheScanCommand.scala  |    2 +-
 .../visor/commands/node/VisorNodeCommand.scala  |    2 +-
 .../visor/commands/open/VisorOpenCommand.scala  |  319 +
 .../commands/tasks/VisorTasksCommand.scala      |    2 +-
 .../scala/org/apache/ignite/visor/visor.scala   |  291 +-
 .../ignite/visor/VisorRuntimeBaseSpec.scala     |    4 +-
 .../visor/commands/VisorArgListSpec.scala       |   60 +-
 .../commands/VisorFileNameCompleterSpec.scala   |   34 +-
 .../commands/ack/VisorAckCommandSpec.scala      |   20 +-
 .../commands/alert/VisorAlertCommandSpec.scala  |   68 +-
 .../cache/VisorCacheClearCommandSpec.scala      |   48 +-
 .../commands/cache/VisorCacheCommandSpec.scala  |   66 +-
 .../config/VisorConfigurationCommandSpec.scala  |    8 +-
 .../cswap/VisorCacheSwapCommandSpec.scala       |   24 +-
 .../deploy/VisorDeployCommandSpec.scala         |   10 +-
 .../disco/VisorDiscoveryCommandSpec.scala       |   46 +-
 .../events/VisorEventsCommandSpec.scala         |   28 +-
 .../visor/commands/gc/VisorGcCommandSpec.scala  |   30 +-
 .../commands/help/VisorHelpCommandSpec.scala    |   57 +-
 .../commands/kill/VisorKillCommandSpec.scala    |   59 +-
 .../commands/log/VisorLogCommandSpec.scala      |   10 +-
 .../commands/mem/VisorMemoryCommandSpec.scala   |   77 +-
 .../commands/node/VisorNodeCommandSpec.scala    |   22 +-
 .../commands/open/VisorOpenCommandSpec.scala    |   16 +-
 .../commands/ping/VisorPingCommandSpec.scala    |   16 +-
 .../commands/start/VisorStartCommandSpec.scala  |  127 +-
 .../commands/tasks/VisorTasksCommandSpec.scala  |  113 +-
 .../commands/top/VisorTopologyCommandSpec.scala |   52 +-
 .../commands/vvm/VisorVvmCommandSpec.scala      |   31 +-
 modules/visor-plugins/pom.xml                   |    2 +-
 modules/web/pom.xml                             |    8 +-
 .../IgniteWebSessionSelfTestSuite.java          |    2 +-
 .../config/benchmark-client-mode.properties     |   89 +
 .../config/benchmark-put-indexed-val.properties |   64 +
 modules/yardstick/config/ignite-base-config.xml |   23 +
 modules/yardstick/pom.xml                       |    2 +-
 .../cache/IgnitePutIndexedValue1Benchmark.java  |   42 +
 .../cache/IgnitePutIndexedValue2Benchmark.java  |   42 +
 .../cache/IgnitePutIndexedValue8Benchmark.java  |   42 +
 .../ignite/yardstick/cache/model/Person1.java   |   55 +
 .../ignite/yardstick/cache/model/Person2.java   |   67 +
 .../ignite/yardstick/cache/model/Person8.java   |  109 +
 parent/pom.xml                                  |   55 +-
 pom.xml                                         |  127 +-
 scripts/git-apply-patch.sh                      |    8 +-
 scripts/git-format-patch.sh                     |   16 +-
 scripts/git-patch-functions.sh                  |   36 +-
 scripts/git-patch-prop.sh                       |    2 +-
 1120 files changed, 70813 insertions(+), 25662 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0839e8d3/pom.xml
----------------------------------------------------------------------


[11/24] incubator-ignite git commit: # ignite-788: tests

Posted by sb...@apache.org.
# ignite-788: tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f524d3fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f524d3fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f524d3fd

Branch: refs/heads/ignite-788-last-review
Commit: f524d3fdac80d9631f10869b05620ad3eb9f8571
Parents: 86b47a0
Author: ashutak <as...@gridgain.com>
Authored: Wed Jul 15 20:53:55 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Jul 15 20:53:55 2015 +0300

----------------------------------------------------------------------
 config/ignite-log4j2.xml                        | 32 ++++++-
 modules/core/src/test/config/log4j2-test.xml    | 56 ++++++++++++
 .../log4j2/GridLog4j2CorrectFileNameTest.java   | 81 ++++-------------
 .../log4j2/GridLog4j2InitializedTest.java       | 15 +---
 .../log4j2/GridLog4j2InitiallizationTest.java   | 94 ++++++++++++++++++++
 .../log4j2/GridLog4j2LoggingFileTest.java       | 59 ------------
 .../log4j2/GridLog4j2LoggingPathTest.java       | 52 -----------
 .../logger/log4j2/GridLog4j2LoggingUrlTest.java | 59 ------------
 .../log4j2/GridLog4j2NotInitializedTest.java    |  2 +-
 .../testsuites/IgniteLog4j2TestSuite.java       |  6 ++
 10 files changed, 207 insertions(+), 249 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f524d3fd/config/ignite-log4j2.xml
----------------------------------------------------------------------
diff --git a/config/ignite-log4j2.xml b/config/ignite-log4j2.xml
index b24c57b..c1393aa 100644
--- a/config/ignite-log4j2.xml
+++ b/config/ignite-log4j2.xml
@@ -17,8 +17,12 @@
   limitations under the License.
 -->
 
-<Configuration status="info">
+<Configuration>
     <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+        </Console>
+
         <Console name="CONSOLE_ERR" target="SYSTEM_ERR">
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
         </Console>
@@ -53,15 +57,37 @@
     </Appenders>
 
     <Loggers>
+        <!--
+        <Logger name="org.apache.ignite" level=DEBUG/>
+        -->
+
+        <!--
+            Uncomment to disable courtesy notices, such as SPI configuration
+            consistency warnings.
+        -->
+        <!--
+        <Logger name="org.apache.ignite.CourtesyConfigNotice" level=OFF/>
+        -->
+
         <Logger name="org.springframework" level="WARN"/>
         <Logger name="org.eclipse.jetty" level="WARN"/>
+
+        <!--
+        Avoid warnings about failed bind attempt when multiple nodes running on the same host.
+        -->
         <Logger name="org.eclipse.jetty.util.log" level="ERROR"/>
         <Logger name="org.eclipse.jetty.util.component" level="ERROR"/>
+
         <Logger name="com.amazonaws" level="WARN"/>
 
         <Root level="INFO">
-            <AppenderRef ref="CONSOLE_ERR"/>
-            <AppenderRef ref="Routing"/>
+            <!-- Uncomment to enable logging to console. -->
+            <!--
+            <AppenderRef ref="CONSOLE" level="DEBUG"/>
+            -->
+
+            <AppenderRef ref="CONSOLE_ERR" level="ERROR"/>
+            <AppenderRef ref="Routing" level="DEBUG"/>
         </Root>
     </Loggers>
 </Configuration>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f524d3fd/modules/core/src/test/config/log4j2-test.xml
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/log4j2-test.xml b/modules/core/src/test/config/log4j2-test.xml
new file mode 100644
index 0000000..b95709b
--- /dev/null
+++ b/modules/core/src/test/config/log4j2-test.xml
@@ -0,0 +1,56 @@
+<?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.
+-->
+
+<Configuration status="info">
+    <Appenders>
+        <Console name="CONSOLE" target="SYSTEM_OUT">
+            <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+        </Console>
+
+        <Console name="CONSOLE_ERR" target="SYSTEM_ERR">
+            <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+        </Console>
+
+        <Routing name="FILE">
+            <Routes pattern="$${ctx:nodeId}">
+                <Route>
+                    <RollingFile name="Rolling-${ctx:nodeId}" fileName="work/log/ignite-${ctx:nodeId}.log"
+                                 filePattern="work/log/ignite-${ctx:nodeId}-%i-%d{yyyy-MM-dd}.log.gz">
+                        <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+                        <Policies>
+                            <TimeBasedTriggeringPolicy interval="6" modulate="true" />
+                            <SizeBasedTriggeringPolicy size="10 MB" />
+                        </Policies>
+                    </RollingFile>
+                </Route>
+            </Routes>
+        </Routing>
+    </Appenders>
+
+    <Loggers>
+        <Logger name="org" level="INFO"/>
+        <Logger name="org.eclipse.jetty" level="INFO"/>
+
+        <Root level="INFO">
+            <AppenderRef ref="CONSOLE" level="DEBUG"/>
+            <AppenderRef ref="CONSOLE_ERR" level="WARN"/>
+            <AppenderRef ref="FILE" level="DEBUG"/>
+        </Root>
+    </Loggers>
+</Configuration>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f524d3fd/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
index 4699ab8..7a968d4 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.ignite.logger.log4j2;
 
 import junit.framework.*;
@@ -25,39 +24,12 @@ import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.testframework.junits.common.*;
 
 import java.io.*;
-import java.util.*;
 
 /**
  * Tests that several grids log to files with correct names.
  */
 @GridCommonTest(group = "Logger")
 public class GridLog4j2CorrectFileNameTest extends TestCase {
-    /** Appender */
-    private Log4jRollingFileAppender appender;
-
-    /** {@inheritDoc} */
-    @Override protected void setUp() throws Exception {
-        Logger root = Logger.getRootLogger();
-
-        for (Enumeration appenders = root.getAllAppenders(); appenders.hasMoreElements(); ) {
-            if (appenders.nextElement() instanceof Log4jRollingFileAppender)
-                return;
-        }
-
-        appender = createAppender();
-
-        root.addAppender(appender);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void tearDown() {
-        if (appender != null) {
-            Logger.getRootLogger().removeAppender(Log4jRollingFileAppender.class.getSimpleName());
-
-            Log4JLogger.removeAppender(appender);
-        }
-    }
-
     /**
      * Tests correct behaviour in case 2 local nodes are started.
      *
@@ -76,19 +48,24 @@ public class GridLog4j2CorrectFileNameTest extends TestCase {
      * @throws Exception If error occurred.
      */
     private void checkOneNode(int id) throws Exception {
+        String id8 = null;
+        
         try (Ignite ignite = G.start(getConfiguration("grid" + id))) {
-            String id8 = U.id8(ignite.cluster().localNode().id());
-            String logPath = "work/log/ignite-" + id8 + ".log";
-            File logFile = U.resolveIgnitePath(logPath);
+            id8 = U.id8(ignite.cluster().localNode().id());
+        }
 
-            assertNotNull("Failed to resolve path: " + logPath, logFile);
-            assertTrue("Log file does not exist: " + logFile, logFile.exists());
+        String logPath = "work/log/ignite-" + id8 + ".log";
+        File logFile = U.resolveIgnitePath(logPath);
 
-            String logContent = U.readFileToString(logFile.getAbsolutePath(), "UTF-8");
+        assertNotNull("Failed to resolve path: " + logPath, logFile);
+        assertTrue("Log file does not exist: " + logFile, logFile.exists());
+        // We have a row in log with the following content
+        // con >>> Local node [ID=NodeId ]
+        String logContent = U.readFileToString(logFile.getAbsolutePath(), "UTF-8");
+
+        assertTrue("Log file does not contain it's node ID: " + logFile,
+            logContent.contains(">>> Local node [ID="+ id8.toUpperCase()));
 
-            assertTrue("Log file does not contain it's node ID: " + logFile,
-                logContent.contains(">>> Local node [ID=" + id8.toUpperCase()));
-        }
     }
 
     /**
@@ -98,37 +75,15 @@ public class GridLog4j2CorrectFileNameTest extends TestCase {
      * @return Grid configuration.
      * @throws Exception If error occurred.
      */
-    private static IgniteConfiguration getConfiguration(String gridName) throws Exception {
+    private static IgniteConfiguration getConfiguration(String gridName)
+        throws Exception {
         IgniteConfiguration cfg = new IgniteConfiguration();
 
         cfg.setGridName(gridName);
-        cfg.setGridLogger(new Log4JLogger());
+
+        cfg.setGridLogger(new Log4J2Logger("config/ignite-log4j2.xml"));
         cfg.setConnectorConfiguration(null);
 
         return cfg;
     }
-
-    /**
-     * Creates new GridLog4jRollingFileAppender.
-     *
-     * @return GridLog4jRollingFileAppender.
-     * @throws Exception If error occurred.
-     */
-    private static Log4jRollingFileAppender createAppender() throws Exception {
-        Log4jRollingFileAppender appender = new Log4jRollingFileAppender();
-
-        appender.setLayout(new PatternLayout("[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"));
-        appender.setFile("work/log/ignite.log");
-        appender.setName(Log4jRollingFileAppender.class.getSimpleName());
-
-        LevelRangeFilter lvlFilter = new LevelRangeFilter();
-
-        lvlFilter.setLevelMin(Level.DEBUG);
-        lvlFilter.setLevelMax(Level.INFO);
-
-        appender.addFilter(lvlFilter);
-
-        return appender;
-    }
 }
-

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f524d3fd/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java
index 107ec38..78a53b6 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java
@@ -26,19 +26,11 @@ import org.apache.ignite.testframework.junits.common.*;
  */
 @GridCommonTest(group = "Logger")
 public class GridLog4j2InitializedTest extends TestCase {
-
-    /**
-     * @throws Exception If failed.
-     */
-    @Override protected void setUp() throws Exception {
-        BasicConfigurator.configure();
-    }
-
     /** */
     public void testLogInitialize() {
-        IgniteLogger log = new Log4JLogger();
+        IgniteLogger log = new Log4J2Logger();
 
-        assert log.isInfoEnabled() == true;
+        assert log.isInfoEnabled();
 
         if (log.isDebugEnabled())
             log.debug("This is 'debug' message.");
@@ -47,8 +39,7 @@ public class GridLog4j2InitializedTest extends TestCase {
         log.warning("This is 'warning' message.");
         log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
         log.error("This is 'error' message.");
-        log.error("This is 'error' message.", new Exception("It's a test error exception"));
 
-        assert log.getLogger(GridLog4j2InitializedTest.class.getName()) instanceof Log4JLogger;
+        assert log.getLogger(GridLog4j2InitializedTest.class.getName()) instanceof Log4J2Logger;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f524d3fd/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java
new file mode 100644
index 0000000..c2fb7ca
--- /dev/null
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.logger.log4j2;
+
+import junit.framework.*;
+import org.apache.ignite.*;
+import org.apache.ignite.logger.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Grid Log4j2 SPI test.
+ */
+@GridCommonTest(group = "Logger")
+public class GridLog4j2InitiallizationTest extends TestCase {
+    /** */
+    public static final String LOG_PATH = "modules/core/src/test/config/log4j2-test.xml";
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFile() throws Exception {
+        File xml = GridTestUtils.resolveIgnitePath(LOG_PATH);
+
+        assert xml != null;
+        assert xml.exists();
+
+        IgniteLogger log = new Log4J2Logger(xml).getLogger(getClass());
+
+        ((LoggerNodeIdAware) log).setNodeId(UUID.randomUUID());
+
+        checkLog(log);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testUrl() throws Exception {
+        File xml = GridTestUtils.resolveIgnitePath(LOG_PATH);
+
+        assert xml != null;
+        assert xml.exists();
+
+        IgniteLogger log = new Log4J2Logger(xml.toURI().toURL()).getLogger(getClass());
+
+        ((LoggerNodeIdAware) log).setNodeId(UUID.randomUUID());
+
+        checkLog(log);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPath() throws Exception {
+        IgniteLogger log = new Log4J2Logger(LOG_PATH).getLogger(getClass());
+
+        ((LoggerNodeIdAware) log).setNodeId(UUID.randomUUID());
+
+        checkLog(log);
+    }
+
+    /**
+     * Tests log4j logging SPI.
+     */
+    private void checkLog(IgniteLogger log) {
+        assert !log.isDebugEnabled();
+        assert log.isInfoEnabled();
+
+        log.debug("This is 'debug' message.");
+        log.info("This is 'info' message.");
+        log.warning("This is 'warning' message.");
+        log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
+        log.error("This is 'error' message.");
+        log.error("This is 'error' message.", new Exception("It's a test error exception"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f524d3fd/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingFileTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingFileTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingFileTest.java
deleted file mode 100644
index e52e58f..0000000
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingFileTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-import junit.framework.*;
-import org.apache.ignite.*;
-import org.apache.ignite.testframework.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import java.io.*;
-
-/**
- * Grid Log4j SPI test.
- */
-@GridCommonTest(group = "Logger")
-public class GridLog4j2LoggingFileTest extends TestCase {
-    /** */
-    private IgniteLogger log;
-
-    /** {@inheritDoc} */
-    @Override protected void setUp() throws Exception {
-        File xml = GridTestUtils.resolveIgnitePath("modules/core/src/test/config/log4j-test.xml");
-
-        assert xml != null;
-        assert xml.exists() == true;
-
-        log = new Log4JLogger(xml).getLogger(getClass());
-    }
-
-    /**
-     * Tests log4j logging SPI.
-     */
-    public void testLog() {
-        assert log.isDebugEnabled() == true;
-        assert log.isInfoEnabled() == true;
-
-        log.debug("This is 'debug' message.");
-        log.info("This is 'info' message.");
-        log.warning("This is 'warning' message.");
-        log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
-        log.error("This is 'error' message.");
-        log.error("This is 'error' message.", new Exception("It's a test error exception"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f524d3fd/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingPathTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingPathTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingPathTest.java
deleted file mode 100644
index 7477528..0000000
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingPathTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-import junit.framework.*;
-import org.apache.ignite.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-/**
- * Grid Log4j SPI test.
- */
-@GridCommonTest(group = "Logger")
-public class GridLog4j2LoggingPathTest extends TestCase {
-    /** */
-    private IgniteLogger log;
-
-    /** {@inheritDoc} */
-    @Override protected void setUp() throws Exception {
-        log = new Log4JLogger("modules/core/src/test/config/log4j-test.xml").getLogger(getClass());
-    }
-
-    /**
-     * Tests log4j logging SPI.
-     */
-    public void testLog() {
-        assert log.isInfoEnabled() == true;
-
-        if (log.isDebugEnabled())
-            log.debug("This is 'debug' message.");
-
-        log.info("This is 'info' message.");
-        log.warning("This is 'warning' message.");
-        log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
-        log.error("This is 'error' message.");
-        log.error("This is 'error' message.", new Exception("It's a test error exception"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f524d3fd/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingUrlTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingUrlTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingUrlTest.java
deleted file mode 100644
index 03ff4ba..0000000
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingUrlTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-import junit.framework.*;
-import org.apache.ignite.*;
-import org.apache.ignite.testframework.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import java.io.*;
-
-/**
- * Grid Log4j SPI test.
- */
-@GridCommonTest(group = "Logger")
-public class GridLog4j2LoggingUrlTest extends TestCase {
-    /** */
-    private IgniteLogger log;
-
-    /** {@inheritDoc} */
-    @Override protected void setUp() throws Exception {
-        File xml = GridTestUtils.resolveIgnitePath("modules/core/src/test/config/log4j-test.xml");
-
-        assert xml != null;
-        assert xml.exists();
-
-        log = new Log4JLogger(xml.toURI().toURL()).getLogger(getClass());
-    }
-
-    /**
-     * Tests log4j logging SPI.
-     */
-    public void testLog() {
-        assert log.isDebugEnabled();
-        assert log.isInfoEnabled();
-
-        log.debug("This is 'debug' message.");
-        log.info("This is 'info' message.");
-        log.warning("This is 'warning' message.");
-        log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
-        log.error("This is 'error' message.");
-        log.error("This is 'error' message.", new Exception("It's a test error exception"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f524d3fd/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java
index 10bf0a1..6db58bf 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java
@@ -28,7 +28,7 @@ import org.apache.ignite.testframework.junits.common.*;
 public class GridLog4j2NotInitializedTest extends TestCase {
     /** */
     public void testLogInitialize() {
-        IgniteLogger log = new Log4JLogger().getLogger(GridLog4j2NotInitializedTest.class);
+        IgniteLogger log = new Log4J2Logger().getLogger(GridLog4j2NotInitializedTest.class);
 
         if (log.isDebugEnabled())
             log.debug("This is 'debug' message.");

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f524d3fd/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java b/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java
index 23fef9a..4cc7c1a 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.testsuites;
 
 import junit.framework.*;
+import org.apache.ignite.logger.log4j2.*;
 
 /**
  * Log4j2 logging tests.
@@ -30,6 +31,11 @@ public class IgniteLog4j2TestSuite extends TestSuite {
     public static TestSuite suite() throws Exception {
         TestSuite suite = new TestSuite("Log4j2 Logging Test Suite");
 
+//        suite.addTest(new TestSuite(GridLog4j2InitializedTest.class));
+        suite.addTest(new TestSuite(GridLog4j2NotInitializedTest.class));
+        suite.addTest(new TestSuite(GridLog4j2CorrectFileNameTest.class));
+        suite.addTest(new TestSuite(GridLog4j2InitiallizationTest.class));
+
         return suite;
     }
 }


[16/24] incubator-ignite git commit: # ignite-788: all without quite mode

Posted by sb...@apache.org.
# ignite-788: all without quite mode


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2fcafcd5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2fcafcd5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2fcafcd5

Branch: refs/heads/ignite-788-last-review
Commit: 2fcafcd5edf82ef2beee97859de049347129c0ab
Parents: 4b6dd06
Author: ashutak <as...@gridgain.com>
Authored: Fri Jul 17 16:01:55 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Fri Jul 17 16:01:55 2015 +0300

----------------------------------------------------------------------
 config/ignite-log4j2.xml                        |  15 +-
 modules/core/src/test/config/log4j2-test.xml    |  10 +-
 .../ignite/logger/log4j2/ContextTestTmp.java    |  26 ++-
 .../ignite/logger/log4j2/Log4J2Logger.java      | 216 +++++++------------
 .../org/apache/ignite/logger/log4j2/TmpTmp.java |  37 ++++
 .../log4j2/GridLog4j2CorrectFileNameTest.java   |  90 --------
 .../log4j2/GridLog4j2InitializedTest.java       |  45 ----
 .../log4j2/GridLog4j2InitiallizationTest.java   | 106 ---------
 .../log4j2/GridLog4j2NotInitializedTest.java    |  46 ----
 .../logger/log4j2/GridLog4j2SelfTest.java       | 190 ++++++++++++++++
 .../testsuites/IgniteLog4j2TestSuite.java       |   5 +-
 11 files changed, 332 insertions(+), 454 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2fcafcd5/config/ignite-log4j2.xml
----------------------------------------------------------------------
diff --git a/config/ignite-log4j2.xml b/config/ignite-log4j2.xml
index 95da8c5..57f567e 100644
--- a/config/ignite-log4j2.xml
+++ b/config/ignite-log4j2.xml
@@ -21,10 +21,12 @@
     <Appenders>
         <Console name="CONSOLE" target="SYSTEM_OUT">
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+            <ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="ACCEPT"/>
         </Console>
 
         <Console name="CONSOLE_ERR" target="SYSTEM_ERR">
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+            <ThresholdFilter level="OFF" onMatch="DENY" onMismatch="ACCEPT"/>
         </Console>
 
         <Routing name="FILE">
@@ -39,19 +41,6 @@
                         </Policies>
                     </RollingFile>
                 </Route>
-
-                <!--
-                <Route key="$${sys:nodeId}">
-                    <RollingFile name="Rolling-default" fileName="work/log/ignite-default.log"
-                                 filePattern="work/log/ignite-default-%i-%d{yyyy-MM-dd}.log.gz">
-                        <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
-                        <Policies>
-                            <TimeBasedTriggeringPolicy interval="6" modulate="true" />
-                            <SizeBasedTriggeringPolicy size="10 MB" />
-                        </Policies>
-                    </RollingFile>
-                </Route>
-                 -->
             </Routes>
         </Routing>
     </Appenders>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2fcafcd5/modules/core/src/test/config/log4j2-test.xml
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/log4j2-test.xml b/modules/core/src/test/config/log4j2-test.xml
index b95709b..ef5c461 100644
--- a/modules/core/src/test/config/log4j2-test.xml
+++ b/modules/core/src/test/config/log4j2-test.xml
@@ -17,21 +17,23 @@
   limitations under the License.
 -->
 
-<Configuration status="info">
+<Configuration>
     <Appenders>
         <Console name="CONSOLE" target="SYSTEM_OUT">
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+            <ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="ACCEPT"/>
         </Console>
 
         <Console name="CONSOLE_ERR" target="SYSTEM_ERR">
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+            <ThresholdFilter level="OFF" onMatch="DENY" onMismatch="ACCEPT"/>
         </Console>
 
         <Routing name="FILE">
-            <Routes pattern="$${ctx:nodeId}">
+            <Routes pattern="$${sys:nodeId}">
                 <Route>
-                    <RollingFile name="Rolling-${ctx:nodeId}" fileName="work/log/ignite-${ctx:nodeId}.log"
-                                 filePattern="work/log/ignite-${ctx:nodeId}-%i-%d{yyyy-MM-dd}.log.gz">
+                    <RollingFile name="Rolling-${sys:nodeId}" fileName="${sys:IGNITE_HOME}/work/log/ignite-${sys:nodeId}.log"
+                                 filePattern="${sys:IGNITE_HOME}/work/log/ignite-${sys:nodeId}-%i-%d{yyyy-MM-dd}.log.gz">
                         <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
                         <Policies>
                             <TimeBasedTriggeringPolicy interval="6" modulate="true" />

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2fcafcd5/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
index 88540f0..1f858da 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
@@ -42,7 +42,7 @@ public class ContextTestTmp {
 
         Configurator.initialize(LogManager.ROOT_LOGGER_NAME, cfgUrl.toString());
 
-        addConsoleAppender(LogManager.getRootLogger(), Level.INFO);
+//        addConsoleAppender(LogManager.getRootLogger(), Level.INFO);
 //
 //        logTest();
 
@@ -54,6 +54,10 @@ public class ContextTestTmp {
 
         System.out.println(((org.apache.logging.log4j.core.Logger)LogManager.getRootLogger()).getAppenders());
 
+        Configuration cfg = ((LoggerContext)LogManager.getContext(false)).getConfiguration();
+        System.out.println(cfg.getAppenders().containsKey("Console"));
+//        System.out.println(cfg.getA.containsKey("Console"));
+
         logTest();
     }
 
@@ -69,26 +73,32 @@ public class ContextTestTmp {
     }
 
     private static void addConsoleAppender(final Logger logger, final Level maxLevel) {
-        ConsoleAppender appender = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
-            "SYSTEM_OUT", CONSOLE_APPENDER, null, null);
-
         final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
 
         final Configuration cfg = ctx.getConfiguration();
 
+//        for (Appender a : loggerConfig.getAppenders().values()) {
+//            if (a instanceof ConsoleAppender)
+//                return;
+//        }
+
+        ConsoleAppender appender = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
+            "SYSTEM_OUT", CONSOLE_APPENDER, null, null);
+
         appender.start();
 
         cfg.addAppender(appender);
 
-        LoggerConfig loggerConfig = cfg.getLoggerConfig(logger.getName());
+        LoggerConfig oldLogCfg = cfg.getLoggerConfig(logger.getName());
 
         AppenderRef ref = AppenderRef.createAppenderRef(CONSOLE_APPENDER, maxLevel, null);
 
-        loggerConfig.getAppenderRefs().add(ref);
+        LoggerConfig newLogCfg = LoggerConfig.createLogger("false", oldLogCfg.getLevel(),
+            oldLogCfg.getName(), "true", new AppenderRef[]{ref}, null, cfg, null);
 
-        loggerConfig.addAppender(appender, maxLevel, null);
+        newLogCfg.addAppender(appender, maxLevel, null);
 
-        cfg.addLogger(logger.getName(), loggerConfig);
+        cfg.addLogger(logger.getName(), oldLogCfg);
 
         ctx.updateLoggers();
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2fcafcd5/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index a8b7a31..8fc4e57 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -29,7 +29,6 @@ import org.apache.logging.log4j.core.Logger;
 import org.apache.logging.log4j.core.appender.*;
 import org.apache.logging.log4j.core.appender.routing.*;
 import org.apache.logging.log4j.core.config.*;
-import org.apache.logging.log4j.core.layout.*;
 import org.jetbrains.annotations.*;
 
 import java.io.*;
@@ -46,7 +45,7 @@ import static org.apache.ignite.IgniteSystemProperties.*;
  * Here is a typical example of configuring log4j2 logger in Ignite configuration file:
  * <pre name="code" class="xml">
  *      &lt;property name="gridLogger"&gt;
- *          &lt;bean class="org.apache.ignite.grid.logger.log4j2.Log4j2Logger"&gt;
+ *          &lt;bean class="org.apache.ignite.logger.log4j2.Log4J2Logger"&gt;
  *              &lt;constructor-arg type="java.lang.String" value="config/ignite-log4j2.xml"/&gt;
  *          &lt;/bean>
  *      &lt;/property&gt;
@@ -86,10 +85,6 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
     private Logger impl;
 
-    /** Path to configuration file. */
-    // TODO delete field.
-    private final String path;
-
     /** Quiet flag. */
     private final boolean quiet;
 
@@ -97,45 +92,6 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     private volatile UUID nodeId;
 
     /**
-     * Creates new logger and automatically detects if root logger already
-     * has appenders configured. If it does not, the root logger will be
-     * configured with default appender (analogous to calling
-     * {@link #Log4J2Logger(boolean) Log4J2Logger(boolean)}
-     * with parameter {@code true}, otherwise, existing appenders will be used (analogous
-     * to calling {@link #Log4J2Logger(boolean) Log4J2Logger(boolean)}
-     * with parameter {@code false}).
-     */
-    public Log4J2Logger() {
-        this(!isConfigured());
-    }
-
-    /**
-     * Creates new logger. If initialize parameter is {@code true} the Log4j
-     * logger will be initialized with default console appender and {@code INFO}
-     * log level.
-     *
-     * @param init If {@code true}, then a default console appender with
-     *      following pattern layout will be created: {@code %d{ABSOLUTE} %-5p [%c{1}] %m%n}.
-     *      If {@code false}, then no implicit initialization will take place,
-     *      and {@code Log4j} should be configured prior to calling this
-     *      constructor.
-     */
-    public Log4J2Logger(boolean init) {
-        impl = (Logger)LogManager.getRootLogger();
-
-        if (init) {
-            // Implementation has already been inited, passing NULL.
-            addConsoleAppenderIfNeeded(Level.INFO, null);
-
-            quiet = quiet0;
-        }
-        else
-            quiet = true;
-
-        path = null;
-    }
-
-    /**
      * Creates new logger with given implementation.
      *
      * @param impl Log4j implementation to use.
@@ -143,9 +99,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     public Log4J2Logger(final Logger impl) {
         assert impl != null;
 
-        path = null;
-
-        addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
+        addConsoleAppenderIfNeeded(new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 return impl;
             }
@@ -164,14 +118,12 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         if (path == null)
             throw new IgniteCheckedException("Configuration XML file for Log4j must be specified.");
 
-        this.path = path;
-
         final URL cfgUrl = U.resolveIgniteUrl(path);
 
         if (cfgUrl == null)
             throw new IgniteCheckedException("Log4j configuration path was not found: " + path);
 
-        addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
+        addConsoleAppenderIfNeeded(new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
                     Configurator.initialize(LogManager.ROOT_LOGGER_NAME, cfgUrl.toString());
@@ -194,11 +146,11 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
             throw new IgniteCheckedException("Configuration XML file for Log4j must be specified.");
 
         if (!cfgFile.exists() || cfgFile.isDirectory())
-            throw new IgniteCheckedException("Log4j configuration path was not found or is a directory: " + cfgFile);
+            throw new IgniteCheckedException("Log4j2 configuration path was not found or is a directory: " + cfgFile);
 
-        path = cfgFile.getAbsolutePath();
+        final String path = cfgFile.getAbsolutePath();
 
-        addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
+        addConsoleAppenderIfNeeded(new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
                     Configurator.initialize(LogManager.ROOT_LOGGER_NAME, path);
@@ -220,9 +172,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         if (cfgUrl == null)
             throw new IgniteCheckedException("Configuration XML file for Log4j must be specified.");
 
-        path = null;
-
-        addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
+        addConsoleAppenderIfNeeded(new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
                     Configurator.initialize(LogManager.ROOT_LOGGER_NAME, cfgUrl.toString());
@@ -235,19 +185,6 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     }
 
     /**
-     * Checks if Log4j2 is already configured within this VM or not.
-     *
-     * @return {@code True} if log4j2 was already configured, {@code false} otherwise.
-     */
-    // TODO review
-    public static boolean isConfigured() {
-        Logger log =
-            (Logger)LogManager.getLogger(LogManager.ROOT_LOGGER_NAME);
-
-        return !log.getAppenders().isEmpty();
-    }
-
-    /**
      * Sets level for internal log4j implementation.
      *
      * @param level Log level to set.
@@ -305,31 +242,29 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     /**
      * Adds console appender when needed with some default logging settings.
      *
-     * @param logLevel Optional log level.
-     * @param implInitC Optional log implementation init closure.
+     * @param initLogClo Optional log implementation init closure.
      */
-    private void addConsoleAppenderIfNeeded(@Nullable Level logLevel,
-        @Nullable IgniteClosure<Boolean, Logger> implInitC) {
+    private void addConsoleAppenderIfNeeded(@Nullable IgniteClosure<Boolean, Logger> initLogClo) {
         if (inited) {
-            if (implInitC != null)
+            if (initLogClo != null)
                 // Do not init.
-                impl = implInitC.apply(false);
+                impl = initLogClo.apply(false);
 
             return;
         }
 
         synchronized (mux) {
             if (inited) {
-                if (implInitC != null)
+                if (initLogClo != null)
                     // Do not init.
-                    impl = implInitC.apply(false);
+                    impl = initLogClo.apply(false);
 
                 return;
             }
 
-            if (implInitC != null)
+            if (initLogClo != null)
                 // Init logger impl.
-                impl = implInitC.apply(true);
+                impl = initLogClo.apply(true);
 
             boolean quiet = Boolean.valueOf(System.getProperty(IGNITE_QUIET, "true"));
 
@@ -337,7 +272,6 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
             Logger rootLogger = null;
             ConsoleAppender errAppender = null;
 
-            // TODO impl should be core logger.
             for (Logger log = impl; log != null; ) {
                 if (!consoleAppenderFound) {
                     for (Appender appender : log.getAppenders().values()) {
@@ -369,68 +303,75 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
                 // User configured console appender, but log is quiet.
                 quiet = false;
 
-            if (!consoleAppenderFound && !quiet && Boolean.valueOf(System.getProperty(IGNITE_CONSOLE_APPENDER, "true"))) {
-                // Console appender not found => we've looked through all categories up to root.
-                assert rootLogger != null;
-
-                // User launched ignite in verbose mode and did not add console appender with INFO level
-                // to configuration and did not set IGNITE_CONSOLE_APPENDER to false.
-                if (errAppender != null) {
-                    rootLogger.addAppender(createConsoleAppender(Level.INFO));
-
-                    // TODO implement.
-//                    if (errAppender.getThreshold() == Level.ERROR)
-//                        errAppender.setThreshold(Level.WARN);
-                }
-                else
-                    // No error console appender => create console appender with no level limit.
-                    rootLogger.addAppender(createConsoleAppender(Level.OFF));
-
-                if (logLevel != null)
-                    impl.setLevel(logLevel);
-            }
+//            if (!consoleAppenderFound && !quiet && Boolean.valueOf(System.getProperty(IGNITE_CONSOLE_APPENDER, "true"))) {
+//                // Console appender not found => we've looked through all categories up to root.
+//                assert rootLogger != null;
+//
+//                // User launched ignite in verbose mode and did not add console appender with INFO level
+//                // to configuration and did not set IGNITE_CONSOLE_APPENDER to false.
+//                if (errAppender != null) {
+//                    rootLogger.addAppender(createConsoleAppender(Level.INFO));
+//
+//                    // TODO implement.
+////                    if (errAppender.getThreshold() == Level.ERROR)
+////                        errAppender.setThreshold(Level.WARN);
+////                }
+////                else
+////                    // No error console appender => create console appender with no level limit.
+////                    rootLogger.addAppender(createConsoleAppender(Level.OFF));
+////
+//////                if (logLevel != null)
+//////                    impl.setLevel(logLevel);
+//                }
+//                else
+//                    // No error console appender => create console appender with no level limit.
+//                    rootLogger.addAppender(createConsoleAppender(Level.OFF));
+//
+//                if (logLevel != null)
+//                    impl.setLevel(logLevel);
+//            }
 
             quiet0 = quiet;
             inited = true;
         }
     }
 
-    /**
-     * Creates console appender with some reasonable default logging settings.
-     *
-     * @param maxLevel Max logging level.
-     * @return New console appender.
-     */
-    // TODO review.
-    private Appender createConsoleAppender(Level maxLevel) {
-        ConsoleAppender console = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
-            "SYSTEM_OUT", "console", null, null);
-
-        final LoggerContext ctx = new LoggerContext("console");
-
-        final Configuration cfg = ctx.getConfiguration();
-
-        console.start();
-
-        cfg.addAppender(console);
-
-        AppenderRef ref = AppenderRef.createAppenderRef("console", null, null);
-
-        AppenderRef[] refs = new AppenderRef[] {ref};
-
-        LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.ALL, LogManager.ROOT_LOGGER_NAME,
-            "true", refs, null, cfg, null);
-
-        loggerConfig.addAppender(console, null, null);
-
-        cfg.addLogger("org.apache.logging.log4j", loggerConfig);
-
-        ctx.updateLoggers();
-
-        ctx.getLogger("console").error("");
-
-        return console;
-    }
+//    /**
+//     * Creates console appender with some reasonable default logging settings.
+//     *
+//     * @param maxLevel Max logging level.
+//     * @return New console appender.
+//     */
+//    // TODO review.
+//    private Appender createConsoleAppender(Level maxLevel) {
+//        ConsoleAppender console = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
+//            "SYSTEM_OUT", "console", null, null);
+//
+//        final LoggerContext ctx = new LoggerContext("console");
+//
+//        final Configuration cfg = ctx.getConfiguration();
+//
+//        console.start();
+//
+//        cfg.addAppender(console);
+//
+//        AppenderRef ref = AppenderRef.createAppenderRef("console", null, null);
+//
+//        AppenderRef[] refs = new AppenderRef[] {ref};
+//
+//        LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.ALL, LogManager.ROOT_LOGGER_NAME,
+//            "true", refs, null, cfg, null);
+//
+//        loggerConfig.addAppender(console, null, null);
+//
+//        cfg.addLogger("org.apache.logging.log4j", loggerConfig);
+//
+//        ctx.updateLoggers();
+//
+//        ctx.getLogger("console").error("");
+//
+//        return console;
+//    }
 
     /** {@inheritDoc} */
     @Override public void setNodeId(UUID nodeId) {
@@ -444,7 +385,6 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         ((LoggerContext) LogManager.getContext(false)).reconfigure();
 
         // Hack. To touch the logger to create all log resources (files). Then #fileName() will work properly.
-        // TODO review it
         impl.log(Level.OFF, "");
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2fcafcd5/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/TmpTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/TmpTmp.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/TmpTmp.java
new file mode 100644
index 0000000..65ffbdb
--- /dev/null
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/TmpTmp.java
@@ -0,0 +1,37 @@
+/*
+ * 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.logger.log4j2;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+
+/**
+ * TODO: Add class description.
+ */
+public class TmpTmp {
+    public static void main(String[] args) throws IgniteCheckedException {
+        IgniteConfiguration cfg = new IgniteConfiguration().setGridLogger(
+//            new Log4J2Logger()
+            new Log4J2Logger("config/ignite-log4j2.xml")
+        );
+
+        try(Ignite ignite = Ignition.start(cfg)) {
+            ignite.log().info("lolol");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2fcafcd5/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
deleted file mode 100644
index 38cadfe..0000000
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-import junit.framework.*;
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import java.io.*;
-
-/**
- * Tests that several grids log to files with correct names.
- */
-@GridCommonTest(group = "Logger")
-public class GridLog4j2CorrectFileNameTest extends TestCase {
-    /**
-     * Tests correct behaviour in case 2 local nodes are started.
-     *
-     * @throws Exception If error occurs.
-     */
-    public void testLogFilesTwoNodes() throws Exception {
-        checkOneNode(0);
-        checkOneNode(1);
-    }
-
-    /**
-     * Starts the local node and checks for presence of log file.
-     * Also checks that this is really a log of a started node.
-     *
-     * @param id Test-local node ID.
-     * @throws Exception If error occurred.
-     */
-    private void checkOneNode(int id) throws Exception {
-        String id8;
-        File logFile;
-
-        try (Ignite ignite = G.start(getConfiguration("grid" + id))) {
-            id8 = U.id8(ignite.cluster().localNode().id());
-
-            String logPath = "work/log/ignite-" + id8 + ".log";
-
-            logFile = U.resolveIgnitePath(logPath);
-            assertNotNull("Failed to resolve path: " + logPath, logFile);
-            assertTrue("Log file does not exist: " + logFile, logFile.exists());
-
-            assertEquals(logFile.getAbsolutePath(), ignite.log().fileName());
-        }
-        String logContent = U.readFileToString(logFile.getAbsolutePath(), "UTF-8");
-
-        assertTrue("Log file does not contain it's node ID: " + logFile,
-            logContent.contains(">>> Local node [ID="+ id8.toUpperCase()));
-
-    }
-
-    /**
-     * Creates grid configuration.
-     *
-     * @param gridName Grid name.
-     * @return Grid configuration.
-     * @throws Exception If error occurred.
-     */
-    private static IgniteConfiguration getConfiguration(String gridName)
-        throws Exception {
-        IgniteConfiguration cfg = new IgniteConfiguration();
-
-        cfg.setGridName(gridName);
-
-        cfg.setGridLogger(new Log4J2Logger("config/ignite-log4j2.xml"));
-        cfg.setConnectorConfiguration(null);
-
-        return cfg;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2fcafcd5/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java
deleted file mode 100644
index 78a53b6..0000000
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-import junit.framework.*;
-import org.apache.ignite.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-/**
- * Log4j initialized test.
- */
-@GridCommonTest(group = "Logger")
-public class GridLog4j2InitializedTest extends TestCase {
-    /** */
-    public void testLogInitialize() {
-        IgniteLogger log = new Log4J2Logger();
-
-        assert log.isInfoEnabled();
-
-        if (log.isDebugEnabled())
-            log.debug("This is 'debug' message.");
-
-        log.info("This is 'info' message.");
-        log.warning("This is 'warning' message.");
-        log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
-        log.error("This is 'error' message.");
-
-        assert log.getLogger(GridLog4j2InitializedTest.class.getName()) instanceof Log4J2Logger;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2fcafcd5/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java
deleted file mode 100644
index 734ca6d..0000000
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-import junit.framework.*;
-import org.apache.ignite.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.logger.*;
-import org.apache.ignite.testframework.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * Grid Log4j2 SPI test.
- */
-@GridCommonTest(group = "Logger")
-public class GridLog4j2InitiallizationTest extends TestCase {
-    /** */
-    public static final String LOG_PATH = "modules/core/src/test/config/log4j2-test.xml";
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testFile() throws Exception {
-        File xml = GridTestUtils.resolveIgnitePath(LOG_PATH);
-
-        assert xml != null;
-        assert xml.exists();
-
-        IgniteLogger log = new Log4J2Logger(xml).getLogger(getClass());
-
-        ((LoggerNodeIdAware) log).setNodeId(UUID.randomUUID());
-
-        checkLog(log);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testUrl() throws Exception {
-        File xml = GridTestUtils.resolveIgnitePath(LOG_PATH);
-
-        assert xml != null;
-        assert xml.exists();
-
-        IgniteLogger log = new Log4J2Logger(xml.toURI().toURL()).getLogger(getClass());
-
-        ((LoggerNodeIdAware) log).setNodeId(UUID.randomUUID());
-
-        checkLog(log);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testPath() throws Exception {
-        IgniteLogger log = new Log4J2Logger(LOG_PATH).getLogger(getClass());
-
-        ((LoggerNodeIdAware) log).setNodeId(UUID.randomUUID());
-
-        checkLog(log);
-    }
-
-    /**
-     * Tests log4j logging SPI.
-     */
-    private void checkLog(IgniteLogger log) {
-        assert !log.isDebugEnabled();
-        assert log.isInfoEnabled();
-
-        log.debug("This is 'debug' message.");
-        log.info("This is 'info' message.");
-        log.warning("This is 'warning' message.");
-        log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
-        log.error("This is 'error' message.");
-        log.error("This is 'error' message.", new Exception("It's a test error exception"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testSystemNodeId() throws Exception {
-        UUID id = UUID.randomUUID();
-
-        new Log4J2Logger().setNodeId(id);
-
-        assertEquals(U.id8(id), System.getProperty("nodeId"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2fcafcd5/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java
deleted file mode 100644
index 6db58bf..0000000
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-import junit.framework.*;
-import org.apache.ignite.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-/**
- * Log4j not initialized test.
- */
-@GridCommonTest(group = "Logger")
-public class GridLog4j2NotInitializedTest extends TestCase {
-    /** */
-    public void testLogInitialize() {
-        IgniteLogger log = new Log4J2Logger().getLogger(GridLog4j2NotInitializedTest.class);
-
-        if (log.isDebugEnabled())
-            log.debug("This is 'debug' message.");
-        else
-            System.out.println("DEBUG level is not enabled.");
-
-        if (log.isInfoEnabled())
-            log.info("This is 'info' message.");
-        else
-            System.out.println("INFO level is not enabled.");
-
-        log.warning("This is 'warning' message.");
-        log.error("This is 'error' message.");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2fcafcd5/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
new file mode 100644
index 0000000..ba3f37b
--- /dev/null
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
@@ -0,0 +1,190 @@
+/*
+ * 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.logger.log4j2;
+
+import junit.framework.*;
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.logger.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.io.*;
+import java.util.*;
+
+import static org.apache.ignite.IgniteSystemProperties.*;
+
+/**
+ * Grid Log4j2 SPI test.
+ */
+@GridCommonTest(group = "Logger")
+public class GridLog4j2SelfTest extends TestCase {
+    /** */
+    public static final String LOG_PATH_TEST = "modules/core/src/test/config/log4j2-test.xml";
+
+    /** */
+    public static final String LOG_PATH_MAIN = "config/ignite-log4j2.xml";
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFileConstructor() throws Exception {
+        File xml = GridTestUtils.resolveIgnitePath(LOG_PATH_TEST);
+
+        assert xml != null;
+        assert xml.exists();
+
+        IgniteLogger log = new Log4J2Logger(xml).getLogger(getClass());
+
+        ((LoggerNodeIdAware) log).setNodeId(UUID.randomUUID());
+
+        checkLog(log);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testUrlConstructor() throws Exception {
+        File xml = GridTestUtils.resolveIgnitePath(LOG_PATH_TEST);
+
+        assert xml != null;
+        assert xml.exists();
+
+        IgniteLogger log = new Log4J2Logger(xml.toURI().toURL()).getLogger(getClass());
+
+        ((LoggerNodeIdAware) log).setNodeId(UUID.randomUUID());
+
+        checkLog(log);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testPathConstructor() throws Exception {
+        IgniteLogger log = new Log4J2Logger(LOG_PATH_TEST).getLogger(getClass());
+
+        ((LoggerNodeIdAware) log).setNodeId(UUID.randomUUID());
+
+        checkLog(log);
+    }
+
+    /**
+     * Tests log4j logging SPI.
+     */
+    private void checkLog(IgniteLogger log) {
+        assert !log.isDebugEnabled();
+        assert log.isInfoEnabled();
+
+        log.debug("This is 'debug' message.");
+        log.info("This is 'info' message.");
+        log.warning("This is 'warning' message.");
+        log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
+        log.error("This is 'error' message.");
+        log.error("This is 'error' message.", new Exception("It's a test error exception"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSystemNodeId() throws Exception {
+        UUID id = UUID.randomUUID();
+
+        new Log4J2Logger(LOG_PATH_TEST).setNodeId(id);
+
+        assertEquals(U.id8(id), System.getProperty("nodeId"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testVerboseMode() throws Exception {
+        System.setProperty(IGNITE_QUIET, "false");
+
+//        try (Ignite ignite = G.start(getConfiguration("grid" + id))) {
+//            id8 = U.id8(ignite.cluster().localNode().id());
+//
+//            String logPath = "work/log/ignite-" + id8 + ".log";
+//
+//            logFile = U.resolveIgnitePath(logPath);
+//            assertNotNull("Failed to resolve path: " + logPath, logFile);
+//            assertTrue("Log file does not exist: " + logFile, logFile.exists());
+//
+//            assertEquals(logFile.getAbsolutePath(), ignite.log().fileName());
+//        }
+    }
+
+    /**
+     * Tests correct behaviour in case 2 local nodes are started.
+     *
+     * @throws Exception If error occurs.
+     */
+    public void testLogFilesTwoNodes() throws Exception {
+        checkOneNode(0);
+        checkOneNode(1);
+    }
+
+    /**
+     * Starts the local node and checks for presence of log file.
+     * Also checks that this is really a log of a started node.
+     *
+     * @param id Test-local node ID.
+     * @throws Exception If error occurred.
+     */
+    private void checkOneNode(int id) throws Exception {
+        String id8;
+        File logFile;
+
+        try (Ignite ignite = G.start(getConfiguration("grid" + id))) {
+            id8 = U.id8(ignite.cluster().localNode().id());
+
+            String logPath = "work/log/ignite-" + id8 + ".log";
+
+            logFile = U.resolveIgnitePath(logPath);
+            assertNotNull("Failed to resolve path: " + logPath, logFile);
+            assertTrue("Log file does not exist: " + logFile, logFile.exists());
+
+            assertEquals(logFile.getAbsolutePath(), ignite.log().fileName());
+        }
+        String logContent = U.readFileToString(logFile.getAbsolutePath(), "UTF-8");
+
+        assertTrue("Log file does not contain it's node ID: " + logFile,
+            logContent.contains(">>> Local node [ID="+ id8.toUpperCase()));
+
+    }
+
+    /**
+     * Creates grid configuration.
+     *
+     * @param gridName Grid name.
+     * @return Grid configuration.
+     * @throws Exception If error occurred.
+     */
+    private static IgniteConfiguration getConfiguration(String gridName)
+        throws Exception {
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setGridName(gridName);
+
+        cfg.setGridLogger(new Log4J2Logger(LOG_PATH_MAIN));
+        cfg.setConnectorConfiguration(null);
+
+        return cfg;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2fcafcd5/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java b/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java
index 4cc7c1a..84b6a0c 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/testsuites/IgniteLog4j2TestSuite.java
@@ -31,10 +31,7 @@ public class IgniteLog4j2TestSuite extends TestSuite {
     public static TestSuite suite() throws Exception {
         TestSuite suite = new TestSuite("Log4j2 Logging Test Suite");
 
-//        suite.addTest(new TestSuite(GridLog4j2InitializedTest.class));
-        suite.addTest(new TestSuite(GridLog4j2NotInitializedTest.class));
-        suite.addTest(new TestSuite(GridLog4j2CorrectFileNameTest.class));
-        suite.addTest(new TestSuite(GridLog4j2InitiallizationTest.class));
+        suite.addTest(new TestSuite(GridLog4j2SelfTest.class));
 
         return suite;
     }



[08/24] incubator-ignite git commit: # ignite-788: file logger works properly

Posted by sb...@apache.org.
# ignite-788: file logger works properly


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a679ff96
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a679ff96
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a679ff96

Branch: refs/heads/ignite-788-last-review
Commit: a679ff966d60b8362a36c2a03db9d5e8d9368861
Parents: 992dc65
Author: ashutak <as...@gridgain.com>
Authored: Wed Jul 15 19:31:57 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Jul 15 19:31:57 2015 +0300

----------------------------------------------------------------------
 config/ignite-log4j2.xml                        |  42 +++--
 .../log4j2/IgniteRollingFileAppender.java       | 162 -------------------
 .../ignite/logger/log4j2/Log4J2Logger.java      |  65 +-------
 .../ignite/logger/log4j2/Log4j2FileAware.java   |  32 ----
 .../logger/log4j2/Log4j2NodeIdFilePath.java     |  64 --------
 .../ignite/logger/log4j2/Log4j2TestTmp.java     |  41 ++---
 6 files changed, 55 insertions(+), 351 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a679ff96/config/ignite-log4j2.xml
----------------------------------------------------------------------
diff --git a/config/ignite-log4j2.xml b/config/ignite-log4j2.xml
index 08d9246..b24c57b 100644
--- a/config/ignite-log4j2.xml
+++ b/config/ignite-log4j2.xml
@@ -23,19 +23,33 @@
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
         </Console>
 
-        <!--TODO-->
-        <!--<param name="MaxFileSize" value="10MB"/>-->
-        <!--<param name="MaxBackupIndex" value="10"/>-->
-        <IgniteRollingFile name="FILE" fileName="work/log/ignite-id2.log"
-                     filePattern="work/log/$${date:yyyy-MM}/ignite-%d{MM-dd-yyyy}-%i.log.gz">
-            <PatternLayout>
-                <pattern>[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n</pattern>
-            </PatternLayout>
-            <Policies>
-                <TimeBasedTriggeringPolicy />
-                <SizeBasedTriggeringPolicy size="250 MB"/>
-            </Policies>
-        </IgniteRollingFile>
+        <Routing name="Routing">
+            <Routes pattern="$${ctx:nodeId}">
+                <Route>
+                    <RollingFile name="Rolling-${ctx:nodeId}" fileName="work/log/ignite-${ctx:nodeId}.log"
+                                 filePattern="work/log/ignite-${ctx:nodeId}-%i-%d{yyyy-MM-dd}.log.gz">
+                        <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+                        <Policies>
+                            <TimeBasedTriggeringPolicy interval="6" modulate="true" />
+                            <SizeBasedTriggeringPolicy size="10 MB" />
+                        </Policies>
+                    </RollingFile>
+                </Route>
+
+                <!--
+                <Route key="$${ctx:nodeId}">
+                    <RollingFile name="Rolling-default" fileName="work/log/ignite-default.log"
+                                 filePattern="work/log/ignite-default-%i-%d{yyyy-MM-dd}.log.gz">
+                        <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+                        <Policies>
+                            <TimeBasedTriggeringPolicy interval="6" modulate="true" />
+                            <SizeBasedTriggeringPolicy size="10 MB" />
+                        </Policies>
+                    </RollingFile>
+                </Route>
+                 -->
+            </Routes>
+        </Routing>
     </Appenders>
 
     <Loggers>
@@ -47,7 +61,7 @@
 
         <Root level="INFO">
             <AppenderRef ref="CONSOLE_ERR"/>
-            <AppenderRef ref="FILE"/>
+            <AppenderRef ref="Routing"/>
         </Root>
     </Loggers>
 </Configuration>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a679ff96/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/IgniteRollingFileAppender.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/IgniteRollingFileAppender.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/IgniteRollingFileAppender.java
deleted file mode 100644
index 75f967f..0000000
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/IgniteRollingFileAppender.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
-* 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.logger.log4j2;
-
-import org.apache.ignite.lang.*;
-import org.apache.logging.log4j.core.*;
-import org.apache.logging.log4j.core.appender.*;
-import org.apache.logging.log4j.core.appender.rolling.*;
-import org.apache.logging.log4j.core.config.*;
-import org.apache.logging.log4j.core.config.plugins.*;
-
-import java.io.*;
-
-/**
-* TODO
-*/
-@Plugin(name = "IgniteRollingFile", category = "Core", elementType = "appender", printObject = true)
-public final class IgniteRollingFileAppender implements Appender, Serializable, Log4j2FileAware {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** */
-    private volatile RollingFileAppender a;
-
-    /** */
-    private IgniteRollingFileAppender(RollingFileAppender a) {
-        this.a = a;
-    }
-
-    /**
-     * Create a RollingFileAppender.
-     * @param fileName The name of the file that is actively written to. (required).
-     * @param filePattern The pattern of the file name to use on rollover. (required).
-     * @param append If true, events are appended to the file. If false, the file
-     * is overwritten when opened. Defaults to "true"
-     * @param name The name of the Appender (required).
-     * @param bufferedIO When true, I/O will be buffered. Defaults to "true".
-     * @param bufferSizeStr buffer size for buffered IO (default is 8192).
-     * @param immediateFlush When true, events are immediately flushed. Defaults to "true".
-     * @param policy The triggering policy. (required).
-     * @param strategy The rollover strategy. Defaults to DefaultRolloverStrategy.
-     * @param layout The layout to use (defaults to the default PatternLayout).
-     * @param filter The Filter or null.
-     * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
-     *               they are propagated to the caller.
-     * @param advertise "true" if the appender configuration should be advertised, "false" otherwise.
-     * @param advertiseURI The advertised URI which can be used to retrieve the file contents.
-     * @param config The Configuration.
-     * @return A RollingFileAppender.
-     */
-    @PluginFactory
-    public static IgniteRollingFileAppender createAppender(
-        @PluginAttribute("fileName") final String fileName,
-        @PluginAttribute("filePattern") final String filePattern,
-        @PluginAttribute("append") final String append,
-        @PluginAttribute("name") final String name,
-        @PluginAttribute("bufferedIO") final String bufferedIO,
-        @PluginAttribute("bufferSize") final String bufferSizeStr,
-        @PluginAttribute("immediateFlush") final String immediateFlush,
-        @PluginElement("Policy") final TriggeringPolicy policy,
-        @PluginElement("Strategy") RolloverStrategy strategy,
-        @PluginElement("Layout") Layout<? extends Serializable> layout,
-        @PluginElement("Filter") final Filter filter,
-        @PluginAttribute("ignoreExceptions") final String ignore,
-        @PluginAttribute("advertise") final String advertise,
-        @PluginAttribute("advertiseURI") final String advertiseURI,
-        @PluginConfiguration final Configuration config) {
-
-        RollingFileAppender a = RollingFileAppender.createAppender(
-            fileName,
-            filePattern,
-            append,
-            name,
-            bufferedIO,
-            bufferSizeStr,
-            immediateFlush,
-            policy,
-            strategy,
-            layout,
-            filter,
-            ignore,
-            advertise,
-            advertiseURI,
-            config);
-
-        return new IgniteRollingFileAppender(a);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void append(LogEvent event) {
-        a.append(event);
-    }
-
-    /** {@inheritDoc} */
-    @Override public String getName() {
-        return a.getName();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Layout<? extends Serializable> getLayout() {
-        return a.getLayout();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean ignoreExceptions() {
-        return a.ignoreExceptions();
-    }
-
-    /** {@inheritDoc} */
-    @Override public ErrorHandler getHandler() {
-        return a.getHandler();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void setHandler(ErrorHandler handler) {
-        a.setHandler(handler);
-    }
-
-    /** {@inheritDoc} */
-    @Override public State getState() {
-        return a.getState();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void start() {
-        a.start();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void stop() {
-        a.stop();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isStarted() {
-        return a.isStarted();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isStopped() {
-        return a.isStopped();
-    }
-
-    @Override public void updateFilePath(IgniteClosure<String, String> filePathClos) {
-        System.out.println();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a679ff96/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index c6a4df1..0cfe485 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.logger.log4j2;
 
 import org.apache.ignite.*;
-import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -67,10 +66,9 @@ import static org.apache.ignite.IgniteSystemProperties.*;
  * logger in your task/job code. See {@link org.apache.ignite.resources.LoggerResource} annotation about logger
  * injection.
  */
-public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4j2FileAware {
+public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     public static final String LOGGER_NAME = "Log4J2Logger";
-    /** Appenders. */
-    private static Collection<FileAppender> fileAppenders = new GridConcurrentHashSet<>();
+    public static final String NODE_ID = "nodeId";
 
     /** */
     private static volatile boolean inited;
@@ -417,36 +415,16 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4j2File
         return console;
     }
 
-    /**
-     * Adds file appender.
-     *
-     * @param a Appender.
-     */
-    public static void addAppender(FileAppender a) {
-        A.notNull(a, "a");
-
-        fileAppenders.add(a);
-    }
-
-    /**
-     * Removes file appender.
-     *
-     * @param a Appender.
-     */
-    public static void removeAppender(FileAppender a) {
-        A.notNull(a, "a");
-
-        fileAppenders.remove(a);
-    }
-
     /** {@inheritDoc} */
     @Override public void setNodeId(UUID nodeId) {
         A.notNull(nodeId, "nodeId");
 
         this.nodeId = nodeId;
 
-        // TODO implement
-        updateFilePath(new Log4j2NodeIdFilePath(nodeId));
+        // Set nodeId at context to be used at configuration.
+        ThreadContext.put(NODE_ID, U.id8(nodeId));
+
+        ((LoggerContext) LogManager.getContext(false)).reconfigure();
     }
 
     /** {@inheritDoc} */
@@ -454,21 +432,6 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4j2File
         return nodeId;
     }
 
-    // TODO implement.
-//    /**
-//     * Gets files for all registered file appenders.
-//     *
-//     * @return List of files.
-//     */
-//    public static Collection<String> logFiles() {
-//        Collection<String> res = new ArrayList<>(fileAppenders.size());
-//
-//        for (FileAppender a : fileAppenders)
-//            res.add(a.getFile());
-//
-//        return res;
-//    }
-
     /**
      * Gets {@link IgniteLogger} wrapper around log4j logger for the given
      * category. If category is {@code null}, then root logger is returned. If
@@ -556,20 +519,4 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4j2File
     @Override public String toString() {
         return S.toString(Log4J2Logger.class, this);
     }
-
-    /** {@inheritDoc} */
-    // TODO implement.
-    @Override public void updateFilePath(IgniteClosure<String, String> filePathClos) {
-        A.notNull(filePathClos, "filePathClos");
-
-//        new RollingFileAppender()
-
-//        for (FileAppender a : fileAppenders) {
-//            if (a instanceof Log4j2FileAware) {
-//                ((Log4j2FileAware)a).updateFilePath(filePathClos);
-//
-//                a.activateOptions();
-//            }
-//        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a679ff96/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2FileAware.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2FileAware.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2FileAware.java
deleted file mode 100644
index de261aa..0000000
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2FileAware.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-import org.apache.ignite.lang.*;
-
-/**
- * Interface for those loggers and appenders that evaluate their file paths lazily.
- */
-interface Log4j2FileAware {
-    /**
-     * Sets closure that later evaluate file path.
-     *
-     * @param filePathClos Closure that generates actual file path.
-     */
-    void updateFilePath(IgniteClosure<String, String> filePathClos);
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a679ff96/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2NodeIdFilePath.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2NodeIdFilePath.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2NodeIdFilePath.java
deleted file mode 100644
index a0a7b12..0000000
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2NodeIdFilePath.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-import org.apache.ignite.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lang.*;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * Closure that generates file path adding node id to filename as a suffix.
- */
-class Log4j2NodeIdFilePath implements IgniteClosure<String, String> {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Node id. */
-    private final UUID nodeId;
-
-    /**
-     * Creates new instance.
-     *
-     * @param id Node id.
-     */
-    Log4j2NodeIdFilePath(UUID id) {
-        nodeId = id;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String apply(String oldPath) {
-        if (!F.isEmpty(U.IGNITE_LOG_DIR))
-            return U.nodeIdLogFileName(nodeId, new File(U.IGNITE_LOG_DIR, "ignite.log").getAbsolutePath());
-
-        if (oldPath != null) // fileName could be null if IGNITE_HOME is not defined.
-            return U.nodeIdLogFileName(nodeId, oldPath);
-
-        String tmpDir = IgniteSystemProperties.getString("java.io.tmpdir");
-
-        if (tmpDir != null)
-            return U.nodeIdLogFileName(nodeId, new File(tmpDir, "ignite.log").getAbsolutePath());
-
-        System.err.println("Failed to get tmp directory for log file.");
-
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a679ff96/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
index 4cd836e..cb1d6be 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
@@ -17,34 +17,35 @@
 
 package org.apache.ignite.logger.log4j2;
 
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.logging.log4j.*;
-import org.apache.logging.log4j.core.config.*;
-
-import java.net.*;
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
 
 /**
  * TODO: Add class description.
  */
 public class Log4j2TestTmp {
     public static void main(String[] args) throws Exception {
-        URL url = U.resolveIgniteUrl("config/ignite-log4j2.xml");
-
-        System.out.println(url);
-
-        Configurator.initialize("test logger", url.toString());
-
-        LogManager.getLogger("test logger").info("******************************");
-
-//        IgniteConfiguration cfg = new IgniteConfiguration()
-//            .setGridLogger(new Log4J2Logger("config/ignite-log4j2.xml"));
+//        URL url = U.resolveIgniteUrl("config/ignite-log4j2.xml");
+//
+//        System.out.println(url);
+//
+//        Configurator.initialize("test logger", url.toString());
 //
-//        try(Ignite ignite = Ignition.start(cfg)) {
-//            ignite.log().info("********** Hi! **************");
+//        LogManager.getLogger("test logger").info("******************************1");
 //
-//            Thread.sleep(5_000);
+//        ThreadContext.put("nodeId", "12345");
 //
-//            ignite.log().info("********** Hi! **************");
-//        }
+//        LogManager.getLogger("test logger").info("******************************2");
+
+        IgniteConfiguration cfg = new IgniteConfiguration()
+            .setGridLogger(new Log4J2Logger("config/ignite-log4j2.xml"));
+
+        try (Ignite ignite = Ignition.start(cfg.setGridName("grid1"))) {
+            ignite.log().info("****** smf 1 ********");
+            try (Ignite ignite2 = Ignition.start(cfg.setGridName("grid2"))) {
+                ignite.log().info("****** smf 2 ********");
+                ignite2.log().info("****** smf 3 ********");
+            }
+        }
     }
 }


[07/24] incubator-ignite git commit: # ignite-788: stop implementation at this way

Posted by sb...@apache.org.
# ignite-788: stop implementation at this way


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/992dc65c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/992dc65c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/992dc65c

Branch: refs/heads/ignite-788-last-review
Commit: 992dc65c01f320b328c44bdfa989701dd1e1b118
Parents: 630439f
Author: ashutak <as...@gridgain.com>
Authored: Wed Jul 15 18:51:33 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Jul 15 18:51:33 2015 +0300

----------------------------------------------------------------------
 config/ignite-log4j.xml                         |  10 +-
 config/ignite-log4j2.xml                        |   6 +-
 modules/log4j/src/main/java/Log4jTestTmp.java   |  37 +++++
 .../logger/log4j/Log4jRollingFileAppender.java  |   4 +
 .../log4j2/IgniteRollingFileAppender.java       | 162 +++++++++++++++++++
 .../ignite/logger/log4j2/Log4J2Logger.java      |  11 +-
 .../ignite/logger/log4j2/Log4j2TestTmp.java     |  29 ++--
 7 files changed, 238 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/992dc65c/config/ignite-log4j.xml
----------------------------------------------------------------------
diff --git a/config/ignite-log4j.xml b/config/ignite-log4j.xml
index 9d4521a..8dd114c 100644
--- a/config/ignite-log4j.xml
+++ b/config/ignite-log4j.xml
@@ -23,14 +23,14 @@
 <!--
     Default log4j configuration for Ignite.
 -->
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
     <!--
         Logs System.out messages to console.
 
         Note, this appender is disabled by default.
         To enable, uncomment the section below and also CONSOLE appender in the <root> element.
     -->
-    <!--
+    <!--&lt;!&ndash;-->
     <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
         <param name="Target" value="System.out"/>
 
@@ -45,7 +45,7 @@
             <param name="levelMax" value="WARN"/>
         </filter>
     </appender>
-    -->
+    <!--&ndash;&gt;-->
 
     <!--
         Logs all ERROR messages to console.
@@ -123,9 +123,9 @@
         <level value="INFO"/>
 
         <!-- Uncomment to enable logging to console. -->
-        <!--
+        <!--&lt;!&ndash;-->
         <appender-ref ref="CONSOLE"/>
-        -->
+        <!--&ndash;&gt;-->
 
         <appender-ref ref="CONSOLE_ERR"/>
         <appender-ref ref="FILE"/>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/992dc65c/config/ignite-log4j2.xml
----------------------------------------------------------------------
diff --git a/config/ignite-log4j2.xml b/config/ignite-log4j2.xml
index 4ada9ff..08d9246 100644
--- a/config/ignite-log4j2.xml
+++ b/config/ignite-log4j2.xml
@@ -17,7 +17,7 @@
   limitations under the License.
 -->
 
-<Configuration status="trace">
+<Configuration status="info">
     <Appenders>
         <Console name="CONSOLE_ERR" target="SYSTEM_ERR">
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
@@ -26,7 +26,7 @@
         <!--TODO-->
         <!--<param name="MaxFileSize" value="10MB"/>-->
         <!--<param name="MaxBackupIndex" value="10"/>-->
-        <RollingFile name="FILE" fileName="work/log/ignite-id.log"
+        <IgniteRollingFile name="FILE" fileName="work/log/ignite-id2.log"
                      filePattern="work/log/$${date:yyyy-MM}/ignite-%d{MM-dd-yyyy}-%i.log.gz">
             <PatternLayout>
                 <pattern>[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n</pattern>
@@ -35,7 +35,7 @@
                 <TimeBasedTriggeringPolicy />
                 <SizeBasedTriggeringPolicy size="250 MB"/>
             </Policies>
-        </RollingFile>
+        </IgniteRollingFile>
     </Appenders>
 
     <Loggers>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/992dc65c/modules/log4j/src/main/java/Log4jTestTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/Log4jTestTmp.java b/modules/log4j/src/main/java/Log4jTestTmp.java
new file mode 100644
index 0000000..b855ce5
--- /dev/null
+++ b/modules/log4j/src/main/java/Log4jTestTmp.java
@@ -0,0 +1,37 @@
+/*
+ * 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.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.logger.log4j.*;
+
+/**
+ * TODO: Add class description.
+ */
+public class Log4jTestTmp {
+    public static void main(String[] args) throws Exception {
+        IgniteConfiguration cfg = new IgniteConfiguration()
+            .setGridLogger(new Log4JLogger("config/ignite-log4j.xml"));
+
+        try(Ignite ignite = Ignition.start(cfg.setGridName("grid1"))) {
+            ignite.log().info("****** smf 1 ********");
+        try(Ignite ignite2 = Ignition.start(cfg.setGridName("grid2"))) {
+            ignite.log().info("****** smf 2 ********");
+            ignite2.log().info("****** smf 3 ********");
+        }}
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/992dc65c/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4jRollingFileAppender.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4jRollingFileAppender.java b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4jRollingFileAppender.java
index dcf03a4..fbe3aab 100644
--- a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4jRollingFileAppender.java
+++ b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4jRollingFileAppender.java
@@ -73,12 +73,16 @@ public class Log4jRollingFileAppender extends RollingFileAppender implements Log
 
     /** {@inheritDoc} */
     @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) {
+        U.debug("**************** updateFilePath ************");
+
         A.notNull(filePathClos, "filePathClos");
 
         if (baseFileName == null)
             baseFileName = fileName;
 
         fileName = filePathClos.apply(baseFileName);
+
+        U.debug("**************** fileName=" + fileName + " appender=" + System.identityHashCode(this) + " ************");
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/992dc65c/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/IgniteRollingFileAppender.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/IgniteRollingFileAppender.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/IgniteRollingFileAppender.java
new file mode 100644
index 0000000..75f967f
--- /dev/null
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/IgniteRollingFileAppender.java
@@ -0,0 +1,162 @@
+/*
+* 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.logger.log4j2;
+
+import org.apache.ignite.lang.*;
+import org.apache.logging.log4j.core.*;
+import org.apache.logging.log4j.core.appender.*;
+import org.apache.logging.log4j.core.appender.rolling.*;
+import org.apache.logging.log4j.core.config.*;
+import org.apache.logging.log4j.core.config.plugins.*;
+
+import java.io.*;
+
+/**
+* TODO
+*/
+@Plugin(name = "IgniteRollingFile", category = "Core", elementType = "appender", printObject = true)
+public final class IgniteRollingFileAppender implements Appender, Serializable, Log4j2FileAware {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** */
+    private volatile RollingFileAppender a;
+
+    /** */
+    private IgniteRollingFileAppender(RollingFileAppender a) {
+        this.a = a;
+    }
+
+    /**
+     * Create a RollingFileAppender.
+     * @param fileName The name of the file that is actively written to. (required).
+     * @param filePattern The pattern of the file name to use on rollover. (required).
+     * @param append If true, events are appended to the file. If false, the file
+     * is overwritten when opened. Defaults to "true"
+     * @param name The name of the Appender (required).
+     * @param bufferedIO When true, I/O will be buffered. Defaults to "true".
+     * @param bufferSizeStr buffer size for buffered IO (default is 8192).
+     * @param immediateFlush When true, events are immediately flushed. Defaults to "true".
+     * @param policy The triggering policy. (required).
+     * @param strategy The rollover strategy. Defaults to DefaultRolloverStrategy.
+     * @param layout The layout to use (defaults to the default PatternLayout).
+     * @param filter The Filter or null.
+     * @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise
+     *               they are propagated to the caller.
+     * @param advertise "true" if the appender configuration should be advertised, "false" otherwise.
+     * @param advertiseURI The advertised URI which can be used to retrieve the file contents.
+     * @param config The Configuration.
+     * @return A RollingFileAppender.
+     */
+    @PluginFactory
+    public static IgniteRollingFileAppender createAppender(
+        @PluginAttribute("fileName") final String fileName,
+        @PluginAttribute("filePattern") final String filePattern,
+        @PluginAttribute("append") final String append,
+        @PluginAttribute("name") final String name,
+        @PluginAttribute("bufferedIO") final String bufferedIO,
+        @PluginAttribute("bufferSize") final String bufferSizeStr,
+        @PluginAttribute("immediateFlush") final String immediateFlush,
+        @PluginElement("Policy") final TriggeringPolicy policy,
+        @PluginElement("Strategy") RolloverStrategy strategy,
+        @PluginElement("Layout") Layout<? extends Serializable> layout,
+        @PluginElement("Filter") final Filter filter,
+        @PluginAttribute("ignoreExceptions") final String ignore,
+        @PluginAttribute("advertise") final String advertise,
+        @PluginAttribute("advertiseURI") final String advertiseURI,
+        @PluginConfiguration final Configuration config) {
+
+        RollingFileAppender a = RollingFileAppender.createAppender(
+            fileName,
+            filePattern,
+            append,
+            name,
+            bufferedIO,
+            bufferSizeStr,
+            immediateFlush,
+            policy,
+            strategy,
+            layout,
+            filter,
+            ignore,
+            advertise,
+            advertiseURI,
+            config);
+
+        return new IgniteRollingFileAppender(a);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void append(LogEvent event) {
+        a.append(event);
+    }
+
+    /** {@inheritDoc} */
+    @Override public String getName() {
+        return a.getName();
+    }
+
+    /** {@inheritDoc} */
+    @Override public Layout<? extends Serializable> getLayout() {
+        return a.getLayout();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean ignoreExceptions() {
+        return a.ignoreExceptions();
+    }
+
+    /** {@inheritDoc} */
+    @Override public ErrorHandler getHandler() {
+        return a.getHandler();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void setHandler(ErrorHandler handler) {
+        a.setHandler(handler);
+    }
+
+    /** {@inheritDoc} */
+    @Override public State getState() {
+        return a.getState();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void start() {
+        a.start();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void stop() {
+        a.stop();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isStarted() {
+        return a.isStarted();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isStopped() {
+        return a.isStopped();
+    }
+
+    @Override public void updateFilePath(IgniteClosure<String, String> filePathClos) {
+        System.out.println();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/992dc65c/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index 22cc231..c6a4df1 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -68,6 +68,7 @@ import static org.apache.ignite.IgniteSystemProperties.*;
  * injection.
  */
 public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4j2FileAware {
+    public static final String LOGGER_NAME = "Log4J2Logger";
     /** Appenders. */
     private static Collection<FileAppender> fileAppenders = new GridConcurrentHashSet<>();
 
@@ -174,7 +175,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4j2File
             @Override public Logger apply(Boolean init) {
                 if (init)
                     // TODO review
-                    Configurator.initialize("Log4J2Logger", cfgUrl.toString());
+                    Configurator.initialize(LOGGER_NAME, cfgUrl.toString());
 
                 return LogManager.getRootLogger();
             }
@@ -202,7 +203,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4j2File
         addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
-                    Configurator.initialize("Log4J2Logger", path);
+                    Configurator.initialize(LOGGER_NAME, path);
 
                 return LogManager.getRootLogger();
             }
@@ -227,7 +228,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4j2File
         addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
-                    Configurator.initialize("Log4J2Logger", cfgUrl.toString());
+                    Configurator.initialize(LOGGER_NAME, cfgUrl.toString());
 
                 return LogManager.getRootLogger();
             }
@@ -243,7 +244,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4j2File
      */
     // TODO review
     public static boolean isConfigured() {
-        return LogManager.getLogger("Log4J2Logger") != null;
+        return LogManager.getLogger(LOGGER_NAME) != null;
     }
 
     /**
@@ -561,6 +562,8 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4j2File
     @Override public void updateFilePath(IgniteClosure<String, String> filePathClos) {
         A.notNull(filePathClos, "filePathClos");
 
+//        new RollingFileAppender()
+
 //        for (FileAppender a : fileAppenders) {
 //            if (a instanceof Log4j2FileAware) {
 //                ((Log4j2FileAware)a).updateFilePath(filePathClos);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/992dc65c/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
index d809b73..4cd836e 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
@@ -17,23 +17,34 @@
 
 package org.apache.ignite.logger.log4j2;
 
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.logging.log4j.*;
+import org.apache.logging.log4j.core.config.*;
+
+import java.net.*;
 
 /**
  * TODO: Add class description.
  */
 public class Log4j2TestTmp {
     public static void main(String[] args) throws Exception {
-        IgniteConfiguration cfg = new IgniteConfiguration()
-            .setGridLogger(new Log4J2Logger("config/ignite-log4j2.xml"));
+        URL url = U.resolveIgniteUrl("config/ignite-log4j2.xml");
+
+        System.out.println(url);
 
-        try(Ignite ignite = Ignition.start(cfg)) {
-            ignite.log().info("********** Hi! **************");
+        Configurator.initialize("test logger", url.toString());
 
-            Thread.sleep(5_000);
+        LogManager.getLogger("test logger").info("******************************");
 
-            ignite.log().info("********** Hi! **************");
-        }
+//        IgniteConfiguration cfg = new IgniteConfiguration()
+//            .setGridLogger(new Log4J2Logger("config/ignite-log4j2.xml"));
+//
+//        try(Ignite ignite = Ignition.start(cfg)) {
+//            ignite.log().info("********** Hi! **************");
+//
+//            Thread.sleep(5_000);
+//
+//            ignite.log().info("********** Hi! **************");
+//        }
     }
 }


[20/24] incubator-ignite git commit: # ignite-788: refactor

Posted by sb...@apache.org.
# ignite-788: refactor


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/5dc5e392
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5dc5e392
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5dc5e392

Branch: refs/heads/ignite-788-last-review
Commit: 5dc5e3928c9009e90c0be078c3a090147878567d
Parents: f2264e0
Author: ashutak <as...@gridgain.com>
Authored: Fri Jul 17 20:03:23 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Fri Jul 17 20:03:23 2015 +0300

----------------------------------------------------------------------
 .../ignite/logger/log4j2/Log4J2Logger.java      | 96 +++++---------------
 .../logger/log4j2/GridLog4j2SelfTest.java       | 34 ++++---
 2 files changed, 37 insertions(+), 93 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5dc5e392/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index 4dc5e6f..48cfef0 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -75,7 +75,6 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
 
     /** */
     public static final String CONSOLE_APPENDER = "autoConfiguredIgniteConsoleAppender";
-    public static final String CONSOLE_LOGGER_NAME = LogManager.ROOT_LOGGER_NAME;
 
     /** */
     private static volatile boolean inited;
@@ -335,91 +334,38 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         }
     }
 
-//    private void createConsoleLogger(Logger logger, Level maxLevel) {
-//        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
-//
-//        final Configuration cfg = ctx.getConfiguration();
-//
-//        ConsoleAppender appender = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
-//            "SYSTEM_OUT", CONSOLE_APPENDER, null, null);
-//
-//        appender.start();
-//
-//        cfg.addAppender(appender);
-//
-//        LoggerConfig oldLogCfg = cfg.getLoggerConfig(logger.getName());
-//
-//        AppenderRef ref = AppenderRef.createAppenderRef(CONSOLE_APPENDER, Level.ALL, null);
-//
-//        LoggerConfig newLogCfg = LoggerConfig.createLogger("false", oldLogCfg.getLevel(),
-//            oldLogCfg.getName(), "true", new AppenderRef[]{ref}, null, cfg, null);
-//
-//        newLogCfg.addAppender(appender, Level.ALL, null);
-//
-//        cfg.addLogger(logger.getName(), oldLogCfg);
-//
-//        ctx.reconfigure();
-//        ctx.updateLoggers();
-//    }
-
-    /**
-     * Creates console appender with some reasonable default logging settings.
-     *
-     * @param maxLevel Max logging level.
-     * @return New console appender.
-     */
-    // TODO review.
-//    private void createConsoleLogger(Logger log, Level maxLevel) {
-//        ConsoleAppender consoleApp = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
-//            "SYSTEM_OUT", CONSOLE_APPENDER, null, null);
-//
-//        final LoggerContext ctx = log.getContext();
-//
-//        final Configuration cfg = ctx.getConfiguration();
-//
-//        consoleApp.start();
-//
-//        cfg.addAppender(consoleApp);
-//
-//        AppenderRef ref = AppenderRef.createAppenderRef(CONSOLE_APPENDER, null, null);
-//
-//        LoggerConfig logCfg = LoggerConfig.createLogger("true", null, log.getName(),
-//            "true", new AppenderRef[] {ref}, null, cfg, null);
-//
-//        logCfg.getAppenderRefs().add(ref);
-//
-//        cfg.addLogger(log.getName(), logCfg);
-//
-//        ctx.updateLoggers();
-//
-//        return consoleApp;
-//    }
     /**
      * Creates console appender with some reasonable default logging settings.
      *
      * @param maxLevel Max logging level.
      * @return New console appender.
      */
-    // TODO review.
     public static Logger createConsoleLogger(Logger log, Level maxLevel) {
-//        ((Log4jContextFactory)LogManager.getFactory()).getSelector().
+        LoggerContext ctx = (LoggerContext)LogManager.getContext(true);
 
-        LoggerContext context= (LoggerContext) LogManager.getContext(true);
-        Configuration config= context.getConfiguration();
+        Configuration cfg = ctx.getConfiguration();
+
+        PatternLayout layout = PatternLayout.createLayout("[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n", null, null, 
+            Charset.defaultCharset(), false, false, null, null);
+
+        Appender appender = ConsoleAppender.createAppender(layout, null, null, "CONSOLE_APPENDER", null, null);
 
-        PatternLayout layout= PatternLayout.createLayout("[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n", null, null, Charset.defaultCharset(),false,false,null,null);
-        Appender appender=ConsoleAppender.createAppender(layout, null, null, "CONSOLE_APPENDER", null, null);
         appender.start();
-        AppenderRef ref= AppenderRef.createAppenderRef("CONSOLE_APPENDER",null,null);
-        AppenderRef[] refs = new AppenderRef[] {ref};
-        LoggerConfig loggerConfig= LoggerConfig.createLogger("false", Level.INFO,CONSOLE_LOGGER_NAME,"",refs,null,null,null);
-        loggerConfig.addAppender(appender,null,null);
 
-        config.addAppender(appender);
-        config.addLogger(CONSOLE_LOGGER_NAME, loggerConfig);
-        context.updateLoggers(config);
+        AppenderRef ref = AppenderRef.createAppenderRef("CONSOLE_APPENDER", null, null);
+
+        LoggerConfig logCfg = LoggerConfig.createLogger("false", Level.INFO, LogManager.ROOT_LOGGER_NAME, "",
+            new AppenderRef[] {ref}, null, null, null);
+
+        logCfg.addAppender(appender, null, null);
+
+        cfg.addAppender(appender);
+
+        cfg.addLogger(LogManager.ROOT_LOGGER_NAME, logCfg);
+
+        ctx.updateLoggers(cfg);
 
-        return (Logger)LogManager.getContext().getLogger(CONSOLE_LOGGER_NAME);
+        return (Logger)LogManager.getContext().getLogger(LogManager.ROOT_LOGGER_NAME);
     }
 
     /** {@inheritDoc} */
@@ -496,7 +442,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     /** {@inheritDoc} */
     @Override public void warning(String msg) {
         impl.warn(msg);
-        if (LogManager.getContext().getLogger(CONSOLE_LOGGER_NAME) != null) LogManager.getContext().getLogger(CONSOLE_LOGGER_NAME).warn(msg);
+        if (consoleLogger != null) consoleLogger.warn(msg);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5dc5e392/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
index 3b07fa9..1a44be2 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
@@ -127,18 +127,7 @@ public class GridLog4j2SelfTest extends TestCase {
 
             System.setProperty("IGNITE_QUIET", "false");
 
-            TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
-            disco.setIpFinder(new TcpDiscoveryVmIpFinder(false) {{
-                setAddresses(Collections.singleton("127.0.0.1:47500..47509"));
-            }});
-
-            IgniteConfiguration cfg = new IgniteConfiguration()
-                .setGridLogger(new Log4J2Logger(LOG_PATH_VERBOSE_TEST))
-                .setConnectorConfiguration(null)
-                .setDiscoverySpi(disco);
-
-            try (Ignite ignite = G.start(cfg)) {
+            try (Ignite ignite = G.start(getConfiguration("verboseLogGrid", LOG_PATH_VERBOSE_TEST))) {
                 String testInfoMsg = "******* Hello Tester! INFO message *******";
                 String testDebugMsg = "******* Hello Tester! DEBUG message *******";
 
@@ -152,9 +141,12 @@ public class GridLog4j2SelfTest extends TestCase {
             }
         }
         finally {
+            System.setProperty("IGNITE_QUIET", "true");
+
             // Restore the stdout and write the String to stdout.
             System.setOut(backupSysOut);
 
+            System.out.println("***** It was at output *****");
             System.out.println(testOut.toString());
         }
     }
@@ -180,7 +172,7 @@ public class GridLog4j2SelfTest extends TestCase {
         String id8;
         File logFile;
 
-        try (Ignite ignite = G.start(getConfiguration("grid" + id))) {
+        try (Ignite ignite = G.start(getConfiguration("grid" + id, LOG_PATH_TEST))) {
             id8 = U.id8(ignite.cluster().localNode().id());
 
             String logPath = "work/log/ignite-" + id8 + ".log";
@@ -202,17 +194,23 @@ public class GridLog4j2SelfTest extends TestCase {
      * Creates grid configuration.
      *
      * @param gridName Grid name.
+     * @param logPath
      * @return Grid configuration.
      * @throws Exception If error occurred.
      */
-    private static IgniteConfiguration getConfiguration(String gridName)
+    private static IgniteConfiguration getConfiguration(String gridName, String logPath)
         throws Exception {
-        IgniteConfiguration cfg = new IgniteConfiguration();
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
 
-        cfg.setGridName(gridName);
+        disco.setIpFinder(new TcpDiscoveryVmIpFinder(false) {{
+            setAddresses(Collections.singleton("127.0.0.1:47500..47509"));
+        }});
 
-        cfg.setGridLogger(new Log4J2Logger(LOG_PATH_MAIN));
-        cfg.setConnectorConfiguration(null);
+        IgniteConfiguration cfg = new IgniteConfiguration()
+            .setGridName(gridName)
+            .setGridLogger(new Log4J2Logger(logPath))
+            .setConnectorConfiguration(null)
+            .setDiscoverySpi(disco);
 
         return cfg;
     }


[12/24] incubator-ignite git commit: # ignite-788: nodeId and fileName

Posted by sb...@apache.org.
# ignite-788: nodeId and fileName


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a04605a6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a04605a6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a04605a6

Branch: refs/heads/ignite-788-last-review
Commit: a04605a602b361f203ec5504f92b6734f551db2c
Parents: f524d3f
Author: ashutak <as...@gridgain.com>
Authored: Thu Jul 16 13:58:10 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Jul 16 13:58:10 2015 +0300

----------------------------------------------------------------------
 config/ignite-log4j.xml                         |  4 +-
 config/ignite-log4j2.xml                        | 12 ++--
 .../logger/log4j/Log4jRollingFileAppender.java  |  4 --
 .../ignite/logger/log4j2/Log4J2Logger.java      | 63 +++++++++++++-------
 .../log4j2/GridLog4j2CorrectFileNameTest.java   | 10 +++-
 .../log4j2/GridLog4j2InitiallizationTest.java   | 12 ++++
 6 files changed, 70 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a04605a6/config/ignite-log4j.xml
----------------------------------------------------------------------
diff --git a/config/ignite-log4j.xml b/config/ignite-log4j.xml
index 8dd114c..192e945 100644
--- a/config/ignite-log4j.xml
+++ b/config/ignite-log4j.xml
@@ -123,9 +123,9 @@
         <level value="INFO"/>
 
         <!-- Uncomment to enable logging to console. -->
-        <!--&lt;!&ndash;-->
+        <!--
         <appender-ref ref="CONSOLE"/>
-        <!--&ndash;&gt;-->
+        -->
 
         <appender-ref ref="CONSOLE_ERR"/>
         <appender-ref ref="FILE"/>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a04605a6/config/ignite-log4j2.xml
----------------------------------------------------------------------
diff --git a/config/ignite-log4j2.xml b/config/ignite-log4j2.xml
index c1393aa..3f7b3d5 100644
--- a/config/ignite-log4j2.xml
+++ b/config/ignite-log4j2.xml
@@ -27,11 +27,11 @@
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
         </Console>
 
-        <Routing name="Routing">
-            <Routes pattern="$${ctx:nodeId}">
+        <Routing name="FILE">
+            <Routes pattern="$${sys:nodeId}">
                 <Route>
-                    <RollingFile name="Rolling-${ctx:nodeId}" fileName="work/log/ignite-${ctx:nodeId}.log"
-                                 filePattern="work/log/ignite-${ctx:nodeId}-%i-%d{yyyy-MM-dd}.log.gz">
+                    <RollingFile name="Rolling-${sys:nodeId}" fileName="work/log/ignite-${sys:nodeId}.log"
+                                 filePattern="work/log/ignite-${sys:nodeId}-%i-%d{yyyy-MM-dd}.log.gz">
                         <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
                         <Policies>
                             <TimeBasedTriggeringPolicy interval="6" modulate="true" />
@@ -41,7 +41,7 @@
                 </Route>
 
                 <!--
-                <Route key="$${ctx:nodeId}">
+                <Route key="$${sys:nodeId}">
                     <RollingFile name="Rolling-default" fileName="work/log/ignite-default.log"
                                  filePattern="work/log/ignite-default-%i-%d{yyyy-MM-dd}.log.gz">
                         <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
@@ -87,7 +87,7 @@
             -->
 
             <AppenderRef ref="CONSOLE_ERR" level="ERROR"/>
-            <AppenderRef ref="Routing" level="DEBUG"/>
+            <AppenderRef ref="FILE" level="DEBUG"/>
         </Root>
     </Loggers>
 </Configuration>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a04605a6/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4jRollingFileAppender.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4jRollingFileAppender.java b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4jRollingFileAppender.java
index fbe3aab..dcf03a4 100644
--- a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4jRollingFileAppender.java
+++ b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4jRollingFileAppender.java
@@ -73,16 +73,12 @@ public class Log4jRollingFileAppender extends RollingFileAppender implements Log
 
     /** {@inheritDoc} */
     @Override public synchronized void updateFilePath(IgniteClosure<String, String> filePathClos) {
-        U.debug("**************** updateFilePath ************");
-
         A.notNull(filePathClos, "filePathClos");
 
         if (baseFileName == null)
             baseFileName = fileName;
 
         fileName = filePathClos.apply(baseFileName);
-
-        U.debug("**************** fileName=" + fileName + " appender=" + System.identityHashCode(this) + " ************");
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a04605a6/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index 0cfe485..5ccbc04 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -27,11 +27,13 @@ import org.apache.logging.log4j.*;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.*;
 import org.apache.logging.log4j.core.appender.*;
+import org.apache.logging.log4j.core.appender.routing.*;
 import org.apache.logging.log4j.core.config.*;
 import org.apache.logging.log4j.core.layout.*;
 import org.jetbrains.annotations.*;
 
 import java.io.*;
+import java.lang.reflect.*;
 import java.net.*;
 import java.util.*;
 
@@ -67,7 +69,11 @@ import static org.apache.ignite.IgniteSystemProperties.*;
  * injection.
  */
 public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
-    public static final String LOGGER_NAME = "Log4J2Logger";
+    /** */
+    // TODO review.
+    public static final String LOGGER_NAME = LogManager.ROOT_LOGGER_NAME;
+
+    /** */
     public static final String NODE_ID = "nodeId";
 
     /** */
@@ -172,7 +178,6 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
-                    // TODO review
                     Configurator.initialize(LOGGER_NAME, cfgUrl.toString());
 
                 return LogManager.getRootLogger();
@@ -188,7 +193,6 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
      * @param cfgFile Log4j configuration XML file.
      * @throws IgniteCheckedException Thrown in case logger can't be created.
      */
-    // TODO create test
     public Log4J2Logger(File cfgFile) throws IgniteCheckedException {
         if (cfgFile == null)
             throw new IgniteCheckedException("Configuration XML file for Log4j must be specified.");
@@ -216,7 +220,6 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
      * @param cfgUrl URL for Log4j configuration XML file.
      * @throws IgniteCheckedException Thrown in case logger can't be created.
      */
-    // TODO test it.
     public Log4J2Logger(final URL cfgUrl) throws IgniteCheckedException {
         if (cfgUrl == null)
             throw new IgniteCheckedException("Configuration XML file for Log4j must be specified.");
@@ -262,24 +265,40 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
 
     /** {@inheritDoc} */
     @Nullable @Override public String fileName() {
-        // TODO
-        // It was.
-//        FileAppender fapp = F.first(fileAppenders);
-//
-//        return fapp != null ? fapp.getFile() : null;
+        for (org.apache.logging.log4j.core.Logger log = (org.apache.logging.log4j.core.Logger)impl;
+            log != null; log = log.getParent()) {
+            for (Appender a : log.getAppenders().values()) {
+                if (a instanceof FileAppender)
+                    return ((FileAppender)a).getFileName();
+
+                if (a instanceof RollingFileAppender)
+                    return ((RollingFileAppender)a).getFileName();
+
+                if (a instanceof RoutingAppender) {
+                    try {
+                        RoutingAppender routing = (RoutingAppender)a;
+
+                        Field appsFiled = routing.getClass().getDeclaredField("appenders");
 
-        // New logic.
-        // TODO cast, RollingFileAppender and etc.
-        org.apache.logging.log4j.core.Logger logImpl = (org.apache.logging.log4j.core.Logger)impl;
+                        appsFiled.setAccessible(true);
 
-        Collection<Appender> appenders = logImpl.getAppenders().values();
+                        Map<String, AppenderControl> appenders = (Map<String, AppenderControl>)appsFiled.get(routing);
 
-        for (Appender a : appenders) {
-            if (a instanceof FileAppender)
-                return ((FileAppender)a).getFileName();
+                        for (AppenderControl control : appenders.values()) {
+                            Appender innerApp = control.getAppender();
 
-            if (a instanceof RollingFileAppender)
-                return ((RollingFileAppender)a).getFileName();
+                            if (innerApp instanceof FileAppender)
+                                return ((FileAppender)innerApp).getFileName();
+
+                            if (innerApp instanceof RollingFileAppender)
+                                return ((RollingFileAppender)innerApp).getFileName();
+                        }
+                    }
+                    catch (IllegalAccessException | NoSuchFieldException e) {
+                        error("Faild to get file name. Looks like the implementation of log4j 2 was changed.", e);
+                    }
+                }
+            }
         }
 
         return null;
@@ -421,10 +440,14 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
 
         this.nodeId = nodeId;
 
-        // Set nodeId at context to be used at configuration.
-        ThreadContext.put(NODE_ID, U.id8(nodeId));
+        // Set nodeId as system variable to be used at configuration.
+        System.setProperty("nodeId", U.id8(nodeId));
 
         ((LoggerContext) LogManager.getContext(false)).reconfigure();
+
+        // Hack. To touch the logger to create all log resources (files). Then #fileName() will work properly.
+        // TODO review it
+        impl.log(Level.OFF, "");
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a04605a6/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
index 7a968d4..2d8ee82 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
@@ -48,13 +48,17 @@ public class GridLog4j2CorrectFileNameTest extends TestCase {
      * @throws Exception If error occurred.
      */
     private void checkOneNode(int id) throws Exception {
-        String id8 = null;
-        
+        String id8;
+        String logPath;
+
         try (Ignite ignite = G.start(getConfiguration("grid" + id))) {
             id8 = U.id8(ignite.cluster().localNode().id());
+
+            logPath = "work/log/ignite-" + id8 + ".log";
+
+            assertEquals(logPath, ignite.log().fileName());
         }
 
-        String logPath = "work/log/ignite-" + id8 + ".log";
         File logFile = U.resolveIgnitePath(logPath);
 
         assertNotNull("Failed to resolve path: " + logPath, logFile);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a04605a6/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java
index c2fb7ca..734ca6d 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitiallizationTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.logger.log4j2;
 
 import junit.framework.*;
 import org.apache.ignite.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.logger.*;
 import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
@@ -91,4 +92,15 @@ public class GridLog4j2InitiallizationTest extends TestCase {
         log.error("This is 'error' message.");
         log.error("This is 'error' message.", new Exception("It's a test error exception"));
     }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testSystemNodeId() throws Exception {
+        UUID id = UUID.randomUUID();
+
+        new Log4J2Logger().setNodeId(id);
+
+        assertEquals(U.id8(id), System.getProperty("nodeId"));
+    }
 }


[15/24] incubator-ignite git commit: # ignite-788: add console appender

Posted by sb...@apache.org.
# ignite-788: add console appender


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/4b6dd06e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4b6dd06e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4b6dd06e

Branch: refs/heads/ignite-788-last-review
Commit: 4b6dd06ea7cb0eac3dd7c6a07a88411f36ddd072
Parents: b75c24b
Author: ashutak <as...@gridgain.com>
Authored: Thu Jul 16 19:21:03 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Jul 16 19:21:03 2015 +0300

----------------------------------------------------------------------
 .../ignite/logger/log4j2/ContextTestTmp.java    | 117 +++++++++++++++++++
 1 file changed, 117 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b6dd06e/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
new file mode 100644
index 0000000..88540f0
--- /dev/null
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
@@ -0,0 +1,117 @@
+/*
+ * 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.logger.log4j2;
+
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.logging.log4j.*;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.*;
+import org.apache.logging.log4j.core.appender.*;
+import org.apache.logging.log4j.core.config.*;
+import org.apache.logging.log4j.core.layout.*;
+
+import java.net.*;
+
+/**
+ * TODO: Add class description.
+ */
+public class ContextTestTmp {
+    public static final String CONSOLE_APPENDER = "consoleAppender";
+    public static final String CONSOLE_CTX = "consoleContext";
+    public static final String CONSOLE_LOG = "consoleLogger";
+
+    public static void main(String[] args) throws Exception {
+        final Level maxLevel = Level.DEBUG;
+
+        final URL cfgUrl = U.resolveIgniteUrl("config/ignite-log4j2.xml");
+
+        Configurator.initialize(LogManager.ROOT_LOGGER_NAME, cfgUrl.toString());
+
+        addConsoleAppender(LogManager.getRootLogger(), Level.INFO);
+//
+//        logTest();
+
+//        Appender appender = FileAppender.createAppender(U.getIgniteHome() + "/work/log/test.log", "false", "false", "File", "true",
+//            "false", "false", "4000", PatternLayout.createDefaultLayout(), null, "false", null,
+//            ((LoggerContext) LogManager.getContext(false)).getConfiguration());
+//
+//        addAppender(LogManager.getRootLogger(), appender, Level.INFO);
+
+        System.out.println(((org.apache.logging.log4j.core.Logger)LogManager.getRootLogger()).getAppenders());
+
+        logTest();
+    }
+
+    private static void logTest() {
+        LogManager.getRootLogger().log(Level.OFF, "*******************");
+        LogManager.getRootLogger().log(Level.FATAL, "*******************");
+        LogManager.getRootLogger().log(Level.ERROR, "*******************");
+        LogManager.getRootLogger().log(Level.WARN, "*******************");
+        LogManager.getRootLogger().log(Level.INFO, "*******************");
+        LogManager.getRootLogger().log(Level.DEBUG, "*******************");
+        LogManager.getRootLogger().log(Level.TRACE, "*******************");
+        LogManager.getRootLogger().log(Level.ALL, "*******************");
+    }
+
+    private static void addConsoleAppender(final Logger logger, final Level maxLevel) {
+        ConsoleAppender appender = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
+            "SYSTEM_OUT", CONSOLE_APPENDER, null, null);
+
+        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+
+        final Configuration cfg = ctx.getConfiguration();
+
+        appender.start();
+
+        cfg.addAppender(appender);
+
+        LoggerConfig loggerConfig = cfg.getLoggerConfig(logger.getName());
+
+        AppenderRef ref = AppenderRef.createAppenderRef(CONSOLE_APPENDER, maxLevel, null);
+
+        loggerConfig.getAppenderRefs().add(ref);
+
+        loggerConfig.addAppender(appender, maxLevel, null);
+
+        cfg.addLogger(logger.getName(), loggerConfig);
+
+        ctx.updateLoggers();
+    }
+
+    private static void addAppender(final Logger logger, Appender appender, final Level maxLevel) {
+        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+
+        final Configuration cfg = ctx.getConfiguration();
+
+        appender.start();
+
+        cfg.addAppender(appender);
+
+        LoggerConfig loggerConfig = cfg.getLoggerConfig(logger.getName());
+
+        AppenderRef ref = AppenderRef.createAppenderRef("File", maxLevel, null);
+
+        loggerConfig.getAppenderRefs().add(ref);
+
+        loggerConfig.addAppender(appender, maxLevel, null);
+
+        cfg.addLogger(logger.getName(), loggerConfig);
+
+        ctx.updateLoggers();
+    }
+}


[03/24] incubator-ignite git commit: # ignite-788: constructors

Posted by sb...@apache.org.
# ignite-788: constructors


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/d7f3588d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d7f3588d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d7f3588d

Branch: refs/heads/ignite-788-last-review
Commit: d7f3588ddd249252a4ecaab9e346c7fd46b8d0de
Parents: 649c781
Author: ashutak <as...@gridgain.com>
Authored: Tue Jul 14 19:00:26 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Tue Jul 14 19:00:26 2015 +0300

----------------------------------------------------------------------
 .../ignite/logger/log4j2/Log4J2Logger.java      | 43 ++++++++++++++------
 1 file changed, 30 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d7f3588d/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index 9a6f424..45898ad 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -24,6 +24,12 @@ import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.logger.*;
+import org.apache.logging.log4j.*;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.*;
+import org.apache.logging.log4j.core.appender.*;
+import org.apache.logging.log4j.core.config.*;
+import org.apache.logging.log4j.core.layout.*;
 import org.jetbrains.annotations.*;
 
 import java.io.*;
@@ -92,9 +98,9 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
      * Creates new logger and automatically detects if root logger already
      * has appenders configured. If it does not, the root logger will be
      * configured with default appender (analogous to calling
-     * {@link #Log4J2Logger(boolean) Log4JLogger(boolean)}
+     * {@link #Log4J2Logger(boolean) Log4J2Logger(boolean)}
      * with parameter {@code true}, otherwise, existing appenders will be used (analogous
-     * to calling {@link #Log4J2Logger(boolean) Log4JLogger(boolean)}
+     * to calling {@link #Log4J2Logger(boolean) Log4J2Logger(boolean)}
      * with parameter {@code false}).
      */
     public Log4J2Logger() {
@@ -113,7 +119,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
      *      constructor.
      */
     public Log4J2Logger(boolean init) {
-        impl = Logger.getRootLogger();
+        impl = LogManager.getRootLogger();
 
         if (init) {
             // Implementation has already been inited, passing NULL.
@@ -166,9 +172,10 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
         addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
-                    DOMConfigurator.configure(cfgUrl);
+                    // TODO review
+                    Configurator.initialize("Log4J2Logger", cfgUrl.toString());
 
-                return Logger.getRootLogger();
+                return LogManager.getRootLogger();
             }
         });
 
@@ -181,6 +188,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
      * @param cfgFile Log4j configuration XML file.
      * @throws IgniteCheckedException Thrown in case logger can't be created.
      */
+    // TODO create test
     public Log4J2Logger(File cfgFile) throws IgniteCheckedException {
         if (cfgFile == null)
             throw new IgniteCheckedException("Configuration XML file for Log4j must be specified.");
@@ -188,14 +196,21 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
         if (!cfgFile.exists() || cfgFile.isDirectory())
             throw new IgniteCheckedException("Log4j configuration path was not found or is a directory: " + cfgFile);
 
-        path = cfgFile.getAbsolutePath();
+        final String uri;
+
+        try {
+            uri = cfgFile.toURI().toURL().toString();
+        }
+        catch (MalformedURLException e) {
+            throw new IgniteCheckedException(e.toString());
+        }
 
         addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
-                    DOMConfigurator.configure(path);
+                    Configurator.initialize("Log4J2Logger", uri);
 
-                return Logger.getRootLogger();
+                return LogManager.getRootLogger();
             }
         });
 
@@ -208,6 +223,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
      * @param cfgUrl URL for Log4j configuration XML file.
      * @throws IgniteCheckedException Thrown in case logger can't be created.
      */
+    // TODO test it.
     public Log4J2Logger(final URL cfgUrl) throws IgniteCheckedException {
         if (cfgUrl == null)
             throw new IgniteCheckedException("Configuration XML file for Log4j must be specified.");
@@ -217,9 +233,9 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
         addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
-                    DOMConfigurator.configure(cfgUrl);
+                    Configurator.initialize("Log4J2Logger", cfgUrl.toString());
 
-                return Logger.getRootLogger();
+                return LogManager.getRootLogger();
             }
         });
 
@@ -227,12 +243,13 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
     }
 
     /**
-     * Checks if Log4j is already configured within this VM or not.
+     * Checks if Log4j2 is already configured within this VM or not.
      *
-     * @return {@code True} if log4j was already configured, {@code false} otherwise.
+     * @return {@code True} if log4j2 was already configured, {@code false} otherwise.
      */
+    // TODO review
     public static boolean isConfigured() {
-        return Logger.getRootLogger().getAllAppenders().hasMoreElements();
+        return LogManager.getLogger("Log4J2Logger") != null;
     }
 
     /**


[09/24] incubator-ignite git commit: # ignite-788: fix pom version

Posted by sb...@apache.org.
# ignite-788: fix pom version


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/6932017b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/6932017b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/6932017b

Branch: refs/heads/ignite-788-last-review
Commit: 6932017b03934318fa7116ef9ebd20a89d9d6fed
Parents: a679ff9
Author: ashutak <as...@gridgain.com>
Authored: Wed Jul 15 19:34:37 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Jul 15 19:34:37 2015 +0300

----------------------------------------------------------------------
 modules/log4j2/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6932017b/modules/log4j2/pom.xml
----------------------------------------------------------------------
diff --git a/modules/log4j2/pom.xml b/modules/log4j2/pom.xml
index d4072f4..58dc05e 100644
--- a/modules/log4j2/pom.xml
+++ b/modules/log4j2/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-log4j2</artifactId>
-    <version>1.2.1-SNAPSHOT</version>
+    <version>1.4.1-SNAPSHOT</version>
 
     <dependencies>
         <dependency>


[24/24] incubator-ignite git commit: Merge branch 'master' into ignite-788

Posted by sb...@apache.org.
Merge branch 'master' into ignite-788


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/83e0a689
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/83e0a689
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/83e0a689

Branch: refs/heads/ignite-788-last-review
Commit: 83e0a68937b26ad2981effd96d6e064c2f920ec7
Parents: 0b36f4f 3194415
Author: ashutak <as...@gridgain.com>
Authored: Mon Jul 20 17:52:21 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Mon Jul 20 17:52:21 2015 +0300

----------------------------------------------------------------------
 DEVNOTES.txt                                    |    8 +
 RELEASE_NOTES.txt                               |    2 +
 assembly/LICENSE_FABRIC                         |  306 +++++
 assembly/LICENSE_HADOOP                         |  259 ++++
 assembly/NOTICE_FABRIC                          |   13 +
 assembly/NOTICE_HADOOP                          |   12 +
 assembly/dependencies-fabric.xml                |   13 +
 assembly/dependencies-hadoop.xml                |   12 +
 assembly/dependencies-visor-console.xml         |   20 +-
 assembly/release-base.xml                       |   10 -
 assembly/release-fabric.xml                     |   12 +
 assembly/release-hadoop.xml                     |   12 +
 modules/aop/licenses/aspectj-epl-license.txt    |   69 -
 modules/apache-license-gen/pom.xml              |   48 +
 .../src/main/resources/META-INF/licenses.txt.vm |   42 +
 modules/core/licenses/jsr166-license.txt        |    3 +
 modules/core/licenses/snaptree-bsd-license.txt  |    2 +-
 .../IgniteClientDisconnectedException.java      |   61 +
 .../java/org/apache/ignite/IgniteCluster.java   |    8 +
 .../apache/ignite/cache/CacheTypeMetadata.java  |   53 +-
 .../ignite/compute/ComputeJobResultPolicy.java  |    3 +-
 .../apache/ignite/internal/GridComponent.java   |   18 +
 .../ignite/internal/GridJobSiblingImpl.java     |    2 +-
 .../ignite/internal/GridKernalContext.java      |    5 +
 .../ignite/internal/GridKernalContextImpl.java  |   31 +-
 .../ignite/internal/GridKernalGateway.java      |   46 +-
 .../ignite/internal/GridKernalGatewayImpl.java  |   85 +-
 .../apache/ignite/internal/GridKernalState.java |    3 +
 .../ignite/internal/GridPluginComponent.java    |   11 +
 ...gniteClientDisconnectedCheckedException.java |   49 +
 .../apache/ignite/internal/IgniteKernal.java    |  234 +++-
 .../cluster/IgniteClusterAsyncImpl.java         |    5 +
 .../internal/cluster/IgniteClusterImpl.java     |   18 +
 .../internal/managers/GridManagerAdapter.java   |   19 +-
 .../deployment/GridDeploymentCommunication.java |    2 +-
 .../deployment/GridDeploymentManager.java       |   95 +-
 .../discovery/GridDiscoveryManager.java         |  188 ++-
 .../failover/GridFailoverContextImpl.java       |   28 +-
 .../managers/failover/GridFailoverManager.java  |   13 +-
 .../processors/GridProcessorAdapter.java        |   11 +
 .../affinity/GridAffinityAssignmentCache.java   |   26 +-
 .../cache/CacheOsConflictResolutionManager.java |    6 +
 .../cache/DynamicCacheChangeBatch.java          |   17 +
 .../processors/cache/GridCacheAdapter.java      |   27 +-
 .../cache/GridCacheAffinityManager.java         |   21 +-
 .../cache/GridCacheConcurrentMap.java           |   15 +-
 .../processors/cache/GridCacheContext.java      |   45 +-
 .../processors/cache/GridCacheGateway.java      |  116 +-
 .../processors/cache/GridCacheIoManager.java    |    8 +
 .../processors/cache/GridCacheManager.java      |    6 +
 .../cache/GridCacheManagerAdapter.java          |    6 +
 .../processors/cache/GridCacheMvccManager.java  |   43 +-
 .../GridCachePartitionExchangeManager.java      |  134 +-
 .../processors/cache/GridCachePreloader.java    |    5 +
 .../cache/GridCachePreloaderAdapter.java        |    5 +
 .../processors/cache/GridCacheProcessor.java    |  311 ++++-
 .../cache/GridCacheSharedContext.java           |  113 +-
 .../cache/GridCacheSharedManager.java           |   11 +-
 .../cache/GridCacheSharedManagerAdapter.java    |   20 +-
 .../processors/cache/GridCacheUtils.java        |    9 +
 .../processors/cache/IgniteCacheFutureImpl.java |   11 +
 .../processors/cache/IgniteCacheProxy.java      |   59 +-
 .../processors/cache/IgniteInternalCache.java   |    1 +
 .../CacheDataStructuresManager.java             |   35 +
 .../distributed/GridCacheTxFinishSync.java      |   46 +
 .../distributed/dht/GridDhtCacheAdapter.java    |   14 +-
 .../dht/GridDhtPartitionTopologyImpl.java       |   24 +
 .../distributed/dht/GridDhtTopologyFuture.java  |   14 -
 .../distributed/dht/GridDhtTxPrepareFuture.java |    9 +-
 .../dht/GridPartitionedGetFuture.java           |   13 +-
 .../dht/atomic/GridDhtAtomicCache.java          |    6 +-
 .../dht/atomic/GridNearAtomicUpdateFuture.java  |   31 +-
 .../GridDhtPartitionsExchangeFuture.java        |   31 +-
 .../dht/preloader/GridDhtPreloader.java         |   16 +-
 .../distributed/near/GridNearCacheAdapter.java  |    8 +
 .../distributed/near/GridNearGetFuture.java     |   13 +-
 .../cache/dr/GridOsCacheDrManager.java          |    7 +-
 .../query/GridCacheDistributedQueryManager.java |   22 +
 .../cache/query/GridCacheQueryAdapter.java      |   11 +-
 .../query/GridCacheQueryFutureAdapter.java      |    2 +-
 .../continuous/CacheContinuousQueryHandler.java |    5 +
 .../transactions/IgniteTransactionsImpl.java    |   59 +-
 .../cache/transactions/IgniteTxManager.java     |   23 +-
 .../transactions/TransactionProxyImpl.java      |    2 +-
 .../cache/version/GridCacheVersionManager.java  |    9 +-
 .../clock/GridClockSyncProcessor.java           |    6 +-
 .../processors/closure/AffinityTask.java        |   35 +
 .../closure/GridClosureProcessor.java           |   63 +-
 .../processors/cluster/ClusterProcessor.java    |   11 +
 .../continuous/GridContinuousHandler.java       |    9 +-
 .../continuous/GridContinuousProcessor.java     |  127 +-
 .../datastreamer/DataStreamProcessor.java       |   24 +-
 .../datastreamer/DataStreamerImpl.java          |   90 +-
 .../datastructures/DataStructuresProcessor.java |   33 +-
 .../datastructures/GridCacheAtomicLongImpl.java |   33 +-
 .../GridCacheAtomicReferenceImpl.java           |   34 +-
 .../GridCacheAtomicSequenceImpl.java            |   33 +-
 .../GridCacheAtomicStampedImpl.java             |   33 +-
 .../GridCacheCountDownLatchImpl.java            |   51 +-
 .../datastructures/GridCacheRemovable.java      |    6 +-
 .../datastructures/GridCacheSetImpl.java        |   15 +-
 .../datastructures/GridCacheSetProxy.java       |   47 +-
 .../processors/job/GridJobProcessor.java        |    2 +-
 .../internal/processors/job/GridJobWorker.java  |    2 +-
 .../processors/query/GridQueryIndexing.java     |    7 +
 .../processors/query/GridQueryProcessor.java    |   10 +-
 .../service/GridServiceProcessor.java           |   45 +-
 .../processors/service/GridServiceProxy.java    |   13 +-
 .../processors/task/GridTaskProcessor.java      |   55 +-
 .../processors/task/GridTaskWorker.java         |   83 +-
 .../ignite/internal/util/IgniteUtils.java       |   30 +-
 .../util/future/GridFutureChainListener.java    |    4 -
 .../internal/util/future/IgniteFutureImpl.java  |   12 +-
 .../shmem/IpcSharedMemoryClientEndpoint.java    |    5 +-
 .../ignite/internal/util/lang/GridFunc.java     |    2 +
 .../plugin/security/SecurityPermission.java     |    7 +-
 .../plugin/security/SecuritySubjectType.java    |    3 +-
 .../java/org/apache/ignite/spi/IgniteSpi.java   |   15 +
 .../org/apache/ignite/spi/IgniteSpiAdapter.java |   51 +-
 .../communication/tcp/TcpCommunicationSpi.java  |  356 ++++--
 .../spi/discovery/DiscoverySpiDataExchange.java |    3 +-
 .../ignite/spi/discovery/tcp/ClientImpl.java    |  408 ++++--
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  177 ++-
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     |    9 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |   33 +-
 .../tcp/internal/TcpDiscoveryNode.java          |   19 +
 .../messages/TcpDiscoveryAbstractMessage.java   |    3 +
 .../messages/TcpDiscoveryClientAckResponse.java |   64 +
 .../messages/TcpDiscoveryHandshakeResponse.java |   14 +
 .../ignite/spi/failover/FailoverContext.java    |   18 +
 .../spi/failover/always/AlwaysFailoverSpi.java  |   25 +
 .../spi/swapspace/file/FileSwapSpaceSpi.java    |    2 +-
 .../internal/GridUpdateNotifierSelfTest.java    |   15 +-
 .../IgniteClientReconnectAbstractTest.java      |  363 ++++++
 .../IgniteClientReconnectApiExceptionTest.java  |  846 ++++++++++++
 .../IgniteClientReconnectAtomicsTest.java       |  672 ++++++++++
 .../IgniteClientReconnectCacheTest.java         | 1202 ++++++++++++++++++
 .../IgniteClientReconnectCollectionsTest.java   |  443 +++++++
 .../IgniteClientReconnectComputeTest.java       |  192 +++
 ...eClientReconnectContinuousProcessorTest.java |  372 ++++++
 ...IgniteClientReconnectDiscoveryStateTest.java |  123 ++
 ...niteClientReconnectFailoverAbstractTest.java |  231 ++++
 .../IgniteClientReconnectFailoverTest.java      |  227 ++++
 .../IgniteClientReconnectServicesTest.java      |  260 ++++
 .../internal/IgniteClientReconnectStopTest.java |  106 ++
 .../IgniteClientReconnectStreamerTest.java      |  233 ++++
 .../IgniteSlowClientDetectionSelfTest.java      |    1 +
 .../GridDeploymentManagerStopSelfTest.java      |    7 +
 .../cache/CacheAffinityCallSelfTest.java        |  172 +++
 .../cache/GridCacheAbstractFullApiSelfTest.java |   32 +
 .../cache/GridCacheAffinityRoutingSelfTest.java |  157 ++-
 .../IgniteCacheAbstractStopBusySelfTest.java    |    2 +-
 .../cache/IgniteCacheDynamicStopSelfTest.java   |    6 +-
 .../cache/IgniteCacheNearLockValueSelfTest.java |    2 +
 .../IgniteTxExceptionAbstractSelfTest.java      |    1 +
 .../GridCacheAbstractNodeRestartSelfTest.java   |   12 +-
 .../distributed/IgniteCache150ClientsTest.java  |    1 +
 .../IgniteCacheClientReconnectTest.java         |  175 +++
 .../IgniteCacheServerNodeConcurrentStart.java   |   96 ++
 .../IgniteCacheSystemTransactionsSelfTest.java  |    2 +-
 .../IgniteCachePutRetryAbstractSelfTest.java    |   52 +-
 ...gniteCachePutRetryTransactionalSelfTest.java |   17 +-
 ...eAtomicInvalidPartitionHandlingSelfTest.java |    2 +-
 ...achePartitionedMultiNodeFullApiSelfTest.java |    4 +-
 .../GridCacheReplicatedInvalidateSelfTest.java  |    3 +-
 ...acheAtomicReplicatedNodeRestartSelfTest.java |   14 +-
 .../loadtests/hashmap/GridCacheTestContext.java |    4 +-
 .../tcp/TcpClientDiscoverySpiSelfTest.java      |  562 +++++++-
 .../tcp/TcpDiscoveryMultiThreadedTest.java      |  140 +-
 .../spi/failover/GridFailoverTestContext.java   |   10 +
 .../testframework/junits/GridAbstractTest.java  |    5 +
 .../multijvm/IgniteClusterProcessProxy.java     |    5 +
 .../ignite/testsuites/IgniteCacheTestSuite.java |    1 +
 .../testsuites/IgniteCacheTestSuite2.java       |    2 +-
 .../testsuites/IgniteCacheTestSuite4.java       |    2 -
 .../testsuites/IgniteClientNodesTestSuite.java  |   42 +
 .../IgniteClientReconnectTestSuite.java         |   48 +
 .../geospatial/licenses/jts-lgpl-license.txt    |  165 ---
 .../licenses/hibernate-lgpl-2.1-license.txt     |  174 ---
 modules/indexing/licenses/h2-epl-license.txt    |   69 -
 .../processors/query/h2/IgniteH2Indexing.java   |    5 +
 .../query/h2/twostep/GridMergeIndex.java        |   45 +-
 .../h2/twostep/GridReduceQueryExecutor.java     |   70 +-
 ...ClientReconnectCacheQueriesFailoverTest.java |  225 ++++
 .../cache/IgniteClientReconnectQueriesTest.java |  427 +++++++
 ...dCacheAbstractReduceFieldsQuerySelfTest.java |    4 +
 .../IgniteCacheWithIndexingTestSuite.java       |    1 +
 modules/jta/licenses/jta-license.txt            |    2 +
 modules/mesos/licenses/jetty-epl-license.txt    |   69 -
 modules/mesos/pom.xml                           |    1 +
 .../apache/ignite/mesos/ClusterProperties.java  |   14 +
 .../apache/ignite/mesos/IgniteScheduler.java    |   26 +-
 modules/rest-http/pom.xml                       |    6 +-
 .../scalar-2.10/licenses/scala-bsd-license.txt  |   18 -
 modules/scalar/licenses/scala-bsd-license.txt   |   18 -
 .../licenses/cron4j-lgpl-2.1-license.txt        |  174 ---
 .../ignite/schema/ui/SchemaImportApp.java       |   36 +-
 modules/slf4j/licenses/sl4j-mit-license.txt     |   21 -
 .../spark-2.10/licenses/scala-bsd-license.txt   |   18 -
 modules/spark/licenses/scala-bsd-license.txt    |   18 -
 .../apache/ignite/cache/spring/SpringCache.java |    2 +-
 .../ignite/cache/spring/SpringCacheManager.java |   22 +-
 modules/ssh/licenses/jcraft-revised-bsd.txt     |   28 -
 modules/tools/licenses/jodd-revised-bsd.txt     |   21 -
 .../urideploy/licenses/jtidy-mit-license.txt    |   50 -
 modules/urideploy/pom.xml                       |    6 +-
 .../licenses/jline-bsd-license.txt              |   18 -
 .../licenses/scala-bsd-license.txt              |   18 -
 .../licenses/slf4j-mit-license.txt              |   21 -
 modules/web/pom.xml                             |    6 +-
 modules/yarn/README.txt                         |   28 +
 modules/yarn/licenses/apache-2.0.txt            |  202 +++
 modules/yarn/pom.xml                            |  101 ++
 .../apache/ignite/yarn/ApplicationMaster.java   |  400 ++++++
 .../apache/ignite/yarn/ClusterProperties.java   |  432 +++++++
 .../org/apache/ignite/yarn/IgniteContainer.java |   84 ++
 .../org/apache/ignite/yarn/IgniteProvider.java  |  339 +++++
 .../apache/ignite/yarn/IgniteYarnClient.java    |  178 +++
 .../org/apache/ignite/yarn/package-info.java    |   22 +
 .../ignite/yarn/utils/IgniteYarnUtils.java      |   81 ++
 .../main/resources/ignite-default-config.xml    |   35 +
 .../org/apache/ignite/IgniteYarnTestSuite.java  |   38 +
 .../yarn/IgniteApplicationMasterSelfTest.java   |  532 ++++++++
 parent/pom.xml                                  |   55 +
 pom.xml                                         |    4 +-
 225 files changed, 14448 insertions(+), 2118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/83e0a689/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/83e0a689/pom.xml
----------------------------------------------------------------------


[06/24] incubator-ignite git commit: # ignite-788: rolling file configuration

Posted by sb...@apache.org.
# ignite-788: rolling file configuration


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/630439f8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/630439f8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/630439f8

Branch: refs/heads/ignite-788-last-review
Commit: 630439f8395041fa31aaab1efd0e434d60a8e0ec
Parents: 9af04af
Author: ashutak <as...@gridgain.com>
Authored: Wed Jul 15 17:46:33 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Jul 15 17:46:33 2015 +0300

----------------------------------------------------------------------
 config/ignite-log4j2.xml | 34 ++++++++++++++++------------------
 1 file changed, 16 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/630439f8/config/ignite-log4j2.xml
----------------------------------------------------------------------
diff --git a/config/ignite-log4j2.xml b/config/ignite-log4j2.xml
index 02dc95b..4ada9ff 100644
--- a/config/ignite-log4j2.xml
+++ b/config/ignite-log4j2.xml
@@ -17,7 +17,7 @@
   limitations under the License.
 -->
 
-<Configuration status="info">
+<Configuration status="trace">
     <Appenders>
         <Console name="CONSOLE_ERR" target="SYSTEM_ERR">
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
@@ -26,26 +26,24 @@
         <!--TODO-->
         <!--<param name="MaxFileSize" value="10MB"/>-->
         <!--<param name="MaxBackupIndex" value="10"/>-->
-        <File name="FILE" fileName="${IGNITE_HOME}/work/log/ignite.log" append="true">
-            <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
-        </File>
+        <RollingFile name="FILE" fileName="work/log/ignite-id.log"
+                     filePattern="work/log/$${date:yyyy-MM}/ignite-%d{MM-dd-yyyy}-%i.log.gz">
+            <PatternLayout>
+                <pattern>[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n</pattern>
+            </PatternLayout>
+            <Policies>
+                <TimeBasedTriggeringPolicy />
+                <SizeBasedTriggeringPolicy size="250 MB"/>
+            </Policies>
+        </RollingFile>
     </Appenders>
 
     <Loggers>
-        <!--<Logger name="org.springframework" level="WARN">-->
-        <!--</Logger>-->
-
-        <!--<Logger name="org.eclipse.jetty" level="WARN">-->
-        <!--</Logger>-->
-
-        <!--<Logger name="org.eclipse.jetty.util.log" level="ERROR">-->
-        <!--</Logger>-->
-
-        <!--<Logger name="org.eclipse.jetty.util.component" level="ERROR">-->
-        <!--</Logger>-->
-
-        <!--<Logger name="com.amazonaws" level="WARN">-->
-        <!--</Logger>-->
+        <Logger name="org.springframework" level="WARN"/>
+        <Logger name="org.eclipse.jetty" level="WARN"/>
+        <Logger name="org.eclipse.jetty.util.log" level="ERROR"/>
+        <Logger name="org.eclipse.jetty.util.component" level="ERROR"/>
+        <Logger name="com.amazonaws" level="WARN"/>
 
         <Root level="INFO">
             <AppenderRef ref="CONSOLE_ERR"/>


[21/24] incubator-ignite git commit: # ignite-788: refactor

Posted by sb...@apache.org.
# ignite-788: refactor


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/8ed4c2f8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/8ed4c2f8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/8ed4c2f8

Branch: refs/heads/ignite-788-last-review
Commit: 8ed4c2f873865c23bf40ee0fa2b8d1b46d58cd09
Parents: 5dc5e39
Author: ashutak <as...@gridgain.com>
Authored: Fri Jul 17 20:31:39 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Fri Jul 17 20:31:39 2015 +0300

----------------------------------------------------------------------
 .../ignite/logger/log4j2/Log4J2Logger.java      | 86 ++++++++++++--------
 1 file changed, 51 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8ed4c2f8/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index 48cfef0..c785c34 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -90,7 +90,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
     private Logger impl;
 
-    private volatile Logger consoleLogger;
+    private volatile Logger consoleLog;
 
     /** Quiet flag. */
     private final boolean quiet;
@@ -102,17 +102,12 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
      * Creates new logger with given implementation.
      *
      * @param impl Log4j implementation to use.
-     * @param consoleLogger
+     * @param consoleLog Cosole logger (optional).
      */
-    public Log4J2Logger(final Logger impl, Logger consoleLogger) {
+    private Log4J2Logger(final Logger impl, @Nullable final Logger consoleLog) {
         assert impl != null;
-        this.consoleLogger = consoleLogger;
-
-        addConsoleAppenderIfNeeded(new C1<Boolean, Logger>() {
-            @Override public Logger apply(Boolean init) {
-                return impl;
-            }
-        });
+        this.impl = impl;
+        this.consoleLog = consoleLog;
 
         quiet = quiet0;
     }
@@ -255,25 +250,22 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
      */
     private void addConsoleAppenderIfNeeded(@Nullable IgniteClosure<Boolean, Logger> initLogClo) {
         if (inited) {
-            if (initLogClo != null)
-                // Do not init.
-                impl = initLogClo.apply(false);
+            // Do not init.
+            impl = initLogClo.apply(false);
 
             return;
         }
 
         synchronized (mux) {
             if (inited) {
-                if (initLogClo != null)
-                    // Do not init.
-                    impl = initLogClo.apply(false);
+                // Do not init.
+                impl = initLogClo.apply(false);
 
                 return;
             }
 
-            if (initLogClo != null)
-                // Init logger impl.
-                impl = initLogClo.apply(true);
+            // Init logger impl.
+            impl = initLogClo.apply(true);
 
             boolean quiet = Boolean.valueOf(System.getProperty(IGNITE_QUIET, "true"));
 
@@ -319,14 +311,14 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
                 // User launched ignite in verbose mode and did not add console appender with INFO level
                 // to configuration and did not set IGNITE_CONSOLE_APPENDER to false.
                 if (errAppender != null) {
-                    consoleLogger = createConsoleLogger(rootLogger, Level.ALL);
+                    consoleLog = createConsoleLogger(rootLogger, Level.TRACE);
 
 //                    if (errAppender.getThreshold() == Level.ERROR)
 //                        errAppender.setThreshold(Level.WARN);
                 }
                 else
                     // No error console appender => create console appender with no level limit.
-                    consoleLogger = createConsoleLogger(rootLogger, Level.INFO);
+                    consoleLog = createConsoleLogger(rootLogger, Level.INFO);
             }
 
             quiet0 = quiet;
@@ -345,14 +337,14 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
 
         Configuration cfg = ctx.getConfiguration();
 
-        PatternLayout layout = PatternLayout.createLayout("[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n", null, null, 
+        PatternLayout layout = PatternLayout.createLayout("[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n", null, null,
             Charset.defaultCharset(), false, false, null, null);
 
-        Appender appender = ConsoleAppender.createAppender(layout, null, null, "CONSOLE_APPENDER", null, null);
+        Appender appender = ConsoleAppender.createAppender(layout, null, null, CONSOLE_APPENDER, null, null);
 
         appender.start();
 
-        AppenderRef ref = AppenderRef.createAppenderRef("CONSOLE_APPENDER", null, null);
+        AppenderRef ref = AppenderRef.createAppenderRef(CONSOLE_APPENDER, null, null);
 
         LoggerConfig logCfg = LoggerConfig.createLogger("false", Level.INFO, LogManager.ROOT_LOGGER_NAME, "",
             new AppenderRef[] {ref}, null, null, null);
@@ -377,7 +369,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         // Set nodeId as system variable to be used at configuration.
         System.setProperty(NODE_ID, U.id8(nodeId));
 
-        ((LoggerContext) LogManager.getContext(false)).reconfigure();
+        ((LoggerContext)LogManager.getContext(false)).reconfigure();
 
         // Hack. To touch the logger to create all log resources (files). Then #fileName() will work properly.
         impl.log(Level.OFF, "");
@@ -413,54 +405,78 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     /** {@inheritDoc} */
     @Override public void trace(String msg) {
         if (!impl.isTraceEnabled())
-            warning("Logging at TRACE level without checking if TRACE level is enabled: " + msg);
+            impl.warn("Logging at TRACE level without checking if TRACE level is enabled: " + msg);
 
         impl.trace(msg);
 
-        if (consoleLogger != null) consoleLogger.trace(msg);
+        if (consoleLog != null) {
+            if (!consoleLog.isTraceEnabled())
+                consoleLog.warn("Logging at TRACE level without checking if TRACE level is enabled: " + msg);
+
+            consoleLog.trace(msg);
+        }
     }
 
     /** {@inheritDoc} */
     @Override public void debug(String msg) {
         if (!impl.isDebugEnabled())
-            warning("Logging at DEBUG level without checking if DEBUG level is enabled: " + msg);
+            impl.warn("Logging at DEBUG level without checking if DEBUG level is enabled: " + msg);
 
         impl.debug(msg);
-        if (consoleLogger != null) consoleLogger.debug(msg);
+
+        if (consoleLog != null) {
+            if (!consoleLog.isDebugEnabled())
+                consoleLog.warn("Logging at DEBUG level without checking if DEBUG level is enabled: " + msg);
+
+            consoleLog.debug(msg);
+        }
     }
 
     /** {@inheritDoc} */
     @Override public void info(String msg) {
         if (!impl.isInfoEnabled())
-            warning("Logging at INFO level without checking if INFO level is enabled: " + msg);
+            impl.warn("Logging at INFO level without checking if INFO level is enabled: " + msg);
 
         impl.info(msg);
 
-        if (consoleLogger != null) consoleLogger.info(msg);
+        if (consoleLog != null) {
+            if (!consoleLog.isInfoEnabled())
+                consoleLog.warn("Logging at INFO level without checking if INFO level is enabled: " + msg);
+
+            consoleLog.info(msg);
+        }
     }
 
     /** {@inheritDoc} */
     @Override public void warning(String msg) {
         impl.warn(msg);
-        if (consoleLogger != null) consoleLogger.warn(msg);
+
+        if (consoleLog != null)
+            consoleLog.warn(msg);
     }
 
     /** {@inheritDoc} */
     @Override public void warning(String msg, @Nullable Throwable e) {
         impl.warn(msg, e);
-        if (consoleLogger != null) consoleLogger.warn(msg, e);
+
+        if (consoleLog != null)
+            consoleLog.warn(msg, e);
     }
 
     /** {@inheritDoc} */
     @Override public void error(String msg) {
         impl.error(msg);
-        if (consoleLogger != null) consoleLogger.error(msg);
+
+        if (consoleLog != null)
+            consoleLog.error(msg);
     }
 
     /** {@inheritDoc} */
     @Override public void error(String msg, @Nullable Throwable e) {
         impl.error(msg, e);
-        if (consoleLogger != null) consoleLogger.error(msg, e);
+
+        if (consoleLog != null)
+            consoleLog.error(msg, e);
     }
 
     /** {@inheritDoc} */


[17/24] incubator-ignite git commit: # ignite-788: make sens

Posted by sb...@apache.org.
# ignite-788: make sens


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/d3315ebb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d3315ebb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d3315ebb

Branch: refs/heads/ignite-788-last-review
Commit: d3315ebbed46c46acfd1e661f48477aa7bf99f81
Parents: 2fcafcd
Author: ashutak <as...@gridgain.com>
Authored: Fri Jul 17 17:11:38 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Fri Jul 17 17:11:38 2015 +0300

----------------------------------------------------------------------
 .../src/test/config/log4j2-verbose-test.xml     | 43 +++++++++++
 .../ignite/logger/log4j2/ContextTestTmp.java    | 79 +++++++++-----------
 2 files changed, 79 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d3315ebb/modules/core/src/test/config/log4j2-verbose-test.xml
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/log4j2-verbose-test.xml b/modules/core/src/test/config/log4j2-verbose-test.xml
new file mode 100644
index 0000000..4c75689
--- /dev/null
+++ b/modules/core/src/test/config/log4j2-verbose-test.xml
@@ -0,0 +1,43 @@
+<?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.
+-->
+
+<Configuration>
+    <!--<Appenders>-->
+        <!--<Routing name="FILE">-->
+            <!--<Routes pattern="$${sys:nodeId}">-->
+                <!--<Route>-->
+                    <!--<RollingFile name="Rolling-${sys:nodeId}" fileName="${sys:IGNITE_HOME}/work/log/ignite-${sys:nodeId}.log"-->
+                                 <!--filePattern="${sys:IGNITE_HOME}/work/log/ignite-${sys:nodeId}-%i-%d{yyyy-MM-dd}.log.gz">-->
+                        <!--<PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>-->
+                        <!--<Policies>-->
+                            <!--<TimeBasedTriggeringPolicy interval="6" modulate="true" />-->
+                            <!--<SizeBasedTriggeringPolicy size="10 MB" />-->
+                        <!--</Policies>-->
+                    <!--</RollingFile>-->
+                <!--</Route>-->
+            <!--</Routes>-->
+        <!--</Routing>-->
+    <!--</Appenders>-->
+
+    <!--<Loggers>-->
+        <!--<Root level="INFO">-->
+            <!--&lt;!&ndash;<AppenderRef ref="FILE" level="DEBUG"/>&ndash;&gt;-->
+        <!--</Root>-->
+    <!--</Loggers>-->
+</Configuration>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d3315ebb/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
index 1f858da..5b6d4ad 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
@@ -38,27 +38,48 @@ public class ContextTestTmp {
     public static void main(String[] args) throws Exception {
         final Level maxLevel = Level.DEBUG;
 
-        final URL cfgUrl = U.resolveIgniteUrl("config/ignite-log4j2.xml");
+        final URL cfgUrl = U.resolveIgniteUrl("modules/core/src/test/config/log4j2-verbose-test.xml");
 
         Configurator.initialize(LogManager.ROOT_LOGGER_NAME, cfgUrl.toString());
 
-//        addConsoleAppender(LogManager.getRootLogger(), Level.INFO);
-//
-//        logTest();
+        LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
+        AbstractConfiguration cfg = (AbstractConfiguration) ctx.getConfiguration();
+        ConsoleAppender appender = ConsoleAppender.createDefaultAppenderForLayout(PatternLayout.createDefaultLayout());
+        appender.start();
+        cfg.addAppender(appender);
+        AppenderRef[] refs = new AppenderRef[] { AppenderRef.createAppenderRef(appender.getName(), null, null) };
+        LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.ALL, LogManager.ROOT_LOGGER_NAME, "true", refs, null, cfg, null);
+        loggerConfig.addAppender(appender, null, null);
+        cfg.addLogger(LogManager.ROOT_LOGGER_NAME, loggerConfig);
+        ctx.updateLoggers();
 
-//        Appender appender = FileAppender.createAppender(U.getIgniteHome() + "/work/log/test.log", "false", "false", "File", "true",
-//            "false", "false", "4000", PatternLayout.createDefaultLayout(), null, "false", null,
-//            ((LoggerContext) LogManager.getContext(false)).getConfiguration());
-//
-//        addAppender(LogManager.getRootLogger(), appender, Level.INFO);
+        logTest();
 
-        System.out.println(((org.apache.logging.log4j.core.Logger)LogManager.getRootLogger()).getAppenders());
+        System.out.println("FInish");
+    }
 
-        Configuration cfg = ((LoggerContext)LogManager.getContext(false)).getConfiguration();
-        System.out.println(cfg.getAppenders().containsKey("Console"));
-//        System.out.println(cfg.getA.containsKey("Console"));
+    private static void doIt(org.apache.logging.log4j.core.Logger log){
+        ConsoleAppender console = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
+            "SYSTEM_OUT", "consoleApp", null, null);
 
-        logTest();
+        final LoggerContext ctx = (LoggerContext)LogManager.getContext(false);
+
+        final Configuration cfg = ctx.getConfiguration();
+
+        console.start();
+
+        cfg.addAppender(console);
+
+        AppenderRef ref = AppenderRef.createAppenderRef("consoleApp", null, null);
+
+        LoggerConfig loggerConfig = LoggerConfig.createLogger("true", Level.ALL, LogManager.ROOT_LOGGER_NAME,
+            "true", new AppenderRef[] {ref}, null, cfg, null );
+
+        loggerConfig.addAppender(console, null, null);
+
+        cfg.addLogger(LogManager.ROOT_LOGGER_NAME, loggerConfig);
+
+        ctx.updateLoggers();
     }
 
     private static void logTest() {
@@ -73,37 +94,9 @@ public class ContextTestTmp {
     }
 
     private static void addConsoleAppender(final Logger logger, final Level maxLevel) {
-        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
-
-        final Configuration cfg = ctx.getConfiguration();
-
-//        for (Appender a : loggerConfig.getAppenders().values()) {
-//            if (a instanceof ConsoleAppender)
-//                return;
-//        }
-
         ConsoleAppender appender = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
             "SYSTEM_OUT", CONSOLE_APPENDER, null, null);
 
-        appender.start();
-
-        cfg.addAppender(appender);
-
-        LoggerConfig oldLogCfg = cfg.getLoggerConfig(logger.getName());
-
-        AppenderRef ref = AppenderRef.createAppenderRef(CONSOLE_APPENDER, maxLevel, null);
-
-        LoggerConfig newLogCfg = LoggerConfig.createLogger("false", oldLogCfg.getLevel(),
-            oldLogCfg.getName(), "true", new AppenderRef[]{ref}, null, cfg, null);
-
-        newLogCfg.addAppender(appender, maxLevel, null);
-
-        cfg.addLogger(logger.getName(), oldLogCfg);
-
-        ctx.updateLoggers();
-    }
-
-    private static void addAppender(final Logger logger, Appender appender, final Level maxLevel) {
         final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
 
         final Configuration cfg = ctx.getConfiguration();
@@ -114,7 +107,7 @@ public class ContextTestTmp {
 
         LoggerConfig loggerConfig = cfg.getLoggerConfig(logger.getName());
 
-        AppenderRef ref = AppenderRef.createAppenderRef("File", maxLevel, null);
+        AppenderRef ref = AppenderRef.createAppenderRef(CONSOLE_APPENDER, maxLevel, null);
 
         loggerConfig.getAppenderRefs().add(ref);
 


[04/24] incubator-ignite git commit: # ignite-788: another methods

Posted by sb...@apache.org.
# ignite-788: another methods


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/81c8eea9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/81c8eea9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/81c8eea9

Branch: refs/heads/ignite-788-last-review
Commit: 81c8eea90ac893b277db003a905c877a80ef05a3
Parents: d7f3588
Author: ashutak <as...@gridgain.com>
Authored: Tue Jul 14 19:43:58 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Tue Jul 14 19:43:58 2015 +0300

----------------------------------------------------------------------
 .../ignite/logger/log4j2/Log4J2Logger.java      | 40 +++++++++++++++++---
 1 file changed, 34 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/81c8eea9/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index 45898ad..5fd4e5d 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -258,14 +258,38 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
      * @param level Log level to set.
      */
     public void setLevel(Level level) {
-        impl.setLevel(level);
+        LoggerContext ctx = (LoggerContext)LogManager.getContext(false);
+
+        Configuration conf = ctx.getConfiguration();
+
+        conf.getLoggerConfig(impl.getName()).setLevel(level);
+
+        ctx.updateLoggers(conf);
     }
 
     /** {@inheritDoc} */
     @Nullable @Override public String fileName() {
-        FileAppender fapp = F.first(fileAppenders);
+        // TODO
+        // It was.
+//        FileAppender fapp = F.first(fileAppenders);
+//
+//        return fapp != null ? fapp.getFile() : null;
+
+        // New logic.
+        // TODO cast, RollingFileAppender and etc.
+        org.apache.logging.log4j.core.Logger logImpl = (org.apache.logging.log4j.core.Logger)impl;
+
+        Collection<Appender> appenders = logImpl.getAppenders().values();
 
-        return fapp != null ? fapp.getFile() : null;
+        for (Appender a : appenders) {
+            if (a instanceof FileAppender)
+                return ((FileAppender)a).getFileName();
+
+            if (a instanceof RollingFileAppender)
+                return ((RollingFileAppender)a).getFileName();
+        }
+
+        return null;
     }
 
     /**
@@ -443,9 +467,13 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
      * @return {@link IgniteLogger} wrapper around log4j logger.
      */
     @Override public Log4J2Logger getLogger(Object ctgr) {
-        return new Log4J2Logger(ctgr == null ? Logger.getRootLogger() :
-            ctgr instanceof Class ? Logger.getLogger(((Class<?>)ctgr).getName()) :
-                Logger.getLogger(ctgr.toString()));
+        if (ctgr == null)
+            return new Log4J2Logger(LogManager.getRootLogger());
+
+        if (ctgr instanceof Class)
+            return new Log4J2Logger(LogManager.getLogger(((Class<?>)ctgr).getName()));
+
+        return new Log4J2Logger(LogManager.getLogger(ctgr.toString()));
     }
 
     /** {@inheritDoc} */


[13/24] incubator-ignite git commit: # ignite-788: sys:IGNITE_HOME

Posted by sb...@apache.org.
# ignite-788: sys:IGNITE_HOME


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/708da7cd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/708da7cd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/708da7cd

Branch: refs/heads/ignite-788-last-review
Commit: 708da7cda307ac5895773342951d1378b66a26a8
Parents: a04605a
Author: ashutak <as...@gridgain.com>
Authored: Thu Jul 16 14:02:47 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Jul 16 14:02:47 2015 +0300

----------------------------------------------------------------------
 config/ignite-log4j2.xml                           |  4 ++--
 .../log4j2/GridLog4j2CorrectFileNameTest.java      | 17 +++++++----------
 2 files changed, 9 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/708da7cd/config/ignite-log4j2.xml
----------------------------------------------------------------------
diff --git a/config/ignite-log4j2.xml b/config/ignite-log4j2.xml
index 3f7b3d5..95da8c5 100644
--- a/config/ignite-log4j2.xml
+++ b/config/ignite-log4j2.xml
@@ -30,8 +30,8 @@
         <Routing name="FILE">
             <Routes pattern="$${sys:nodeId}">
                 <Route>
-                    <RollingFile name="Rolling-${sys:nodeId}" fileName="work/log/ignite-${sys:nodeId}.log"
-                                 filePattern="work/log/ignite-${sys:nodeId}-%i-%d{yyyy-MM-dd}.log.gz">
+                    <RollingFile name="Rolling-${sys:nodeId}" fileName="${sys:IGNITE_HOME}/work/log/ignite-${sys:nodeId}.log"
+                                 filePattern="${sys:IGNITE_HOME}/work/log/ignite-${sys:nodeId}-%i-%d{yyyy-MM-dd}.log.gz">
                         <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
                         <Policies>
                             <TimeBasedTriggeringPolicy interval="6" modulate="true" />

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/708da7cd/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
index 2d8ee82..38cadfe 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
@@ -49,22 +49,19 @@ public class GridLog4j2CorrectFileNameTest extends TestCase {
      */
     private void checkOneNode(int id) throws Exception {
         String id8;
-        String logPath;
+        File logFile;
 
         try (Ignite ignite = G.start(getConfiguration("grid" + id))) {
             id8 = U.id8(ignite.cluster().localNode().id());
 
-            logPath = "work/log/ignite-" + id8 + ".log";
+            String logPath = "work/log/ignite-" + id8 + ".log";
 
-            assertEquals(logPath, ignite.log().fileName());
-        }
-
-        File logFile = U.resolveIgnitePath(logPath);
+            logFile = U.resolveIgnitePath(logPath);
+            assertNotNull("Failed to resolve path: " + logPath, logFile);
+            assertTrue("Log file does not exist: " + logFile, logFile.exists());
 
-        assertNotNull("Failed to resolve path: " + logPath, logFile);
-        assertTrue("Log file does not exist: " + logFile, logFile.exists());
-        // We have a row in log with the following content
-        // con >>> Local node [ID=NodeId ]
+            assertEquals(logFile.getAbsolutePath(), ignite.log().fileName());
+        }
         String logContent = U.readFileToString(logFile.getAbsolutePath(), "UTF-8");
 
         assertTrue("Log file does not contain it's node ID: " + logFile,


[19/24] incubator-ignite git commit: # ignite-788: cosnole messages (works fine)

Posted by sb...@apache.org.
# ignite-788: cosnole messages (works fine)


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f2264e0b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f2264e0b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f2264e0b

Branch: refs/heads/ignite-788-last-review
Commit: f2264e0b36a8e5288b38f8da7932c6a9477b6bd4
Parents: 53b4e2a
Author: ashutak <as...@gridgain.com>
Authored: Fri Jul 17 19:52:56 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Fri Jul 17 19:52:56 2015 +0300

----------------------------------------------------------------------
 .../src/test/config/log4j2-verbose-test.xml     |  6 ++
 .../ignite/logger/log4j2/ContextTestTmp.java    | 81 ++------------------
 .../ignite/logger/log4j2/Log4J2Logger.java      | 30 +++++---
 3 files changed, 29 insertions(+), 88 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f2264e0b/modules/core/src/test/config/log4j2-verbose-test.xml
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/log4j2-verbose-test.xml b/modules/core/src/test/config/log4j2-verbose-test.xml
index 8abb07f..81df209 100644
--- a/modules/core/src/test/config/log4j2-verbose-test.xml
+++ b/modules/core/src/test/config/log4j2-verbose-test.xml
@@ -19,6 +19,11 @@
 
 <Configuration>
     <Appenders>
+        <Console name="CONSOLE_ERR" target="SYSTEM_ERR">
+            <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+            <ThresholdFilter level="OFF" onMatch="DENY" onMismatch="ACCEPT"/>
+        </Console>
+
         <Routing name="FILE">
             <Routes pattern="$${sys:nodeId}">
                 <Route>
@@ -37,6 +42,7 @@
 
     <Loggers>
         <Root level="INFO">
+            <AppenderRef ref="CONSOLE_ERR" level="INFO"/>
             <AppenderRef ref="FILE" level="DEBUG"/>
         </Root>
     </Loggers>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f2264e0b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
index cb91303..b4c9eb2 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
@@ -19,14 +19,8 @@ package org.apache.ignite.logger.log4j2;
 
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.logging.log4j.*;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.*;
-import org.apache.logging.log4j.core.appender.*;
-import org.apache.logging.log4j.core.config.*;
-import org.apache.logging.log4j.core.layout.*;
 
 import java.net.*;
-import java.nio.charset.*;
 
 /**
  * TODO: Add class description.
@@ -41,56 +35,13 @@ public class ContextTestTmp {
 
         final URL cfgUrl = U.resolveIgniteUrl("modules/core/src/test/config/log4j2-verbose-test.xml");
 
-        String loggerName = LogManager.ROOT_LOGGER_NAME;
-
-        Configurator.initialize(loggerName, cfgUrl.toString());
-
-        LoggerContext context= (LoggerContext) LogManager.getContext();
-        Configuration config= context.getConfiguration();
-
-        PatternLayout layout= PatternLayout.createLayout("%m%n", null, null, Charset.defaultCharset(),false,false,null,null);
-        Appender appender=ConsoleAppender.createAppender(layout, null, null, "CONSOLE_APPENDER", null, null);
-        appender.start();
-        AppenderRef ref= AppenderRef.createAppenderRef("CONSOLE_APPENDER",null,null);
-        AppenderRef[] refs = new AppenderRef[] {ref};
-        LoggerConfig loggerConfig= LoggerConfig.createLogger("false", Level.INFO,"CONSOLE_LOGGER","CONSOLE_LOGGER",refs,null,null,null);
-        loggerConfig.addAppender(appender,null,null);
-
-        config.addAppender(appender);
-        config.addLogger("CONSOLE_LOGGER", loggerConfig);
-        context.updateLoggers(config);
-
-        Logger logger=LogManager.getContext().getLogger("CONSOLE_LOGGER");
-        logger.info("HELLO_WORLD");
+        org.apache.logging.log4j.core.Logger logger = Log4J2Logger.createConsoleLogger(null, null);
 
         logTest(logger);
-        logTest(LogManager.getRootLogger());
-
-        System.out.println("FInish");
-    }
-
-    private static void doIt(org.apache.logging.log4j.core.Logger log){
-        ConsoleAppender console = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
-            "SYSTEM_OUT", "consoleApp", null, null);
-
-        final LoggerContext ctx = (LoggerContext)LogManager.getContext(false);
-
-        final Configuration cfg = ctx.getConfiguration();
-
-        console.start();
-
-        cfg.addAppender(console);
-
-        AppenderRef ref = AppenderRef.createAppenderRef("consoleApp", null, null);
 
-        LoggerConfig loggerConfig = LoggerConfig.createLogger("true", Level.ALL, LogManager.ROOT_LOGGER_NAME,
-            "true", new AppenderRef[] {ref}, null, cfg, null );
+        logTest(LogManager.getContext().getLogger(LogManager.ROOT_LOGGER_NAME));
 
-        loggerConfig.addAppender(console, null, null);
-
-        cfg.addLogger(LogManager.ROOT_LOGGER_NAME, loggerConfig);
-
-        ctx.updateLoggers();
+        logTest(LogManager.getContext().getLogger("Some_another_class"));
     }
 
     private static void logTest(Logger logger) {
@@ -102,30 +53,8 @@ public class ContextTestTmp {
         logger.log(Level.DEBUG, "*******************");
         logger.log(Level.TRACE, "*******************");
         logger.log(Level.ALL, "*******************");
-    }
-
-    private static void addConsoleAppender(final Logger logger, final Level maxLevel) {
-        ConsoleAppender appender = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
-            "SYSTEM_OUT", CONSOLE_APPENDER, null, null);
-
-        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
-
-        final Configuration cfg = ctx.getConfiguration();
-
-        appender.start();
-
-        cfg.addAppender(appender);
-
-        LoggerConfig loggerConfig = cfg.getLoggerConfig(logger.getName());
-
-        AppenderRef ref = AppenderRef.createAppenderRef(CONSOLE_APPENDER, maxLevel, null);
-
-        loggerConfig.getAppenderRefs().add(ref);
-
-        loggerConfig.addAppender(appender, maxLevel, null);
-
-        cfg.addLogger(logger.getName(), loggerConfig);
 
-        ctx.updateLoggers();
+        System.out.println();
+        System.out.println();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f2264e0b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index ef8e73a..4dc5e6f 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -75,6 +75,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
 
     /** */
     public static final String CONSOLE_APPENDER = "autoConfiguredIgniteConsoleAppender";
+    public static final String CONSOLE_LOGGER_NAME = LogManager.ROOT_LOGGER_NAME;
 
     /** */
     private static volatile boolean inited;
@@ -319,14 +320,14 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
                 // User launched ignite in verbose mode and did not add console appender with INFO level
                 // to configuration and did not set IGNITE_CONSOLE_APPENDER to false.
                 if (errAppender != null) {
-                    consoleLogger = createConsoleLogger(rootLogger, Level.INFO);
+                    consoleLogger = createConsoleLogger(rootLogger, Level.ALL);
 
 //                    if (errAppender.getThreshold() == Level.ERROR)
 //                        errAppender.setThreshold(Level.WARN);
                 }
                 else
                     // No error console appender => create console appender with no level limit.
-                    consoleLogger = createConsoleLogger(rootLogger, Level.ALL);
+                    consoleLogger = createConsoleLogger(rootLogger, Level.INFO);
             }
 
             quiet0 = quiet;
@@ -400,8 +401,10 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
      * @return New console appender.
      */
     // TODO review.
-    private Logger createConsoleLogger(Logger log, Level maxLevel) {
-        LoggerContext context= (LoggerContext) LogManager.getContext();
+    public static Logger createConsoleLogger(Logger log, Level maxLevel) {
+//        ((Log4jContextFactory)LogManager.getFactory()).getSelector().
+
+        LoggerContext context= (LoggerContext) LogManager.getContext(true);
         Configuration config= context.getConfiguration();
 
         PatternLayout layout= PatternLayout.createLayout("[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n", null, null, Charset.defaultCharset(),false,false,null,null);
@@ -409,14 +412,14 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         appender.start();
         AppenderRef ref= AppenderRef.createAppenderRef("CONSOLE_APPENDER",null,null);
         AppenderRef[] refs = new AppenderRef[] {ref};
-        LoggerConfig loggerConfig= LoggerConfig.createLogger("false", Level.INFO,"CONSOLE_LOGGER","CONSOLE_LOGGER",refs,null,null,null);
+        LoggerConfig loggerConfig= LoggerConfig.createLogger("false", Level.INFO,CONSOLE_LOGGER_NAME,"",refs,null,null,null);
         loggerConfig.addAppender(appender,null,null);
 
         config.addAppender(appender);
-        config.addLogger("CONSOLE_LOGGER", loggerConfig);
+        config.addLogger(CONSOLE_LOGGER_NAME, loggerConfig);
         context.updateLoggers(config);
 
-        return  (Logger)LogManager.getContext().getLogger("CONSOLE_LOGGER");
+        return (Logger)LogManager.getContext().getLogger(CONSOLE_LOGGER_NAME);
     }
 
     /** {@inheritDoc} */
@@ -450,12 +453,15 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
      */
     @Override public Log4J2Logger getLogger(Object ctgr) {
         if (ctgr == null)
-            return new Log4J2Logger((Logger)LogManager.getRootLogger(), (Logger)LogManager.getContext().getLogger("CONSOLE_LOGGER"));
+            return new Log4J2Logger((Logger)LogManager.getRootLogger(), (Logger)LogManager.getContext().getLogger(""));
 
-        if (ctgr instanceof Class)
-            return new Log4J2Logger((Logger)LogManager.getLogger(((Class<?>)ctgr).getName()), (Logger)LogManager.getContext().getLogger("CONSOLE_LOGGER"));
+        if (ctgr instanceof Class) {
+            String name = ((Class<?>)ctgr).getName();
+            return new Log4J2Logger((Logger)LogManager.getLogger(name), (Logger)LogManager.getContext().getLogger(name));
+        }
 
-        return new Log4J2Logger((Logger)LogManager.getLogger(ctgr.toString()), (Logger)LogManager.getContext().getLogger("CONSOLE_LOGGER"));
+        String name = ctgr.toString();
+        return new Log4J2Logger((Logger)LogManager.getLogger(name), (Logger)LogManager.getContext().getLogger(name));
     }
 
     /** {@inheritDoc} */
@@ -490,7 +496,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     /** {@inheritDoc} */
     @Override public void warning(String msg) {
         impl.warn(msg);
-        if (LogManager.getContext().getLogger("CONSOLE_LOGGER") != null) LogManager.getContext().getLogger("CONSOLE_LOGGER").warn(msg);
+        if (LogManager.getContext().getLogger(CONSOLE_LOGGER_NAME) != null) LogManager.getContext().getLogger(CONSOLE_LOGGER_NAME).warn(msg);
     }
 
     /** {@inheritDoc} */


[05/24] incubator-ignite git commit: # ignite-788: draft impl

Posted by sb...@apache.org.
# ignite-788: draft impl


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/9af04af0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/9af04af0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/9af04af0

Branch: refs/heads/ignite-788-last-review
Commit: 9af04af0e5744546e408284139bb0e8e01cc30af
Parents: 81c8eea
Author: ashutak <as...@gridgain.com>
Authored: Wed Jul 15 15:20:12 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Jul 15 15:20:12 2015 +0300

----------------------------------------------------------------------
 config/ignite-log4j2.xml                        |  55 +++++++++
 .../ignite/logger/log4j2/Log4J2Logger.java      | 120 ++++++++++---------
 .../ignite/logger/log4j2/Log4j2FileAware.java   |  32 +++++
 .../logger/log4j2/Log4j2NodeIdFilePath.java     |  64 ++++++++++
 .../ignite/logger/log4j2/Log4j2TestTmp.java     |  39 ++++++
 5 files changed, 256 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9af04af0/config/ignite-log4j2.xml
----------------------------------------------------------------------
diff --git a/config/ignite-log4j2.xml b/config/ignite-log4j2.xml
new file mode 100644
index 0000000..02dc95b
--- /dev/null
+++ b/config/ignite-log4j2.xml
@@ -0,0 +1,55 @@
+<?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.
+-->
+
+<Configuration status="info">
+    <Appenders>
+        <Console name="CONSOLE_ERR" target="SYSTEM_ERR">
+            <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+        </Console>
+
+        <!--TODO-->
+        <!--<param name="MaxFileSize" value="10MB"/>-->
+        <!--<param name="MaxBackupIndex" value="10"/>-->
+        <File name="FILE" fileName="${IGNITE_HOME}/work/log/ignite.log" append="true">
+            <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+        </File>
+    </Appenders>
+
+    <Loggers>
+        <!--<Logger name="org.springframework" level="WARN">-->
+        <!--</Logger>-->
+
+        <!--<Logger name="org.eclipse.jetty" level="WARN">-->
+        <!--</Logger>-->
+
+        <!--<Logger name="org.eclipse.jetty.util.log" level="ERROR">-->
+        <!--</Logger>-->
+
+        <!--<Logger name="org.eclipse.jetty.util.component" level="ERROR">-->
+        <!--</Logger>-->
+
+        <!--<Logger name="com.amazonaws" level="WARN">-->
+        <!--</Logger>-->
+
+        <Root level="INFO">
+            <AppenderRef ref="CONSOLE_ERR"/>
+            <AppenderRef ref="FILE"/>
+        </Root>
+    </Loggers>
+</Configuration>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9af04af0/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index 5fd4e5d..22cc231 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -67,7 +67,7 @@ import static org.apache.ignite.IgniteSystemProperties.*;
  * logger in your task/job code. See {@link org.apache.ignite.resources.LoggerResource} annotation about logger
  * injection.
  */
-public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileAware {
+public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4j2FileAware {
     /** Appenders. */
     private static Collection<FileAppender> fileAppenders = new GridConcurrentHashSet<>();
 
@@ -86,13 +86,14 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
     private Logger impl;
 
     /** Path to configuration file. */
+    // TODO delete field.
     private final String path;
 
     /** Quiet flag. */
     private final boolean quiet;
 
     /** Node ID. */
-    private UUID nodeId;
+    private volatile UUID nodeId;
 
     /**
      * Creates new logger and automatically detects if root logger already
@@ -196,19 +197,12 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
         if (!cfgFile.exists() || cfgFile.isDirectory())
             throw new IgniteCheckedException("Log4j configuration path was not found or is a directory: " + cfgFile);
 
-        final String uri;
-
-        try {
-            uri = cfgFile.toURI().toURL().toString();
-        }
-        catch (MalformedURLException e) {
-            throw new IgniteCheckedException(e.toString());
-        }
+        path = cfgFile.getAbsolutePath();
 
         addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
-                    Configurator.initialize("Log4J2Logger", uri);
+                    Configurator.initialize("Log4J2Logger", path);
 
                 return LogManager.getRootLogger();
             }
@@ -324,14 +318,13 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
             boolean quiet = Boolean.valueOf(System.getProperty(IGNITE_QUIET, "true"));
 
             boolean consoleAppenderFound = false;
-            Category rootCategory = null;
+            org.apache.logging.log4j.core.Logger rootLogger = null;
             ConsoleAppender errAppender = null;
 
-            for (Category l = impl; l != null; ) {
+            // TODO impl should be core logger.
+            for (org.apache.logging.log4j.core.Logger log = (org.apache.logging.log4j.core.Logger)impl; log != null; ) {
                 if (!consoleAppenderFound) {
-                    for (Enumeration appenders = l.getAllAppenders(); appenders.hasMoreElements(); ) {
-                        Appender appender = (Appender)appenders.nextElement();
-
+                    for (Appender appender : log.getAppenders().values()) {
                         if (appender instanceof ConsoleAppender) {
                             if ("CONSOLE_ERR".equals(appender.getName())) {
                                 // Treat CONSOLE_ERR appender as a system one and don't count it.
@@ -347,13 +340,13 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
                     }
                 }
 
-                if (l.getParent() == null) {
-                    rootCategory = l;
+                if (log.getParent() == null) {
+                    rootLogger = log;
 
                     break;
                 }
                 else
-                    l = l.getParent();
+                    log = log.getParent();
             }
 
             if (consoleAppenderFound && quiet)
@@ -362,22 +355,23 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
 
             if (!consoleAppenderFound && !quiet && Boolean.valueOf(System.getProperty(IGNITE_CONSOLE_APPENDER, "true"))) {
                 // Console appender not found => we've looked through all categories up to root.
-                assert rootCategory != null;
+                assert rootLogger != null;
 
                 // User launched ignite in verbose mode and did not add console appender with INFO level
                 // to configuration and did not set IGNITE_CONSOLE_APPENDER to false.
                 if (errAppender != null) {
-                    rootCategory.addAppender(createConsoleAppender(Level.INFO));
+                    rootLogger.addAppender(createConsoleAppender(Level.INFO));
 
-                    if (errAppender.getThreshold() == Level.ERROR)
-                        errAppender.setThreshold(Level.WARN);
+                    // TODO implement.
+//                    if (errAppender.getThreshold() == Level.ERROR)
+//                        errAppender.setThreshold(Level.WARN);
                 }
                 else
                     // No error console appender => create console appender with no level limit.
-                    rootCategory.addAppender(createConsoleAppender(Level.OFF));
+                    rootLogger.addAppender(createConsoleAppender(Level.OFF));
 
                 if (logLevel != null)
-                    impl.setLevel(logLevel);
+                    ((org.apache.logging.log4j.core.Logger)impl).setLevel(logLevel);
             }
 
             quiet0 = quiet;
@@ -391,20 +385,35 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
      * @param maxLevel Max logging level.
      * @return New console appender.
      */
+    // TODO review.
     private Appender createConsoleAppender(Level maxLevel) {
-        String fmt = "[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n";
+        ConsoleAppender console = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
+            "SYSTEM_OUT", "console", null, null);
+
+        final LoggerContext ctx = new LoggerContext("console");
+
+        final Configuration cfg = ctx.getConfiguration();
 
-        // Configure output that should go to System.out
-        Appender app = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_OUT);
+        console.start();
 
-        LevelRangeFilter lvlFilter = new LevelRangeFilter();
+        cfg.addAppender(console);
 
-        lvlFilter.setLevelMin(Level.TRACE);
-        lvlFilter.setLevelMax(maxLevel);
+        AppenderRef ref = AppenderRef.createAppenderRef("console", null, null);
 
-        app.addFilter(lvlFilter);
+        AppenderRef[] refs = new AppenderRef[] {ref};
 
-        return app;
+        LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.ALL, LogManager.ROOT_LOGGER_NAME,
+            "true", refs, null, cfg, null);
+
+        loggerConfig.addAppender(console, null, null);
+
+        cfg.addLogger("org.apache.logging.log4j", loggerConfig);
+
+        ctx.updateLoggers();
+
+        ctx.getLogger("console").error("");
+
+        return console;
     }
 
     /**
@@ -435,7 +444,8 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
 
         this.nodeId = nodeId;
 
-        updateFilePath(new Log4jNodeIdFilePath(nodeId));
+        // TODO implement
+        updateFilePath(new Log4j2NodeIdFilePath(nodeId));
     }
 
     /** {@inheritDoc} */
@@ -443,19 +453,20 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
         return nodeId;
     }
 
-    /**
-     * Gets files for all registered file appenders.
-     *
-     * @return List of files.
-     */
-    public static Collection<String> logFiles() {
-        Collection<String> res = new ArrayList<>(fileAppenders.size());
-
-        for (FileAppender a : fileAppenders)
-            res.add(a.getFile());
-
-        return res;
-    }
+    // TODO implement.
+//    /**
+//     * Gets files for all registered file appenders.
+//     *
+//     * @return List of files.
+//     */
+//    public static Collection<String> logFiles() {
+//        Collection<String> res = new ArrayList<>(fileAppenders.size());
+//
+//        for (FileAppender a : fileAppenders)
+//            res.add(a.getFile());
+//
+//        return res;
+//    }
 
     /**
      * Gets {@link IgniteLogger} wrapper around log4j logger for the given
@@ -546,15 +557,16 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileA
     }
 
     /** {@inheritDoc} */
+    // TODO implement.
     @Override public void updateFilePath(IgniteClosure<String, String> filePathClos) {
         A.notNull(filePathClos, "filePathClos");
 
-        for (FileAppender a : fileAppenders) {
-            if (a instanceof Log4jFileAware) {
-                ((Log4jFileAware)a).updateFilePath(filePathClos);
-
-                a.activateOptions();
-            }
-        }
+//        for (FileAppender a : fileAppenders) {
+//            if (a instanceof Log4j2FileAware) {
+//                ((Log4j2FileAware)a).updateFilePath(filePathClos);
+//
+//                a.activateOptions();
+//            }
+//        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9af04af0/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2FileAware.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2FileAware.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2FileAware.java
new file mode 100644
index 0000000..de261aa
--- /dev/null
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2FileAware.java
@@ -0,0 +1,32 @@
+/*
+ * 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.logger.log4j2;
+
+import org.apache.ignite.lang.*;
+
+/**
+ * Interface for those loggers and appenders that evaluate their file paths lazily.
+ */
+interface Log4j2FileAware {
+    /**
+     * Sets closure that later evaluate file path.
+     *
+     * @param filePathClos Closure that generates actual file path.
+     */
+    void updateFilePath(IgniteClosure<String, String> filePathClos);
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9af04af0/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2NodeIdFilePath.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2NodeIdFilePath.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2NodeIdFilePath.java
new file mode 100644
index 0000000..a0a7b12
--- /dev/null
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2NodeIdFilePath.java
@@ -0,0 +1,64 @@
+/*
+ * 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.logger.log4j2;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Closure that generates file path adding node id to filename as a suffix.
+ */
+class Log4j2NodeIdFilePath implements IgniteClosure<String, String> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Node id. */
+    private final UUID nodeId;
+
+    /**
+     * Creates new instance.
+     *
+     * @param id Node id.
+     */
+    Log4j2NodeIdFilePath(UUID id) {
+        nodeId = id;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String apply(String oldPath) {
+        if (!F.isEmpty(U.IGNITE_LOG_DIR))
+            return U.nodeIdLogFileName(nodeId, new File(U.IGNITE_LOG_DIR, "ignite.log").getAbsolutePath());
+
+        if (oldPath != null) // fileName could be null if IGNITE_HOME is not defined.
+            return U.nodeIdLogFileName(nodeId, oldPath);
+
+        String tmpDir = IgniteSystemProperties.getString("java.io.tmpdir");
+
+        if (tmpDir != null)
+            return U.nodeIdLogFileName(nodeId, new File(tmpDir, "ignite.log").getAbsolutePath());
+
+        System.err.println("Failed to get tmp directory for log file.");
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9af04af0/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
new file mode 100644
index 0000000..d809b73
--- /dev/null
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
@@ -0,0 +1,39 @@
+/*
+ * 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.logger.log4j2;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+
+/**
+ * TODO: Add class description.
+ */
+public class Log4j2TestTmp {
+    public static void main(String[] args) throws Exception {
+        IgniteConfiguration cfg = new IgniteConfiguration()
+            .setGridLogger(new Log4J2Logger("config/ignite-log4j2.xml"));
+
+        try(Ignite ignite = Ignition.start(cfg)) {
+            ignite.log().info("********** Hi! **************");
+
+            Thread.sleep(5_000);
+
+            ignite.log().info("********** Hi! **************");
+        }
+    }
+}


[14/24] incubator-ignite git commit: # ignite-788: core logger

Posted by sb...@apache.org.
# ignite-788: core logger


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b75c24bb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b75c24bb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b75c24bb

Branch: refs/heads/ignite-788-last-review
Commit: b75c24bb53b3d4614b6c3fe400a2e6fafda32491
Parents: 708da7c
Author: ashutak <as...@gridgain.com>
Authored: Thu Jul 16 14:18:01 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Jul 16 14:18:01 2015 +0300

----------------------------------------------------------------------
 .../ignite/logger/log4j2/Log4J2Logger.java      | 42 ++++++++++----------
 1 file changed, 20 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b75c24bb/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index 5ccbc04..a8b7a31 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -24,8 +24,8 @@ import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.logger.*;
 import org.apache.logging.log4j.*;
-import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.*;
+import org.apache.logging.log4j.core.Logger;
 import org.apache.logging.log4j.core.appender.*;
 import org.apache.logging.log4j.core.appender.routing.*;
 import org.apache.logging.log4j.core.config.*;
@@ -70,10 +70,6 @@ import static org.apache.ignite.IgniteSystemProperties.*;
  */
 public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     /** */
-    // TODO review.
-    public static final String LOGGER_NAME = LogManager.ROOT_LOGGER_NAME;
-
-    /** */
     public static final String NODE_ID = "nodeId";
 
     /** */
@@ -125,7 +121,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
      *      constructor.
      */
     public Log4J2Logger(boolean init) {
-        impl = LogManager.getRootLogger();
+        impl = (Logger)LogManager.getRootLogger();
 
         if (init) {
             // Implementation has already been inited, passing NULL.
@@ -178,9 +174,9 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
-                    Configurator.initialize(LOGGER_NAME, cfgUrl.toString());
+                    Configurator.initialize(LogManager.ROOT_LOGGER_NAME, cfgUrl.toString());
 
-                return LogManager.getRootLogger();
+                return (Logger)LogManager.getRootLogger();
             }
         });
 
@@ -205,9 +201,9 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
-                    Configurator.initialize(LOGGER_NAME, path);
+                    Configurator.initialize(LogManager.ROOT_LOGGER_NAME, path);
 
-                return LogManager.getRootLogger();
+                return (Logger)LogManager.getRootLogger();
             }
         });
 
@@ -229,9 +225,9 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
                 if (init)
-                    Configurator.initialize(LOGGER_NAME, cfgUrl.toString());
+                    Configurator.initialize(LogManager.ROOT_LOGGER_NAME, cfgUrl.toString());
 
-                return LogManager.getRootLogger();
+                return (Logger)LogManager.getRootLogger();
             }
         });
 
@@ -245,7 +241,10 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
      */
     // TODO review
     public static boolean isConfigured() {
-        return LogManager.getLogger(LOGGER_NAME) != null;
+        Logger log =
+            (Logger)LogManager.getLogger(LogManager.ROOT_LOGGER_NAME);
+
+        return !log.getAppenders().isEmpty();
     }
 
     /**
@@ -265,8 +264,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
 
     /** {@inheritDoc} */
     @Nullable @Override public String fileName() {
-        for (org.apache.logging.log4j.core.Logger log = (org.apache.logging.log4j.core.Logger)impl;
-            log != null; log = log.getParent()) {
+        for (Logger log = impl; log != null; log = log.getParent()) {
             for (Appender a : log.getAppenders().values()) {
                 if (a instanceof FileAppender)
                     return ((FileAppender)a).getFileName();
@@ -336,11 +334,11 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
             boolean quiet = Boolean.valueOf(System.getProperty(IGNITE_QUIET, "true"));
 
             boolean consoleAppenderFound = false;
-            org.apache.logging.log4j.core.Logger rootLogger = null;
+            Logger rootLogger = null;
             ConsoleAppender errAppender = null;
 
             // TODO impl should be core logger.
-            for (org.apache.logging.log4j.core.Logger log = (org.apache.logging.log4j.core.Logger)impl; log != null; ) {
+            for (Logger log = impl; log != null; ) {
                 if (!consoleAppenderFound) {
                     for (Appender appender : log.getAppenders().values()) {
                         if (appender instanceof ConsoleAppender) {
@@ -389,7 +387,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
                     rootLogger.addAppender(createConsoleAppender(Level.OFF));
 
                 if (logLevel != null)
-                    ((org.apache.logging.log4j.core.Logger)impl).setLevel(logLevel);
+                    impl.setLevel(logLevel);
             }
 
             quiet0 = quiet;
@@ -441,7 +439,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         this.nodeId = nodeId;
 
         // Set nodeId as system variable to be used at configuration.
-        System.setProperty("nodeId", U.id8(nodeId));
+        System.setProperty(NODE_ID, U.id8(nodeId));
 
         ((LoggerContext) LogManager.getContext(false)).reconfigure();
 
@@ -466,12 +464,12 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
      */
     @Override public Log4J2Logger getLogger(Object ctgr) {
         if (ctgr == null)
-            return new Log4J2Logger(LogManager.getRootLogger());
+            return new Log4J2Logger((Logger)LogManager.getRootLogger());
 
         if (ctgr instanceof Class)
-            return new Log4J2Logger(LogManager.getLogger(((Class<?>)ctgr).getName()));
+            return new Log4J2Logger((Logger)LogManager.getLogger(((Class<?>)ctgr).getName()));
 
-        return new Log4J2Logger(LogManager.getLogger(ctgr.toString()));
+        return new Log4J2Logger((Logger)LogManager.getLogger(ctgr.toString()));
     }
 
     /** {@inheritDoc} */


[10/24] incubator-ignite git commit: # ignite-788: copy tests

Posted by sb...@apache.org.
# ignite-788: copy tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/86b47a04
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/86b47a04
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/86b47a04

Branch: refs/heads/ignite-788-last-review
Commit: 86b47a041d47080d70b3ab2f7fa0a8469b986001
Parents: 6932017
Author: ashutak <as...@gridgain.com>
Authored: Wed Jul 15 19:37:40 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Wed Jul 15 19:37:40 2015 +0300

----------------------------------------------------------------------
 .../log4j2/GridLog4j2CorrectFileNameTest.java   | 134 +++++++++++++++++++
 .../log4j2/GridLog4j2InitializedTest.java       |  54 ++++++++
 .../log4j2/GridLog4j2LoggingFileTest.java       |  59 ++++++++
 .../log4j2/GridLog4j2LoggingPathTest.java       |  52 +++++++
 .../logger/log4j2/GridLog4j2LoggingUrlTest.java |  59 ++++++++
 .../log4j2/GridLog4j2NotInitializedTest.java    |  46 +++++++
 6 files changed, 404 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86b47a04/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
new file mode 100644
index 0000000..4699ab8
--- /dev/null
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2CorrectFileNameTest.java
@@ -0,0 +1,134 @@
+/*
+ * 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.logger.log4j2;
+
+import junit.framework.*;
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Tests that several grids log to files with correct names.
+ */
+@GridCommonTest(group = "Logger")
+public class GridLog4j2CorrectFileNameTest extends TestCase {
+    /** Appender */
+    private Log4jRollingFileAppender appender;
+
+    /** {@inheritDoc} */
+    @Override protected void setUp() throws Exception {
+        Logger root = Logger.getRootLogger();
+
+        for (Enumeration appenders = root.getAllAppenders(); appenders.hasMoreElements(); ) {
+            if (appenders.nextElement() instanceof Log4jRollingFileAppender)
+                return;
+        }
+
+        appender = createAppender();
+
+        root.addAppender(appender);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void tearDown() {
+        if (appender != null) {
+            Logger.getRootLogger().removeAppender(Log4jRollingFileAppender.class.getSimpleName());
+
+            Log4JLogger.removeAppender(appender);
+        }
+    }
+
+    /**
+     * Tests correct behaviour in case 2 local nodes are started.
+     *
+     * @throws Exception If error occurs.
+     */
+    public void testLogFilesTwoNodes() throws Exception {
+        checkOneNode(0);
+        checkOneNode(1);
+    }
+
+    /**
+     * Starts the local node and checks for presence of log file.
+     * Also checks that this is really a log of a started node.
+     *
+     * @param id Test-local node ID.
+     * @throws Exception If error occurred.
+     */
+    private void checkOneNode(int id) throws Exception {
+        try (Ignite ignite = G.start(getConfiguration("grid" + id))) {
+            String id8 = U.id8(ignite.cluster().localNode().id());
+            String logPath = "work/log/ignite-" + id8 + ".log";
+            File logFile = U.resolveIgnitePath(logPath);
+
+            assertNotNull("Failed to resolve path: " + logPath, logFile);
+            assertTrue("Log file does not exist: " + logFile, logFile.exists());
+
+            String logContent = U.readFileToString(logFile.getAbsolutePath(), "UTF-8");
+
+            assertTrue("Log file does not contain it's node ID: " + logFile,
+                logContent.contains(">>> Local node [ID=" + id8.toUpperCase()));
+        }
+    }
+
+    /**
+     * Creates grid configuration.
+     *
+     * @param gridName Grid name.
+     * @return Grid configuration.
+     * @throws Exception If error occurred.
+     */
+    private static IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setGridName(gridName);
+        cfg.setGridLogger(new Log4JLogger());
+        cfg.setConnectorConfiguration(null);
+
+        return cfg;
+    }
+
+    /**
+     * Creates new GridLog4jRollingFileAppender.
+     *
+     * @return GridLog4jRollingFileAppender.
+     * @throws Exception If error occurred.
+     */
+    private static Log4jRollingFileAppender createAppender() throws Exception {
+        Log4jRollingFileAppender appender = new Log4jRollingFileAppender();
+
+        appender.setLayout(new PatternLayout("[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"));
+        appender.setFile("work/log/ignite.log");
+        appender.setName(Log4jRollingFileAppender.class.getSimpleName());
+
+        LevelRangeFilter lvlFilter = new LevelRangeFilter();
+
+        lvlFilter.setLevelMin(Level.DEBUG);
+        lvlFilter.setLevelMax(Level.INFO);
+
+        appender.addFilter(lvlFilter);
+
+        return appender;
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86b47a04/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java
new file mode 100644
index 0000000..107ec38
--- /dev/null
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2InitializedTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.logger.log4j2;
+
+import junit.framework.*;
+import org.apache.ignite.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+/**
+ * Log4j initialized test.
+ */
+@GridCommonTest(group = "Logger")
+public class GridLog4j2InitializedTest extends TestCase {
+
+    /**
+     * @throws Exception If failed.
+     */
+    @Override protected void setUp() throws Exception {
+        BasicConfigurator.configure();
+    }
+
+    /** */
+    public void testLogInitialize() {
+        IgniteLogger log = new Log4JLogger();
+
+        assert log.isInfoEnabled() == true;
+
+        if (log.isDebugEnabled())
+            log.debug("This is 'debug' message.");
+
+        log.info("This is 'info' message.");
+        log.warning("This is 'warning' message.");
+        log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
+        log.error("This is 'error' message.");
+        log.error("This is 'error' message.", new Exception("It's a test error exception"));
+
+        assert log.getLogger(GridLog4j2InitializedTest.class.getName()) instanceof Log4JLogger;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86b47a04/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingFileTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingFileTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingFileTest.java
new file mode 100644
index 0000000..e52e58f
--- /dev/null
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingFileTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.logger.log4j2;
+
+import junit.framework.*;
+import org.apache.ignite.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.io.*;
+
+/**
+ * Grid Log4j SPI test.
+ */
+@GridCommonTest(group = "Logger")
+public class GridLog4j2LoggingFileTest extends TestCase {
+    /** */
+    private IgniteLogger log;
+
+    /** {@inheritDoc} */
+    @Override protected void setUp() throws Exception {
+        File xml = GridTestUtils.resolveIgnitePath("modules/core/src/test/config/log4j-test.xml");
+
+        assert xml != null;
+        assert xml.exists() == true;
+
+        log = new Log4JLogger(xml).getLogger(getClass());
+    }
+
+    /**
+     * Tests log4j logging SPI.
+     */
+    public void testLog() {
+        assert log.isDebugEnabled() == true;
+        assert log.isInfoEnabled() == true;
+
+        log.debug("This is 'debug' message.");
+        log.info("This is 'info' message.");
+        log.warning("This is 'warning' message.");
+        log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
+        log.error("This is 'error' message.");
+        log.error("This is 'error' message.", new Exception("It's a test error exception"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86b47a04/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingPathTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingPathTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingPathTest.java
new file mode 100644
index 0000000..7477528
--- /dev/null
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingPathTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.logger.log4j2;
+
+import junit.framework.*;
+import org.apache.ignite.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+/**
+ * Grid Log4j SPI test.
+ */
+@GridCommonTest(group = "Logger")
+public class GridLog4j2LoggingPathTest extends TestCase {
+    /** */
+    private IgniteLogger log;
+
+    /** {@inheritDoc} */
+    @Override protected void setUp() throws Exception {
+        log = new Log4JLogger("modules/core/src/test/config/log4j-test.xml").getLogger(getClass());
+    }
+
+    /**
+     * Tests log4j logging SPI.
+     */
+    public void testLog() {
+        assert log.isInfoEnabled() == true;
+
+        if (log.isDebugEnabled())
+            log.debug("This is 'debug' message.");
+
+        log.info("This is 'info' message.");
+        log.warning("This is 'warning' message.");
+        log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
+        log.error("This is 'error' message.");
+        log.error("This is 'error' message.", new Exception("It's a test error exception"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86b47a04/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingUrlTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingUrlTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingUrlTest.java
new file mode 100644
index 0000000..03ff4ba
--- /dev/null
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2LoggingUrlTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.logger.log4j2;
+
+import junit.framework.*;
+import org.apache.ignite.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.io.*;
+
+/**
+ * Grid Log4j SPI test.
+ */
+@GridCommonTest(group = "Logger")
+public class GridLog4j2LoggingUrlTest extends TestCase {
+    /** */
+    private IgniteLogger log;
+
+    /** {@inheritDoc} */
+    @Override protected void setUp() throws Exception {
+        File xml = GridTestUtils.resolveIgnitePath("modules/core/src/test/config/log4j-test.xml");
+
+        assert xml != null;
+        assert xml.exists();
+
+        log = new Log4JLogger(xml.toURI().toURL()).getLogger(getClass());
+    }
+
+    /**
+     * Tests log4j logging SPI.
+     */
+    public void testLog() {
+        assert log.isDebugEnabled();
+        assert log.isInfoEnabled();
+
+        log.debug("This is 'debug' message.");
+        log.info("This is 'info' message.");
+        log.warning("This is 'warning' message.");
+        log.warning("This is 'warning' message.", new Exception("It's a test warning exception"));
+        log.error("This is 'error' message.");
+        log.error("This is 'error' message.", new Exception("It's a test error exception"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/86b47a04/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java
new file mode 100644
index 0000000..10bf0a1
--- /dev/null
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2NotInitializedTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.logger.log4j2;
+
+import junit.framework.*;
+import org.apache.ignite.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+/**
+ * Log4j not initialized test.
+ */
+@GridCommonTest(group = "Logger")
+public class GridLog4j2NotInitializedTest extends TestCase {
+    /** */
+    public void testLogInitialize() {
+        IgniteLogger log = new Log4JLogger().getLogger(GridLog4j2NotInitializedTest.class);
+
+        if (log.isDebugEnabled())
+            log.debug("This is 'debug' message.");
+        else
+            System.out.println("DEBUG level is not enabled.");
+
+        if (log.isInfoEnabled())
+            log.info("This is 'info' message.");
+        else
+            System.out.println("INFO level is not enabled.");
+
+        log.warning("This is 'warning' message.");
+        log.error("This is 'error' message.");
+    }
+}


[23/24] incubator-ignite git commit: # ignite-788: clean up and fixes

Posted by sb...@apache.org.
# ignite-788: clean up and fixes


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/0b36f4f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0b36f4f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0b36f4f4

Branch: refs/heads/ignite-788-last-review
Commit: 0b36f4f49ab1b09f2579c9bd0ea6771d62a22afb
Parents: 39cd7b8
Author: ashutak <as...@gridgain.com>
Authored: Mon Jul 20 17:50:49 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Mon Jul 20 17:50:49 2015 +0300

----------------------------------------------------------------------
 config/ignite-log4j2.xml                        |  1 +
 modules/core/src/test/config/log4j2-test.xml    |  1 -
 .../src/test/config/log4j2-verbose-test.xml     |  3 +-
 .../ignite/logger/log4j2/ContextTestTmp.java    | 60 --------------------
 .../ignite/logger/log4j2/Log4J2Logger.java      | 45 ++++++---------
 .../org/apache/ignite/logger/log4j2/TmpTmp.java | 37 ------------
 .../logger/log4j2/GridLog4j2SelfTest.java       | 47 +++++++++++----
 .../ignite/logger/log4j2/Log4j2TestTmp.java     | 51 -----------------
 8 files changed, 55 insertions(+), 190 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b36f4f4/config/ignite-log4j2.xml
----------------------------------------------------------------------
diff --git a/config/ignite-log4j2.xml b/config/ignite-log4j2.xml
index b6092a9..9258258 100644
--- a/config/ignite-log4j2.xml
+++ b/config/ignite-log4j2.xml
@@ -21,6 +21,7 @@
     <Appenders>
         <Console name="CONSOLE" target="SYSTEM_OUT">
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+            <ThresholdFilter level="WARN" onMatch="DENY" onMismatch="ACCEPT"/>
         </Console>
 
         <Console name="CONSOLE_ERR" target="SYSTEM_ERR">

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b36f4f4/modules/core/src/test/config/log4j2-test.xml
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/log4j2-test.xml b/modules/core/src/test/config/log4j2-test.xml
index ef5c461..30599cc 100644
--- a/modules/core/src/test/config/log4j2-test.xml
+++ b/modules/core/src/test/config/log4j2-test.xml
@@ -26,7 +26,6 @@
 
         <Console name="CONSOLE_ERR" target="SYSTEM_ERR">
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
-            <ThresholdFilter level="OFF" onMatch="DENY" onMismatch="ACCEPT"/>
         </Console>
 
         <Routing name="FILE">

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b36f4f4/modules/core/src/test/config/log4j2-verbose-test.xml
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/log4j2-verbose-test.xml b/modules/core/src/test/config/log4j2-verbose-test.xml
index 81df209..b870dc8 100644
--- a/modules/core/src/test/config/log4j2-verbose-test.xml
+++ b/modules/core/src/test/config/log4j2-verbose-test.xml
@@ -21,7 +21,6 @@
     <Appenders>
         <Console name="CONSOLE_ERR" target="SYSTEM_ERR">
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
-            <ThresholdFilter level="OFF" onMatch="DENY" onMismatch="ACCEPT"/>
         </Console>
 
         <Routing name="FILE">
@@ -42,7 +41,7 @@
 
     <Loggers>
         <Root level="INFO">
-            <AppenderRef ref="CONSOLE_ERR" level="INFO"/>
+            <AppenderRef ref="CONSOLE_ERR" level="WARN"/>
             <AppenderRef ref="FILE" level="DEBUG"/>
         </Root>
     </Loggers>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b36f4f4/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
deleted file mode 100644
index b4c9eb2..0000000
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.logging.log4j.*;
-
-import java.net.*;
-
-/**
- * TODO: Add class description.
- */
-public class ContextTestTmp {
-    public static final String CONSOLE_APPENDER = "consoleAppender";
-    public static final String CONSOLE_CTX = "consoleContext";
-    public static final String CONSOLE_LOG = "consoleLogger";
-
-    public static void main(String[] args) throws Exception {
-        final Level maxLevel = Level.DEBUG;
-
-        final URL cfgUrl = U.resolveIgniteUrl("modules/core/src/test/config/log4j2-verbose-test.xml");
-
-        org.apache.logging.log4j.core.Logger logger = Log4J2Logger.createConsoleLogger(null, null);
-
-        logTest(logger);
-
-        logTest(LogManager.getContext().getLogger(LogManager.ROOT_LOGGER_NAME));
-
-        logTest(LogManager.getContext().getLogger("Some_another_class"));
-    }
-
-    private static void logTest(Logger logger) {
-        logger.log(Level.OFF, "*******************");
-        logger.log(Level.FATAL, "*******************");
-        logger.log(Level.ERROR, "*******************");
-        logger.log(Level.WARN, "*******************");
-        logger.log(Level.INFO, "*******************");
-        logger.log(Level.DEBUG, "*******************");
-        logger.log(Level.TRACE, "*******************");
-        logger.log(Level.ALL, "*******************");
-
-        System.out.println();
-        System.out.println();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b36f4f4/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index dafa034..0be13bf 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -386,62 +386,53 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
      */
     @Override public Log4J2Logger getLogger(Object ctgr) {
         if (ctgr == null)
-            return new Log4J2Logger((Logger)LogManager.getRootLogger(), (Logger)LogManager.getContext().getLogger(""));
+            return new Log4J2Logger((Logger)LogManager.getRootLogger(),
+                consoleLog == null ? null : (Logger)LogManager.getContext().getLogger(""));
 
         if (ctgr instanceof Class) {
             String name = ((Class<?>)ctgr).getName();
 
-            return new Log4J2Logger((Logger)LogManager.getLogger(name), (Logger)LogManager.getContext().getLogger(name));
+            return new Log4J2Logger((Logger)LogManager.getLogger(name),
+                consoleLog == null ? null : (Logger)LogManager.getContext().getLogger(name));
         }
 
         String name = ctgr.toString();
 
-        return new Log4J2Logger((Logger)LogManager.getLogger(name), (Logger)LogManager.getContext().getLogger(name));
+        return new Log4J2Logger((Logger)LogManager.getLogger(name),
+            consoleLog == null ? null : (Logger)LogManager.getContext().getLogger(name));
     }
 
     /** {@inheritDoc} */
     @Override public void trace(String msg) {
-        if (!impl.isTraceEnabled())
-            impl.warn("Logging at TRACE level without checking if TRACE level is enabled: " + msg);
+        if (!isTraceEnabled())
+            warning("Logging at TRACE level without checking if TRACE level is enabled: " + msg);
 
         impl.trace(msg);
 
-        if (consoleLog != null) {
-            if (!consoleLog.isTraceEnabled())
-                consoleLog.warn("Logging at TRACE level without checking if TRACE level is enabled: " + msg);
-
+        if (consoleLog != null)
             consoleLog.trace(msg);
-        }
     }
 
     /** {@inheritDoc} */
     @Override public void debug(String msg) {
-        if (!impl.isDebugEnabled())
-            impl.warn("Logging at DEBUG level without checking if DEBUG level is enabled: " + msg);
+        if (!isDebugEnabled())
+            warning("Logging at DEBUG level without checking if DEBUG level is enabled: " + msg);
 
         impl.debug(msg);
 
-        if (consoleLog != null) {
-            if (!consoleLog.isDebugEnabled())
-                consoleLog.warn("Logging at DEBUG level without checking if DEBUG level is enabled: " + msg);
-
+        if (consoleLog != null)
             consoleLog.debug(msg);
-        }
     }
 
     /** {@inheritDoc} */
     @Override public void info(String msg) {
-        if (!impl.isInfoEnabled())
-            impl.warn("Logging at INFO level without checking if INFO level is enabled: " + msg);
+        if (!isInfoEnabled())
+            warning("Logging at INFO level without checking if INFO level is enabled: " + msg);
 
         impl.info(msg);
 
-        if (consoleLog != null) {
-            if (!consoleLog.isInfoEnabled())
-                consoleLog.warn("Logging at INFO level without checking if INFO level is enabled: " + msg);
-
+        if (consoleLog != null)
             consoleLog.info(msg);
-        }
     }
 
     /** {@inheritDoc} */
@@ -478,17 +469,17 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
 
     /** {@inheritDoc} */
     @Override public boolean isTraceEnabled() {
-        return impl.isTraceEnabled();
+        return impl.isTraceEnabled() || (consoleLog != null && consoleLog.isTraceEnabled());
     }
 
     /** {@inheritDoc} */
     @Override public boolean isDebugEnabled() {
-        return impl.isDebugEnabled();
+        return impl.isDebugEnabled() || (consoleLog != null && consoleLog.isDebugEnabled());
     }
 
     /** {@inheritDoc} */
     @Override public boolean isInfoEnabled() {
-        return impl.isInfoEnabled();
+        return impl.isInfoEnabled() || (consoleLog != null && consoleLog.isInfoEnabled());
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b36f4f4/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/TmpTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/TmpTmp.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/TmpTmp.java
deleted file mode 100644
index 65ffbdb..0000000
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/TmpTmp.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
-
-/**
- * TODO: Add class description.
- */
-public class TmpTmp {
-    public static void main(String[] args) throws IgniteCheckedException {
-        IgniteConfiguration cfg = new IgniteConfiguration().setGridLogger(
-//            new Log4J2Logger()
-            new Log4J2Logger("config/ignite-log4j2.xml")
-        );
-
-        try(Ignite ignite = Ignition.start(cfg)) {
-            ignite.log().info("lolol");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b36f4f4/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
index 1a44be2..0342d8b 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
@@ -27,6 +27,7 @@ import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
+import org.apache.logging.log4j.*;
 
 import java.io.*;
 import java.util.*;
@@ -115,39 +116,61 @@ public class GridLog4j2SelfTest extends TestCase {
     }
 
     /**
+     * Test can be run from IDE
+     *
      * @throws Exception If failed.
      */
-    public void testVerboseMode() throws Exception {
+    public void _testVerboseMode() throws Exception {
         final PrintStream backupSysOut = System.out;
+        final PrintStream backupSysErr = System.err;
+
         final ByteArrayOutputStream testOut = new ByteArrayOutputStream();
+        final ByteArrayOutputStream testErr = new ByteArrayOutputStream();
 
         try {
-            // Redirect the default output to a stream.
             System.setOut(new PrintStream(testOut));
+            System.setErr(new PrintStream(testErr));
 
             System.setProperty("IGNITE_QUIET", "false");
 
             try (Ignite ignite = G.start(getConfiguration("verboseLogGrid", LOG_PATH_VERBOSE_TEST))) {
-                String testInfoMsg = "******* Hello Tester! INFO message *******";
-                String testDebugMsg = "******* Hello Tester! DEBUG message *******";
+                String testMsg = "******* Hello Tester! ******* ";
 
-                ignite.log().info(testInfoMsg);
-                ignite.log().debug(testDebugMsg);
+                ignite.log().error(testMsg + Level.ERROR);
+                ignite.log().warning(testMsg + Level.WARN);
+                ignite.log().info(testMsg + Level.INFO);
+                ignite.log().debug(testMsg + Level.DEBUG);
+                ignite.log().trace(testMsg + Level.TRACE);
 
                 String consoleOut = testOut.toString();
+                String consoleErr = testErr.toString();
+
+                assertTrue(consoleOut.contains(testMsg + Level.INFO));
+                assertTrue(consoleOut.contains(testMsg + Level.DEBUG));
+                assertTrue(consoleOut.contains(testMsg + Level.TRACE));
 
-                assertTrue(consoleOut.contains(testInfoMsg));
-                assertTrue(consoleOut.contains(testDebugMsg));
+                assertTrue(consoleErr.contains(testMsg + Level.ERROR));
+                assertTrue(consoleErr.contains(testMsg + Level.WARN));
+
+                assertTrue(!consoleOut.contains(testMsg + Level.ERROR));
+                assertTrue(!consoleOut.contains(testMsg + Level.WARN));
+
+                assertTrue(!consoleErr.contains(testMsg + Level.INFO));
+                assertTrue(!consoleErr.contains(testMsg + Level.DEBUG));
+                assertTrue(!consoleErr.contains(testMsg + Level.TRACE));
             }
         }
         finally {
             System.setProperty("IGNITE_QUIET", "true");
 
-            // Restore the stdout and write the String to stdout.
             System.setOut(backupSysOut);
+            System.setErr(backupSysErr);
 
-            System.out.println("***** It was at output *****");
+            System.out.println("**************** Out Console content ***************");
             System.out.println(testOut.toString());
+
+            System.err.println("**************** Err Console content ***************");
+            System.err.println(testErr.toString());
         }
     }
 
@@ -172,7 +195,7 @@ public class GridLog4j2SelfTest extends TestCase {
         String id8;
         File logFile;
 
-        try (Ignite ignite = G.start(getConfiguration("grid" + id, LOG_PATH_TEST))) {
+        try (Ignite ignite = G.start(getConfiguration("grid" + id, LOG_PATH_MAIN))) {
             id8 = U.id8(ignite.cluster().localNode().id());
 
             String logPath = "work/log/ignite-" + id8 + ".log";
@@ -194,7 +217,7 @@ public class GridLog4j2SelfTest extends TestCase {
      * Creates grid configuration.
      *
      * @param gridName Grid name.
-     * @param logPath
+     * @param logPath Logger configuration path.
      * @return Grid configuration.
      * @throws Exception If error occurred.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b36f4f4/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
deleted file mode 100644
index cb1d6be..0000000
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/Log4j2TestTmp.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
-
-/**
- * TODO: Add class description.
- */
-public class Log4j2TestTmp {
-    public static void main(String[] args) throws Exception {
-//        URL url = U.resolveIgniteUrl("config/ignite-log4j2.xml");
-//
-//        System.out.println(url);
-//
-//        Configurator.initialize("test logger", url.toString());
-//
-//        LogManager.getLogger("test logger").info("******************************1");
-//
-//        ThreadContext.put("nodeId", "12345");
-//
-//        LogManager.getLogger("test logger").info("******************************2");
-
-        IgniteConfiguration cfg = new IgniteConfiguration()
-            .setGridLogger(new Log4J2Logger("config/ignite-log4j2.xml"));
-
-        try (Ignite ignite = Ignition.start(cfg.setGridName("grid1"))) {
-            ignite.log().info("****** smf 1 ********");
-            try (Ignite ignite2 = Ignition.start(cfg.setGridName("grid2"))) {
-                ignite.log().info("****** smf 2 ********");
-                ignite2.log().info("****** smf 3 ********");
-            }
-        }
-    }
-}


[02/24] incubator-ignite git commit: # ignite-788: init

Posted by sb...@apache.org.
# ignite-788: init


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/649c781a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/649c781a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/649c781a

Branch: refs/heads/ignite-788-last-review
Commit: 649c781aaa569ac6680000752692a33bed421da3
Parents: 0839e8d
Author: ashutak <as...@gridgain.com>
Authored: Tue Jul 14 18:50:40 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Tue Jul 14 18:50:40 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/logger/log4j/Log4JLogger.java |   2 +-
 modules/log4j2/pom.xml                          |  14 +-
 .../ignite/logger/log4j2/Log4J2Logger.java      | 515 +++++++++++++++++++
 .../ignite/logger/log4j2/SampleClass.java       |  27 -
 4 files changed, 529 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/649c781a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4JLogger.java
----------------------------------------------------------------------
diff --git a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4JLogger.java b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4JLogger.java
index 333b1da..7969371 100644
--- a/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4JLogger.java
+++ b/modules/log4j/src/main/java/org/apache/ignite/logger/log4j/Log4JLogger.java
@@ -42,7 +42,7 @@ import static org.apache.ignite.IgniteSystemProperties.*;
  * Here is a typical example of configuring log4j logger in Ignite configuration file:
  * <pre name="code" class="xml">
  *      &lt;property name="gridLogger"&gt;
- *          &lt;bean class="org.apache.ignite.grid.logger.log4j.GridLog4jLogger"&gt;
+ *          &lt;bean class="org.apache.ignite.grid.logger.log4j.Log4jLogger"&gt;
  *              &lt;constructor-arg type="java.lang.String" value="config/ignite-log4j.xml"/&gt;
  *          &lt;/bean>
  *      &lt;/property&gt;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/649c781a/modules/log4j2/pom.xml
----------------------------------------------------------------------
diff --git a/modules/log4j2/pom.xml b/modules/log4j2/pom.xml
index 259b588..d4072f4 100644
--- a/modules/log4j2/pom.xml
+++ b/modules/log4j2/pom.xml
@@ -31,7 +31,7 @@
     </parent>
 
     <artifactId>ignite-log4j2</artifactId>
-    <version>1.0.6-SNAPSHOT</version>
+    <version>1.2.1-SNAPSHOT</version>
 
     <dependencies>
         <dependency>
@@ -47,5 +47,17 @@
             <type>test-jar</type>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>2.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>2.3</version>
+        </dependency>
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/649c781a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
new file mode 100644
index 0000000..9a6f424
--- /dev/null
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -0,0 +1,515 @@
+/*
+ * 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.logger.log4j2;
+
+import org.apache.ignite.*;
+import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.tostring.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.logger.*;
+import org.jetbrains.annotations.*;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+import static org.apache.ignite.IgniteSystemProperties.*;
+
+/**
+ * Log4j2-based implementation for logging. This logger should be used
+ * by loaders that have prefer <a target=_new href="http://logging.apache.org/log4j/2.x/index.html">log4j2</a>-based logging.
+ * <p>
+ * Here is a typical example of configuring log4j2 logger in Ignite configuration file:
+ * <pre name="code" class="xml">
+ *      &lt;property name="gridLogger"&gt;
+ *          &lt;bean class="org.apache.ignite.grid.logger.log4j2.Log4j2Logger"&gt;
+ *              &lt;constructor-arg type="java.lang.String" value="config/ignite-log4j2.xml"/&gt;
+ *          &lt;/bean>
+ *      &lt;/property&gt;
+ * </pre>
+ * and from your code:
+ * <pre name="code" class="java">
+ *      IgniteConfiguration cfg = new IgniteConfiguration();
+ *      ...
+ *      URL xml = U.resolveIgniteUrl("config/custom-log4j2.xml");
+ *      IgniteLogger log = new Log4J2Logger(xml);
+ *      ...
+ *      cfg.setGridLogger(log);
+ * </pre>
+ *
+ * Please take a look at <a target=_new href="http://logging.apache.org/log4j/2.x/index.html">Apache Log4j 2</a>
+ * for additional information.
+ * <p>
+ * It's recommended to use Ignite logger injection instead of using/instantiating
+ * logger in your task/job code. See {@link org.apache.ignite.resources.LoggerResource} annotation about logger
+ * injection.
+ */
+public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware, Log4jFileAware {
+    /** Appenders. */
+    private static Collection<FileAppender> fileAppenders = new GridConcurrentHashSet<>();
+
+    /** */
+    private static volatile boolean inited;
+
+    /** */
+    private static volatile boolean quiet0;
+
+    /** */
+    private static final Object mux = new Object();
+
+    /** Logger implementation. */
+    @GridToStringExclude
+    @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
+    private Logger impl;
+
+    /** Path to configuration file. */
+    private final String path;
+
+    /** Quiet flag. */
+    private final boolean quiet;
+
+    /** Node ID. */
+    private UUID nodeId;
+
+    /**
+     * Creates new logger and automatically detects if root logger already
+     * has appenders configured. If it does not, the root logger will be
+     * configured with default appender (analogous to calling
+     * {@link #Log4J2Logger(boolean) Log4JLogger(boolean)}
+     * with parameter {@code true}, otherwise, existing appenders will be used (analogous
+     * to calling {@link #Log4J2Logger(boolean) Log4JLogger(boolean)}
+     * with parameter {@code false}).
+     */
+    public Log4J2Logger() {
+        this(!isConfigured());
+    }
+
+    /**
+     * Creates new logger. If initialize parameter is {@code true} the Log4j
+     * logger will be initialized with default console appender and {@code INFO}
+     * log level.
+     *
+     * @param init If {@code true}, then a default console appender with
+     *      following pattern layout will be created: {@code %d{ABSOLUTE} %-5p [%c{1}] %m%n}.
+     *      If {@code false}, then no implicit initialization will take place,
+     *      and {@code Log4j} should be configured prior to calling this
+     *      constructor.
+     */
+    public Log4J2Logger(boolean init) {
+        impl = Logger.getRootLogger();
+
+        if (init) {
+            // Implementation has already been inited, passing NULL.
+            addConsoleAppenderIfNeeded(Level.INFO, null);
+
+            quiet = quiet0;
+        }
+        else
+            quiet = true;
+
+        path = null;
+    }
+
+    /**
+     * Creates new logger with given implementation.
+     *
+     * @param impl Log4j implementation to use.
+     */
+    public Log4J2Logger(final Logger impl) {
+        assert impl != null;
+
+        path = null;
+
+        addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
+            @Override public Logger apply(Boolean init) {
+                return impl;
+            }
+        });
+
+        quiet = quiet0;
+    }
+
+    /**
+     * Creates new logger with given configuration {@code path}.
+     *
+     * @param path Path to log4j configuration XML file.
+     * @throws IgniteCheckedException Thrown in case logger can't be created.
+     */
+    public Log4J2Logger(String path) throws IgniteCheckedException {
+        if (path == null)
+            throw new IgniteCheckedException("Configuration XML file for Log4j must be specified.");
+
+        this.path = path;
+
+        final URL cfgUrl = U.resolveIgniteUrl(path);
+
+        if (cfgUrl == null)
+            throw new IgniteCheckedException("Log4j configuration path was not found: " + path);
+
+        addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
+            @Override public Logger apply(Boolean init) {
+                if (init)
+                    DOMConfigurator.configure(cfgUrl);
+
+                return Logger.getRootLogger();
+            }
+        });
+
+        quiet = quiet0;
+    }
+
+    /**
+     * Creates new logger with given configuration {@code cfgFile}.
+     *
+     * @param cfgFile Log4j configuration XML file.
+     * @throws IgniteCheckedException Thrown in case logger can't be created.
+     */
+    public Log4J2Logger(File cfgFile) throws IgniteCheckedException {
+        if (cfgFile == null)
+            throw new IgniteCheckedException("Configuration XML file for Log4j must be specified.");
+
+        if (!cfgFile.exists() || cfgFile.isDirectory())
+            throw new IgniteCheckedException("Log4j configuration path was not found or is a directory: " + cfgFile);
+
+        path = cfgFile.getAbsolutePath();
+
+        addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
+            @Override public Logger apply(Boolean init) {
+                if (init)
+                    DOMConfigurator.configure(path);
+
+                return Logger.getRootLogger();
+            }
+        });
+
+        quiet = quiet0;
+    }
+
+    /**
+     * Creates new logger with given configuration {@code cfgUrl}.
+     *
+     * @param cfgUrl URL for Log4j configuration XML file.
+     * @throws IgniteCheckedException Thrown in case logger can't be created.
+     */
+    public Log4J2Logger(final URL cfgUrl) throws IgniteCheckedException {
+        if (cfgUrl == null)
+            throw new IgniteCheckedException("Configuration XML file for Log4j must be specified.");
+
+        path = null;
+
+        addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
+            @Override public Logger apply(Boolean init) {
+                if (init)
+                    DOMConfigurator.configure(cfgUrl);
+
+                return Logger.getRootLogger();
+            }
+        });
+
+        quiet = quiet0;
+    }
+
+    /**
+     * Checks if Log4j is already configured within this VM or not.
+     *
+     * @return {@code True} if log4j was already configured, {@code false} otherwise.
+     */
+    public static boolean isConfigured() {
+        return Logger.getRootLogger().getAllAppenders().hasMoreElements();
+    }
+
+    /**
+     * Sets level for internal log4j implementation.
+     *
+     * @param level Log level to set.
+     */
+    public void setLevel(Level level) {
+        impl.setLevel(level);
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public String fileName() {
+        FileAppender fapp = F.first(fileAppenders);
+
+        return fapp != null ? fapp.getFile() : null;
+    }
+
+    /**
+     * Adds console appender when needed with some default logging settings.
+     *
+     * @param logLevel Optional log level.
+     * @param implInitC Optional log implementation init closure.
+     */
+    private void addConsoleAppenderIfNeeded(@Nullable Level logLevel,
+        @Nullable IgniteClosure<Boolean, Logger> implInitC) {
+        if (inited) {
+            if (implInitC != null)
+                // Do not init.
+                impl = implInitC.apply(false);
+
+            return;
+        }
+
+        synchronized (mux) {
+            if (inited) {
+                if (implInitC != null)
+                    // Do not init.
+                    impl = implInitC.apply(false);
+
+                return;
+            }
+
+            if (implInitC != null)
+                // Init logger impl.
+                impl = implInitC.apply(true);
+
+            boolean quiet = Boolean.valueOf(System.getProperty(IGNITE_QUIET, "true"));
+
+            boolean consoleAppenderFound = false;
+            Category rootCategory = null;
+            ConsoleAppender errAppender = null;
+
+            for (Category l = impl; l != null; ) {
+                if (!consoleAppenderFound) {
+                    for (Enumeration appenders = l.getAllAppenders(); appenders.hasMoreElements(); ) {
+                        Appender appender = (Appender)appenders.nextElement();
+
+                        if (appender instanceof ConsoleAppender) {
+                            if ("CONSOLE_ERR".equals(appender.getName())) {
+                                // Treat CONSOLE_ERR appender as a system one and don't count it.
+                                errAppender = (ConsoleAppender)appender;
+
+                                continue;
+                            }
+
+                            consoleAppenderFound = true;
+
+                            break;
+                        }
+                    }
+                }
+
+                if (l.getParent() == null) {
+                    rootCategory = l;
+
+                    break;
+                }
+                else
+                    l = l.getParent();
+            }
+
+            if (consoleAppenderFound && quiet)
+                // User configured console appender, but log is quiet.
+                quiet = false;
+
+            if (!consoleAppenderFound && !quiet && Boolean.valueOf(System.getProperty(IGNITE_CONSOLE_APPENDER, "true"))) {
+                // Console appender not found => we've looked through all categories up to root.
+                assert rootCategory != null;
+
+                // User launched ignite in verbose mode and did not add console appender with INFO level
+                // to configuration and did not set IGNITE_CONSOLE_APPENDER to false.
+                if (errAppender != null) {
+                    rootCategory.addAppender(createConsoleAppender(Level.INFO));
+
+                    if (errAppender.getThreshold() == Level.ERROR)
+                        errAppender.setThreshold(Level.WARN);
+                }
+                else
+                    // No error console appender => create console appender with no level limit.
+                    rootCategory.addAppender(createConsoleAppender(Level.OFF));
+
+                if (logLevel != null)
+                    impl.setLevel(logLevel);
+            }
+
+            quiet0 = quiet;
+            inited = true;
+        }
+    }
+
+    /**
+     * Creates console appender with some reasonable default logging settings.
+     *
+     * @param maxLevel Max logging level.
+     * @return New console appender.
+     */
+    private Appender createConsoleAppender(Level maxLevel) {
+        String fmt = "[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n";
+
+        // Configure output that should go to System.out
+        Appender app = new ConsoleAppender(new PatternLayout(fmt), ConsoleAppender.SYSTEM_OUT);
+
+        LevelRangeFilter lvlFilter = new LevelRangeFilter();
+
+        lvlFilter.setLevelMin(Level.TRACE);
+        lvlFilter.setLevelMax(maxLevel);
+
+        app.addFilter(lvlFilter);
+
+        return app;
+    }
+
+    /**
+     * Adds file appender.
+     *
+     * @param a Appender.
+     */
+    public static void addAppender(FileAppender a) {
+        A.notNull(a, "a");
+
+        fileAppenders.add(a);
+    }
+
+    /**
+     * Removes file appender.
+     *
+     * @param a Appender.
+     */
+    public static void removeAppender(FileAppender a) {
+        A.notNull(a, "a");
+
+        fileAppenders.remove(a);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void setNodeId(UUID nodeId) {
+        A.notNull(nodeId, "nodeId");
+
+        this.nodeId = nodeId;
+
+        updateFilePath(new Log4jNodeIdFilePath(nodeId));
+    }
+
+    /** {@inheritDoc} */
+    @Override public UUID getNodeId() {
+        return nodeId;
+    }
+
+    /**
+     * Gets files for all registered file appenders.
+     *
+     * @return List of files.
+     */
+    public static Collection<String> logFiles() {
+        Collection<String> res = new ArrayList<>(fileAppenders.size());
+
+        for (FileAppender a : fileAppenders)
+            res.add(a.getFile());
+
+        return res;
+    }
+
+    /**
+     * Gets {@link IgniteLogger} wrapper around log4j logger for the given
+     * category. If category is {@code null}, then root logger is returned. If
+     * category is an instance of {@link Class} then {@code (Class)ctgr).getName()}
+     * is used as category name.
+     *
+     * @param ctgr {@inheritDoc}
+     * @return {@link IgniteLogger} wrapper around log4j logger.
+     */
+    @Override public Log4J2Logger getLogger(Object ctgr) {
+        return new Log4J2Logger(ctgr == null ? Logger.getRootLogger() :
+            ctgr instanceof Class ? Logger.getLogger(((Class<?>)ctgr).getName()) :
+                Logger.getLogger(ctgr.toString()));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void trace(String msg) {
+        if (!impl.isTraceEnabled())
+            warning("Logging at TRACE level without checking if TRACE level is enabled: " + msg);
+
+        impl.trace(msg);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void debug(String msg) {
+        if (!impl.isDebugEnabled())
+            warning("Logging at DEBUG level without checking if DEBUG level is enabled: " + msg);
+
+        impl.debug(msg);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void info(String msg) {
+        if (!impl.isInfoEnabled())
+            warning("Logging at INFO level without checking if INFO level is enabled: " + msg);
+
+        impl.info(msg);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void warning(String msg) {
+        impl.warn(msg);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void warning(String msg, @Nullable Throwable e) {
+        impl.warn(msg, e);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void error(String msg) {
+        impl.error(msg);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void error(String msg, @Nullable Throwable e) {
+        impl.error(msg, e);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isTraceEnabled() {
+        return impl.isTraceEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isDebugEnabled() {
+        return impl.isDebugEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isInfoEnabled() {
+        return impl.isInfoEnabled();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isQuiet() {
+        return quiet;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(Log4J2Logger.class, this);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void updateFilePath(IgniteClosure<String, String> filePathClos) {
+        A.notNull(filePathClos, "filePathClos");
+
+        for (FileAppender a : fileAppenders) {
+            if (a instanceof Log4jFileAware) {
+                ((Log4jFileAware)a).updateFilePath(filePathClos);
+
+                a.activateOptions();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/649c781a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/SampleClass.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/SampleClass.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/SampleClass.java
deleted file mode 100644
index 8fdc2f1..0000000
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/SampleClass.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.logger.log4j2;
-
-/**
- * TODO: delete me.
- *
- * This class was added just to resolve problem with javadocs for empty module.
- * Class have to be deleted if there are another files in module.
- */
-public class SampleClass {
-}


[22/24] incubator-ignite git commit: # ignite-788: fileName

Posted by sb...@apache.org.
# ignite-788: fileName


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/39cd7b83
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/39cd7b83
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/39cd7b83

Branch: refs/heads/ignite-788-last-review
Commit: 39cd7b83cc760f8ec6dd5b2c3614342abc8c55e6
Parents: 8ed4c2f
Author: ashutak <as...@gridgain.com>
Authored: Mon Jul 20 16:56:30 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Mon Jul 20 16:56:30 2015 +0300

----------------------------------------------------------------------
 config/ignite-log4j2.xml                        |  4 +-
 .../apache/ignite/internal/IgniteKernal.java    | 32 +++++++-------
 .../ignite/logger/log4j2/Log4J2Logger.java      | 45 +++++++++-----------
 3 files changed, 38 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39cd7b83/config/ignite-log4j2.xml
----------------------------------------------------------------------
diff --git a/config/ignite-log4j2.xml b/config/ignite-log4j2.xml
index 57f567e..b6092a9 100644
--- a/config/ignite-log4j2.xml
+++ b/config/ignite-log4j2.xml
@@ -21,12 +21,10 @@
     <Appenders>
         <Console name="CONSOLE" target="SYSTEM_OUT">
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
-            <ThresholdFilter level="ERROR" onMatch="DENY" onMismatch="ACCEPT"/>
         </Console>
 
         <Console name="CONSOLE_ERR" target="SYSTEM_ERR">
             <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
-            <ThresholdFilter level="OFF" onMatch="DENY" onMismatch="ACCEPT"/>
         </Console>
 
         <Routing name="FILE">
@@ -75,7 +73,7 @@
             <AppenderRef ref="CONSOLE" level="DEBUG"/>
             -->
 
-            <AppenderRef ref="CONSOLE_ERR" level="ERROR"/>
+            <AppenderRef ref="CONSOLE_ERR" level="WARN"/>
             <AppenderRef ref="FILE" level="DEBUG"/>
         </Root>
     </Loggers>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39cd7b83/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 024dc7b..880aec8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -1473,11 +1473,23 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
     private void ackAsciiLogo() {
         assert log != null;
 
-        String fileName = log.fileName();
-
         if (System.getProperty(IGNITE_NO_ASCII) == null) {
             String ver = "ver. " + ACK_VER_STR;
 
+            if (log.isInfoEnabled()) {
+                log.info(NL + NL +
+                        ">>>    __________  ________________  " + NL +
+                        ">>>   /  _/ ___/ |/ /  _/_  __/ __/  " + NL +
+                        ">>>  _/ // (7 7    // /  / / / _/    " + NL +
+                        ">>> /___/\\___/_/|_/___/ /_/ /___/   " + NL +
+                        ">>> " + NL +
+                        ">>> " + ver + NL +
+                        ">>> " + COPYRIGHT + NL +
+                        ">>> " + NL +
+                        ">>> Ignite documentation: " + "http://" + SITE + NL
+                );
+            }
+
             // Big thanks to: http://patorjk.com/software/taag
             // Font name "Small Slant"
             if (log.isQuiet()) {
@@ -1494,6 +1506,8 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                     "",
                     "Quiet mode.");
 
+                String fileName = log.fileName();
+
                 if (fileName != null)
                     U.quiet(false, "  ^-- Logging to file '" +  fileName + '\'');
 
@@ -1501,20 +1515,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
                     "  ^-- To see **FULL** console log here add -DIGNITE_QUIET=false or \"-v\" to ignite.{sh|bat}",
                     "");
             }
-
-            if (log.isInfoEnabled()) {
-                log.info(NL + NL +
-                        ">>>    __________  ________________  " + NL +
-                        ">>>   /  _/ ___/ |/ /  _/_  __/ __/  " + NL +
-                        ">>>  _/ // (7 7    // /  / / / _/    " + NL +
-                        ">>> /___/\\___/_/|_/___/ /_/ /___/   " + NL +
-                        ">>> " + NL +
-                        ">>> " + ver + NL +
-                        ">>> " + COPYRIGHT + NL +
-                        ">>> " + NL +
-                        ">>> Ignite documentation: " + "http://" + SITE + NL
-                );
-            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/39cd7b83/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index c785c34..dafa034 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -29,6 +29,7 @@ import org.apache.logging.log4j.core.Logger;
 import org.apache.logging.log4j.core.appender.*;
 import org.apache.logging.log4j.core.appender.routing.*;
 import org.apache.logging.log4j.core.config.*;
+import org.apache.logging.log4j.core.filter.*;
 import org.apache.logging.log4j.core.layout.*;
 import org.jetbrains.annotations.*;
 
@@ -71,10 +72,10 @@ import static org.apache.ignite.IgniteSystemProperties.*;
  */
 public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     /** */
-    public static final String NODE_ID = "nodeId";
+    private static final String NODE_ID = "nodeId";
 
     /** */
-    public static final String CONSOLE_APPENDER = "autoConfiguredIgniteConsoleAppender";
+    private static final String CONSOLE_APPENDER = "autoConfiguredIgniteConsoleAppender";
 
     /** */
     private static volatile boolean inited;
@@ -90,6 +91,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
     private Logger impl;
 
+    /** Auto added at verbose mode console logger (optional). */
     private volatile Logger consoleLog;
 
     /** Quiet flag. */
@@ -310,15 +312,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
 
                 // User launched ignite in verbose mode and did not add console appender with INFO level
                 // to configuration and did not set IGNITE_CONSOLE_APPENDER to false.
-                if (errAppender != null) {
-                    consoleLog = createConsoleLogger(rootLogger, Level.TRACE);
-
-//                    if (errAppender.getThreshold() == Level.ERROR)
-//                        errAppender.setThreshold(Level.WARN);
-                }
-                else
-                    // No error console appender => create console appender with no level limit.
-                    consoleLog = createConsoleLogger(rootLogger, Level.INFO);
+                consoleLog = createConsoleLogger(errAppender != null);
             }
 
             quiet0 = quiet;
@@ -329,10 +323,9 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     /**
      * Creates console appender with some reasonable default logging settings.
      *
-     * @param maxLevel Max logging level.
-     * @return New console appender.
+     * @return Logger with auto configured console appender.
      */
-    public static Logger createConsoleLogger(Logger log, Level maxLevel) {
+    public static Logger createConsoleLogger(boolean errConsoleAppenderWasFound) {
         LoggerContext ctx = (LoggerContext)LogManager.getContext(true);
 
         Configuration cfg = ctx.getConfiguration();
@@ -340,18 +333,23 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         PatternLayout layout = PatternLayout.createLayout("[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n", null, null,
             Charset.defaultCharset(), false, false, null, null);
 
-        Appender appender = ConsoleAppender.createAppender(layout, null, null, CONSOLE_APPENDER, null, null);
+        ThresholdFilter filter = null;
+
+        if (errConsoleAppenderWasFound)
+            filter = ThresholdFilter.createFilter(Level.WARN, Filter.Result.DENY, Filter.Result.ACCEPT);
 
-        appender.start();
+        final Appender consoleApp = ConsoleAppender.createAppender(layout, filter, null, CONSOLE_APPENDER, null, null);
+        consoleApp.start();
 
-        AppenderRef ref = AppenderRef.createAppenderRef(CONSOLE_APPENDER, null, null);
+        AppenderRef ref = AppenderRef.createAppenderRef(CONSOLE_APPENDER, Level.TRACE, null);
 
-        LoggerConfig logCfg = LoggerConfig.createLogger("false", Level.INFO, LogManager.ROOT_LOGGER_NAME, "",
-            new AppenderRef[] {ref}, null, null, null);
+        AppenderRef[] refs = {ref};
 
-        logCfg.addAppender(appender, null, null);
+        LoggerConfig logCfg = LoggerConfig.createLogger("false", Level.ALL, LogManager.ROOT_LOGGER_NAME, "",
+            refs, null, null, null);
 
-        cfg.addAppender(appender);
+        logCfg.addAppender(consoleApp, null, null);
+        cfg.addAppender(consoleApp);
 
         cfg.addLogger(LogManager.ROOT_LOGGER_NAME, logCfg);
 
@@ -370,9 +368,6 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
         System.setProperty(NODE_ID, U.id8(nodeId));
 
         ((LoggerContext)LogManager.getContext(false)).reconfigure();
-
-        // Hack. To touch the logger to create all log resources (files). Then #fileName() will work properly.
-        impl.log(Level.OFF, "");
     }
 
     /** {@inheritDoc} */
@@ -395,10 +390,12 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
 
         if (ctgr instanceof Class) {
             String name = ((Class<?>)ctgr).getName();
+
             return new Log4J2Logger((Logger)LogManager.getLogger(name), (Logger)LogManager.getContext().getLogger(name));
         }
 
         String name = ctgr.toString();
+
         return new Log4J2Logger((Logger)LogManager.getLogger(name), (Logger)LogManager.getContext().getLogger(name));
     }
 


[18/24] incubator-ignite git commit: # ignite-788: cosnole messages

Posted by sb...@apache.org.
# ignite-788: cosnole messages


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/53b4e2a7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/53b4e2a7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/53b4e2a7

Branch: refs/heads/ignite-788-last-review
Commit: 53b4e2a7dbeac3625623486fadc3e031201af72e
Parents: d3315eb
Author: ashutak <as...@gridgain.com>
Authored: Fri Jul 17 19:11:49 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Fri Jul 17 19:11:49 2015 +0300

----------------------------------------------------------------------
 .../src/test/config/log4j2-verbose-test.xml     |  42 ++---
 .../ignite/logger/log4j2/ContextTestTmp.java    |  51 +++---
 .../ignite/logger/log4j2/Log4J2Logger.java      | 161 +++++++++++++------
 .../logger/log4j2/GridLog4j2SelfTest.java       |  59 +++++--
 4 files changed, 204 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/53b4e2a7/modules/core/src/test/config/log4j2-verbose-test.xml
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/log4j2-verbose-test.xml b/modules/core/src/test/config/log4j2-verbose-test.xml
index 4c75689..8abb07f 100644
--- a/modules/core/src/test/config/log4j2-verbose-test.xml
+++ b/modules/core/src/test/config/log4j2-verbose-test.xml
@@ -18,26 +18,26 @@
 -->
 
 <Configuration>
-    <!--<Appenders>-->
-        <!--<Routing name="FILE">-->
-            <!--<Routes pattern="$${sys:nodeId}">-->
-                <!--<Route>-->
-                    <!--<RollingFile name="Rolling-${sys:nodeId}" fileName="${sys:IGNITE_HOME}/work/log/ignite-${sys:nodeId}.log"-->
-                                 <!--filePattern="${sys:IGNITE_HOME}/work/log/ignite-${sys:nodeId}-%i-%d{yyyy-MM-dd}.log.gz">-->
-                        <!--<PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>-->
-                        <!--<Policies>-->
-                            <!--<TimeBasedTriggeringPolicy interval="6" modulate="true" />-->
-                            <!--<SizeBasedTriggeringPolicy size="10 MB" />-->
-                        <!--</Policies>-->
-                    <!--</RollingFile>-->
-                <!--</Route>-->
-            <!--</Routes>-->
-        <!--</Routing>-->
-    <!--</Appenders>-->
+    <Appenders>
+        <Routing name="FILE">
+            <Routes pattern="$${sys:nodeId}">
+                <Route>
+                    <RollingFile name="Rolling-${sys:nodeId}" fileName="${sys:IGNITE_HOME}/work/log/ignite-${sys:nodeId}.log"
+                                 filePattern="${sys:IGNITE_HOME}/work/log/ignite-${sys:nodeId}-%i-%d{yyyy-MM-dd}.log.gz">
+                        <PatternLayout pattern="[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n"/>
+                        <Policies>
+                            <TimeBasedTriggeringPolicy interval="6" modulate="true" />
+                            <SizeBasedTriggeringPolicy size="10 MB" />
+                        </Policies>
+                    </RollingFile>
+                </Route>
+            </Routes>
+        </Routing>
+    </Appenders>
 
-    <!--<Loggers>-->
-        <!--<Root level="INFO">-->
-            <!--&lt;!&ndash;<AppenderRef ref="FILE" level="DEBUG"/>&ndash;&gt;-->
-        <!--</Root>-->
-    <!--</Loggers>-->
+    <Loggers>
+        <Root level="INFO">
+            <AppenderRef ref="FILE" level="DEBUG"/>
+        </Root>
+    </Loggers>
 </Configuration>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/53b4e2a7/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
index 5b6d4ad..cb91303 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/ContextTestTmp.java
@@ -26,6 +26,7 @@ import org.apache.logging.log4j.core.config.*;
 import org.apache.logging.log4j.core.layout.*;
 
 import java.net.*;
+import java.nio.charset.*;
 
 /**
  * TODO: Add class description.
@@ -40,20 +41,30 @@ public class ContextTestTmp {
 
         final URL cfgUrl = U.resolveIgniteUrl("modules/core/src/test/config/log4j2-verbose-test.xml");
 
-        Configurator.initialize(LogManager.ROOT_LOGGER_NAME, cfgUrl.toString());
+        String loggerName = LogManager.ROOT_LOGGER_NAME;
 
-        LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
-        AbstractConfiguration cfg = (AbstractConfiguration) ctx.getConfiguration();
-        ConsoleAppender appender = ConsoleAppender.createDefaultAppenderForLayout(PatternLayout.createDefaultLayout());
+        Configurator.initialize(loggerName, cfgUrl.toString());
+
+        LoggerContext context= (LoggerContext) LogManager.getContext();
+        Configuration config= context.getConfiguration();
+
+        PatternLayout layout= PatternLayout.createLayout("%m%n", null, null, Charset.defaultCharset(),false,false,null,null);
+        Appender appender=ConsoleAppender.createAppender(layout, null, null, "CONSOLE_APPENDER", null, null);
         appender.start();
-        cfg.addAppender(appender);
-        AppenderRef[] refs = new AppenderRef[] { AppenderRef.createAppenderRef(appender.getName(), null, null) };
-        LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.ALL, LogManager.ROOT_LOGGER_NAME, "true", refs, null, cfg, null);
-        loggerConfig.addAppender(appender, null, null);
-        cfg.addLogger(LogManager.ROOT_LOGGER_NAME, loggerConfig);
-        ctx.updateLoggers();
+        AppenderRef ref= AppenderRef.createAppenderRef("CONSOLE_APPENDER",null,null);
+        AppenderRef[] refs = new AppenderRef[] {ref};
+        LoggerConfig loggerConfig= LoggerConfig.createLogger("false", Level.INFO,"CONSOLE_LOGGER","CONSOLE_LOGGER",refs,null,null,null);
+        loggerConfig.addAppender(appender,null,null);
+
+        config.addAppender(appender);
+        config.addLogger("CONSOLE_LOGGER", loggerConfig);
+        context.updateLoggers(config);
+
+        Logger logger=LogManager.getContext().getLogger("CONSOLE_LOGGER");
+        logger.info("HELLO_WORLD");
 
-        logTest();
+        logTest(logger);
+        logTest(LogManager.getRootLogger());
 
         System.out.println("FInish");
     }
@@ -82,15 +93,15 @@ public class ContextTestTmp {
         ctx.updateLoggers();
     }
 
-    private static void logTest() {
-        LogManager.getRootLogger().log(Level.OFF, "*******************");
-        LogManager.getRootLogger().log(Level.FATAL, "*******************");
-        LogManager.getRootLogger().log(Level.ERROR, "*******************");
-        LogManager.getRootLogger().log(Level.WARN, "*******************");
-        LogManager.getRootLogger().log(Level.INFO, "*******************");
-        LogManager.getRootLogger().log(Level.DEBUG, "*******************");
-        LogManager.getRootLogger().log(Level.TRACE, "*******************");
-        LogManager.getRootLogger().log(Level.ALL, "*******************");
+    private static void logTest(Logger logger) {
+        logger.log(Level.OFF, "*******************");
+        logger.log(Level.FATAL, "*******************");
+        logger.log(Level.ERROR, "*******************");
+        logger.log(Level.WARN, "*******************");
+        logger.log(Level.INFO, "*******************");
+        logger.log(Level.DEBUG, "*******************");
+        logger.log(Level.TRACE, "*******************");
+        logger.log(Level.ALL, "*******************");
     }
 
     private static void addConsoleAppender(final Logger logger, final Level maxLevel) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/53b4e2a7/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
index 8fc4e57..ef8e73a 100644
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
+++ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java
@@ -29,11 +29,13 @@ import org.apache.logging.log4j.core.Logger;
 import org.apache.logging.log4j.core.appender.*;
 import org.apache.logging.log4j.core.appender.routing.*;
 import org.apache.logging.log4j.core.config.*;
+import org.apache.logging.log4j.core.layout.*;
 import org.jetbrains.annotations.*;
 
 import java.io.*;
 import java.lang.reflect.*;
 import java.net.*;
+import java.nio.charset.*;
 import java.util.*;
 
 import static org.apache.ignite.IgniteSystemProperties.*;
@@ -72,6 +74,9 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     public static final String NODE_ID = "nodeId";
 
     /** */
+    public static final String CONSOLE_APPENDER = "autoConfiguredIgniteConsoleAppender";
+
+    /** */
     private static volatile boolean inited;
 
     /** */
@@ -85,6 +90,8 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
     @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
     private Logger impl;
 
+    private volatile Logger consoleLogger;
+
     /** Quiet flag. */
     private final boolean quiet;
 
@@ -95,9 +102,11 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
      * Creates new logger with given implementation.
      *
      * @param impl Log4j implementation to use.
+     * @param consoleLogger
      */
-    public Log4J2Logger(final Logger impl) {
+    public Log4J2Logger(final Logger impl, Logger consoleLogger) {
         assert impl != null;
+        this.consoleLogger = consoleLogger;
 
         addConsoleAppenderIfNeeded(new C1<Boolean, Logger>() {
             @Override public Logger apply(Boolean init) {
@@ -303,75 +312,112 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
                 // User configured console appender, but log is quiet.
                 quiet = false;
 
-//            if (!consoleAppenderFound && !quiet && Boolean.valueOf(System.getProperty(IGNITE_CONSOLE_APPENDER, "true"))) {
-//                // Console appender not found => we've looked through all categories up to root.
-//                assert rootLogger != null;
-//
-//                // User launched ignite in verbose mode and did not add console appender with INFO level
-//                // to configuration and did not set IGNITE_CONSOLE_APPENDER to false.
-//                if (errAppender != null) {
-//                    rootLogger.addAppender(createConsoleAppender(Level.INFO));
-//
-//                    // TODO implement.
-////                    if (errAppender.getThreshold() == Level.ERROR)
-////                        errAppender.setThreshold(Level.WARN);
-////                }
-////                else
-////                    // No error console appender => create console appender with no level limit.
-////                    rootLogger.addAppender(createConsoleAppender(Level.OFF));
-////
-//////                if (logLevel != null)
-//////                    impl.setLevel(logLevel);
-//                }
-//                else
-//                    // No error console appender => create console appender with no level limit.
-//                    rootLogger.addAppender(createConsoleAppender(Level.OFF));
-//
-//                if (logLevel != null)
-//                    impl.setLevel(logLevel);
-//            }
+            if (!consoleAppenderFound && !quiet && Boolean.valueOf(System.getProperty(IGNITE_CONSOLE_APPENDER, "true"))) {
+                // Console appender not found => we've looked through all categories up to root.
+                assert rootLogger != null;
+
+                // User launched ignite in verbose mode and did not add console appender with INFO level
+                // to configuration and did not set IGNITE_CONSOLE_APPENDER to false.
+                if (errAppender != null) {
+                    consoleLogger = createConsoleLogger(rootLogger, Level.INFO);
+
+//                    if (errAppender.getThreshold() == Level.ERROR)
+//                        errAppender.setThreshold(Level.WARN);
+                }
+                else
+                    // No error console appender => create console appender with no level limit.
+                    consoleLogger = createConsoleLogger(rootLogger, Level.ALL);
+            }
 
             quiet0 = quiet;
             inited = true;
         }
     }
 
-//    /**
-//     * Creates console appender with some reasonable default logging settings.
-//     *
-//     * @param maxLevel Max logging level.
-//     * @return New console appender.
-//     */
-//    // TODO review.
-//    private Appender createConsoleAppender(Level maxLevel) {
-//        ConsoleAppender console = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
-//            "SYSTEM_OUT", "console", null, null);
-//
-//        final LoggerContext ctx = new LoggerContext("console");
+//    private void createConsoleLogger(Logger logger, Level maxLevel) {
+//        final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
 //
 //        final Configuration cfg = ctx.getConfiguration();
 //
-//        console.start();
+//        ConsoleAppender appender = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
+//            "SYSTEM_OUT", CONSOLE_APPENDER, null, null);
+//
+//        appender.start();
 //
-//        cfg.addAppender(console);
+//        cfg.addAppender(appender);
 //
-//        AppenderRef ref = AppenderRef.createAppenderRef("console", null, null);
+//        LoggerConfig oldLogCfg = cfg.getLoggerConfig(logger.getName());
 //
-//        AppenderRef[] refs = new AppenderRef[] {ref};
+//        AppenderRef ref = AppenderRef.createAppenderRef(CONSOLE_APPENDER, Level.ALL, null);
 //
-//        LoggerConfig loggerConfig = LoggerConfig.createLogger("false", Level.ALL, LogManager.ROOT_LOGGER_NAME,
-//            "true", refs, null, cfg, null);
+//        LoggerConfig newLogCfg = LoggerConfig.createLogger("false", oldLogCfg.getLevel(),
+//            oldLogCfg.getName(), "true", new AppenderRef[]{ref}, null, cfg, null);
 //
-//        loggerConfig.addAppender(console, null, null);
+//        newLogCfg.addAppender(appender, Level.ALL, null);
 //
-//        cfg.addLogger("org.apache.logging.log4j", loggerConfig);
+//        cfg.addLogger(logger.getName(), oldLogCfg);
 //
+//        ctx.reconfigure();
 //        ctx.updateLoggers();
+//    }
+
+    /**
+     * Creates console appender with some reasonable default logging settings.
+     *
+     * @param maxLevel Max logging level.
+     * @return New console appender.
+     */
+    // TODO review.
+//    private void createConsoleLogger(Logger log, Level maxLevel) {
+//        ConsoleAppender consoleApp = ConsoleAppender.createAppender(PatternLayout.createDefaultLayout(), null,
+//            "SYSTEM_OUT", CONSOLE_APPENDER, null, null);
+//
+//        final LoggerContext ctx = log.getContext();
+//
+//        final Configuration cfg = ctx.getConfiguration();
+//
+//        consoleApp.start();
+//
+//        cfg.addAppender(consoleApp);
+//
+//        AppenderRef ref = AppenderRef.createAppenderRef(CONSOLE_APPENDER, null, null);
+//
+//        LoggerConfig logCfg = LoggerConfig.createLogger("true", null, log.getName(),
+//            "true", new AppenderRef[] {ref}, null, cfg, null);
+//
+//        logCfg.getAppenderRefs().add(ref);
 //
-//        ctx.getLogger("console").error("");
+//        cfg.addLogger(log.getName(), logCfg);
 //
-//        return console;
+//        ctx.updateLoggers();
+//
+//        return consoleApp;
 //    }
+    /**
+     * Creates console appender with some reasonable default logging settings.
+     *
+     * @param maxLevel Max logging level.
+     * @return New console appender.
+     */
+    // TODO review.
+    private Logger createConsoleLogger(Logger log, Level maxLevel) {
+        LoggerContext context= (LoggerContext) LogManager.getContext();
+        Configuration config= context.getConfiguration();
+
+        PatternLayout layout= PatternLayout.createLayout("[%d{ABSOLUTE}][%-5p][%t][%c{1}] %m%n", null, null, Charset.defaultCharset(),false,false,null,null);
+        Appender appender=ConsoleAppender.createAppender(layout, null, null, "CONSOLE_APPENDER", null, null);
+        appender.start();
+        AppenderRef ref= AppenderRef.createAppenderRef("CONSOLE_APPENDER",null,null);
+        AppenderRef[] refs = new AppenderRef[] {ref};
+        LoggerConfig loggerConfig= LoggerConfig.createLogger("false", Level.INFO,"CONSOLE_LOGGER","CONSOLE_LOGGER",refs,null,null,null);
+        loggerConfig.addAppender(appender,null,null);
+
+        config.addAppender(appender);
+        config.addLogger("CONSOLE_LOGGER", loggerConfig);
+        context.updateLoggers(config);
+
+        return  (Logger)LogManager.getContext().getLogger("CONSOLE_LOGGER");
+    }
 
     /** {@inheritDoc} */
     @Override public void setNodeId(UUID nodeId) {
@@ -404,12 +450,12 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
      */
     @Override public Log4J2Logger getLogger(Object ctgr) {
         if (ctgr == null)
-            return new Log4J2Logger((Logger)LogManager.getRootLogger());
+            return new Log4J2Logger((Logger)LogManager.getRootLogger(), (Logger)LogManager.getContext().getLogger("CONSOLE_LOGGER"));
 
         if (ctgr instanceof Class)
-            return new Log4J2Logger((Logger)LogManager.getLogger(((Class<?>)ctgr).getName()));
+            return new Log4J2Logger((Logger)LogManager.getLogger(((Class<?>)ctgr).getName()), (Logger)LogManager.getContext().getLogger("CONSOLE_LOGGER"));
 
-        return new Log4J2Logger((Logger)LogManager.getLogger(ctgr.toString()));
+        return new Log4J2Logger((Logger)LogManager.getLogger(ctgr.toString()), (Logger)LogManager.getContext().getLogger("CONSOLE_LOGGER"));
     }
 
     /** {@inheritDoc} */
@@ -418,6 +464,8 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
             warning("Logging at TRACE level without checking if TRACE level is enabled: " + msg);
 
         impl.trace(msg);
+
+        if (consoleLogger != null) consoleLogger.trace(msg);
     }
 
     /** {@inheritDoc} */
@@ -426,6 +474,7 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
             warning("Logging at DEBUG level without checking if DEBUG level is enabled: " + msg);
 
         impl.debug(msg);
+        if (consoleLogger != null) consoleLogger.debug(msg);
     }
 
     /** {@inheritDoc} */
@@ -434,26 +483,32 @@ public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware {
             warning("Logging at INFO level without checking if INFO level is enabled: " + msg);
 
         impl.info(msg);
+
+        if (consoleLogger != null) consoleLogger.info(msg);
     }
 
     /** {@inheritDoc} */
     @Override public void warning(String msg) {
         impl.warn(msg);
+        if (LogManager.getContext().getLogger("CONSOLE_LOGGER") != null) LogManager.getContext().getLogger("CONSOLE_LOGGER").warn(msg);
     }
 
     /** {@inheritDoc} */
     @Override public void warning(String msg, @Nullable Throwable e) {
         impl.warn(msg, e);
+        if (consoleLogger != null) consoleLogger.warn(msg, e);
     }
 
     /** {@inheritDoc} */
     @Override public void error(String msg) {
         impl.error(msg);
+        if (consoleLogger != null) consoleLogger.error(msg);
     }
 
     /** {@inheritDoc} */
     @Override public void error(String msg, @Nullable Throwable e) {
         impl.error(msg, e);
+        if (consoleLogger != null) consoleLogger.error(msg, e);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/53b4e2a7/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
index ba3f37b..3b07fa9 100644
--- a/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
+++ b/modules/log4j2/src/test/java/org/apache/ignite/logger/log4j2/GridLog4j2SelfTest.java
@@ -23,14 +23,14 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.logger.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
 
 import java.io.*;
 import java.util.*;
 
-import static org.apache.ignite.IgniteSystemProperties.*;
-
 /**
  * Grid Log4j2 SPI test.
  */
@@ -40,6 +40,9 @@ public class GridLog4j2SelfTest extends TestCase {
     public static final String LOG_PATH_TEST = "modules/core/src/test/config/log4j2-test.xml";
 
     /** */
+    public static final String LOG_PATH_VERBOSE_TEST = "modules/core/src/test/config/log4j2-verbose-test.xml";
+
+    /** */
     public static final String LOG_PATH_MAIN = "config/ignite-log4j2.xml";
 
     /**
@@ -115,19 +118,45 @@ public class GridLog4j2SelfTest extends TestCase {
      * @throws Exception If failed.
      */
     public void testVerboseMode() throws Exception {
-        System.setProperty(IGNITE_QUIET, "false");
-
-//        try (Ignite ignite = G.start(getConfiguration("grid" + id))) {
-//            id8 = U.id8(ignite.cluster().localNode().id());
-//
-//            String logPath = "work/log/ignite-" + id8 + ".log";
-//
-//            logFile = U.resolveIgnitePath(logPath);
-//            assertNotNull("Failed to resolve path: " + logPath, logFile);
-//            assertTrue("Log file does not exist: " + logFile, logFile.exists());
-//
-//            assertEquals(logFile.getAbsolutePath(), ignite.log().fileName());
-//        }
+        final PrintStream backupSysOut = System.out;
+        final ByteArrayOutputStream testOut = new ByteArrayOutputStream();
+
+        try {
+            // Redirect the default output to a stream.
+            System.setOut(new PrintStream(testOut));
+
+            System.setProperty("IGNITE_QUIET", "false");
+
+            TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+            disco.setIpFinder(new TcpDiscoveryVmIpFinder(false) {{
+                setAddresses(Collections.singleton("127.0.0.1:47500..47509"));
+            }});
+
+            IgniteConfiguration cfg = new IgniteConfiguration()
+                .setGridLogger(new Log4J2Logger(LOG_PATH_VERBOSE_TEST))
+                .setConnectorConfiguration(null)
+                .setDiscoverySpi(disco);
+
+            try (Ignite ignite = G.start(cfg)) {
+                String testInfoMsg = "******* Hello Tester! INFO message *******";
+                String testDebugMsg = "******* Hello Tester! DEBUG message *******";
+
+                ignite.log().info(testInfoMsg);
+                ignite.log().debug(testDebugMsg);
+
+                String consoleOut = testOut.toString();
+
+                assertTrue(consoleOut.contains(testInfoMsg));
+                assertTrue(consoleOut.contains(testDebugMsg));
+            }
+        }
+        finally {
+            // Restore the stdout and write the String to stdout.
+            System.setOut(backupSysOut);
+
+            System.out.println(testOut.toString());
+        }
     }
 
     /**