ignite git commit: IGNITE-3153

2016-06-09 Thread av
Repository: ignite
Updated Branches:
  refs/heads/ignite-3153 [created] 93c88ed0f


IGNITE-3153


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

Branch: refs/heads/ignite-3153
Commit: 93c88ed0f44525c5710ed7d89a883dff88c73eed
Parents: ec5706f
Author: Anton Vinogradov 
Authored: Thu Jun 9 19:58:58 2016 +0300
Committer: Anton Vinogradov 
Committed: Thu Jun 9 19:58:58 2016 +0300

--
 .../zk/TcpDiscoveryZookeeperIpFinder.java   | 73 
 .../tcp/ipfinder/zk/ZookeeperIpFinderTest.java  | 20 --
 2 files changed, 58 insertions(+), 35 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/ignite/blob/93c88ed0/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/TcpDiscoveryZookeeperIpFinder.java
--
diff --git 
a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/TcpDiscoveryZookeeperIpFinder.java
 
b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/TcpDiscoveryZookeeperIpFinder.java
index bee4dab..b3a79e1 100644
--- 
a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/TcpDiscoveryZookeeperIpFinder.java
+++ 
b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/TcpDiscoveryZookeeperIpFinder.java
@@ -39,6 +39,7 @@ import 
org.apache.curator.x.discovery.details.JsonInstanceSerializer;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.resources.LoggerResource;
 import org.apache.ignite.spi.IgniteSpiException;
 import 
org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAdapter;
@@ -68,11 +69,8 @@ import org.codehaus.jackson.map.annotate.JsonRootName;
  *
  * @see http://zookeeper.apache.org;>Apache ZooKeeper
  * @see http://curator.apache.org;>Apache Curator
- *
- * @author Raul Kripalani
  */
 public class TcpDiscoveryZookeeperIpFinder extends TcpDiscoveryIpFinderAdapter 
{
-
 /** System property name to provide the ZK Connection String. */
 public static final String PROP_ZK_CONNECTION_STRING = 
"IGNITE_ZK_CONNECTION_STRING";
 
@@ -89,6 +87,10 @@ public class TcpDiscoveryZookeeperIpFinder extends 
TcpDiscoveryIpFinderAdapter {
 @GridToStringExclude
 private final AtomicBoolean initGuard = new AtomicBoolean();
 
+/** Init guard. */
+@GridToStringExclude
+private final AtomicBoolean closeGuard = new AtomicBoolean();
+
 /** Logger. */
 @LoggerResource
 private IgniteLogger log;
@@ -124,8 +126,14 @@ public class TcpDiscoveryZookeeperIpFinder extends 
TcpDiscoveryIpFinderAdapter {
 
 /** Initializes this IP Finder by creating the appropriate Curator 
objects. */
 private void init() {
-if (!initGuard.compareAndSet(false, true))
+if (!initGuard.compareAndSet(false, true)) {
+if (closeGuard.get())
+U.warn(log, "ZooKeeper IP Finder already was closed and can't 
be reinitialized.");
+else
+U.warn(log, "ZooKeeper IP Finder can't be initialized more 
than once.");
+
 return;
+}
 
 String sysPropZkConnString = 
System.getProperty(PROP_ZK_CONNECTION_STRING);
 
@@ -140,9 +148,11 @@ public class TcpDiscoveryZookeeperIpFinder extends 
TcpDiscoveryIpFinderAdapter {
 curator = CuratorFrameworkFactory.newClient(zkConnectionString, 
retryPolicy);
 }
 
-if (curator.getState() != CuratorFrameworkState.STARTED)
+if (curator.getState() == CuratorFrameworkState.LATENT)
 curator.start();
 
+A.ensure(curator.getState() == CuratorFrameworkState.STARTED, 
"CuratorFramework can't be started.");
+
 discovery = 
ServiceDiscoveryBuilder.builder(IgniteInstanceDetails.class)
 .client(curator)
 .basePath(basePath)
@@ -152,8 +162,11 @@ public class TcpDiscoveryZookeeperIpFinder extends 
TcpDiscoveryIpFinderAdapter {
 
 /** {@inheritDoc} */
 @Override public void onSpiContextDestroyed() {
-if (!initGuard.compareAndSet(true, false))
+if (!closeGuard.compareAndSet(false, true)) {
+U.warn(log, "ZooKeeper IP Finder can't be closed more than once.");
+
 return;
+}
 
 log.info("Destroying ZooKeeper IP Finder.");
 
@@ -175,7 +188,8 @@ public class TcpDiscoveryZookeeperIpFinder extends 
TcpDiscoveryIpFinderAdapter {
 
 try {
  

ignite git commit: IGNITE-3216

2016-06-09 Thread av
Repository: ignite
Updated Branches:
  refs/heads/ignite-3216 b563a4870 -> 43fbbeb5c


IGNITE-3216


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

Branch: refs/heads/ignite-3216
Commit: 43fbbeb5c965272d64dedc480e1560b4aebd517a
Parents: b563a48
Author: Anton Vinogradov 
Authored: Thu Jun 9 16:28:36 2016 +0300
Committer: Anton Vinogradov 
Committed: Thu Jun 9 16:28:36 2016 +0300

--
 .../main/java/org/apache/ignite/internal/util/IgniteUtils.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/ignite/blob/43fbbeb5/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
--
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java 
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 18239b9..faf026b 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -8583,7 +8583,7 @@ public abstract class IgniteUtils {
 throw new IgniteCheckedException("Addresses can not be resolved 
[addr=" + addrs +
 ", hostNames=" + hostNames + ']');
 
-return Collections.unmodifiableCollection(res);
+return res;
 }
 
 /**
@@ -8630,7 +8630,7 @@ public abstract class IgniteUtils {
 res.add(new InetSocketAddress(addr, port));
 }
 
-return Collections.unmodifiableCollection(res);
+return res;
 }
 
 /**



ignite git commit: ignite-2911 Fixed ClusterGroup.forDaemons. This closes #657.

2016-06-09 Thread sboikov
Repository: ignite
Updated Branches:
  refs/heads/master dee6426c7 -> 51a25fa84


ignite-2911 Fixed  ClusterGroup.forDaemons. This closes #657.


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

Branch: refs/heads/master
Commit: 51a25fa8496ff6e084fd1ddca5eb5fed9b8f4d27
Parents: dee6426
Author: sboikov 
Authored: Thu Jun 9 16:19:47 2016 +0300
Committer: sboikov 
Committed: Thu Jun 9 16:19:47 2016 +0300

--
 .../internal/cluster/ClusterGroupAdapter.java   | 18 ++--
 .../ignite/internal/ClusterGroupSelfTest.java   | 30 ++--
 2 files changed, 37 insertions(+), 11 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/ignite/blob/51a25fa8/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
--
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
index c664f1e..e4b45f0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
@@ -109,8 +109,7 @@ public class ClusterGroupAdapter implements ClusterGroupEx, 
Externalizable {
  */
 protected ClusterGroupAdapter(@Nullable GridKernalContext ctx,
 @Nullable UUID subjId,
-@Nullable IgnitePredicate p)
-{
+@Nullable IgnitePredicate p) {
 if (ctx != null)
 setKernalContext(ctx);
 
@@ -127,8 +126,7 @@ public class ClusterGroupAdapter implements ClusterGroupEx, 
Externalizable {
  */
 protected ClusterGroupAdapter(@Nullable GridKernalContext ctx,
 @Nullable UUID subjId,
-Set ids)
-{
+Set ids) {
 if (ctx != null)
 setKernalContext(ctx);
 
@@ -149,8 +147,7 @@ public class ClusterGroupAdapter implements ClusterGroupEx, 
Externalizable {
 private ClusterGroupAdapter(@Nullable GridKernalContext ctx,
 @Nullable UUID subjId,
 @Nullable IgnitePredicate p,
-Set ids)
-{
+Set ids) {
 if (ctx != null)
 setKernalContext(ctx);
 
@@ -311,7 +308,12 @@ public class ClusterGroupAdapter implements 
ClusterGroupEx, Externalizable {
 }
 }
 else {
-Collection all = ctx.discovery().allNodes();
+Collection all;
+
+if (p instanceof DaemonFilter)
+all = F.concat(false, ctx.discovery().daemonNodes(), 
ctx.discovery().allNodes());
+else
+all = ctx.discovery().allNodes();
 
 return p != null ? F.view(all, p) : all;
 }
@@ -1068,4 +1070,4 @@ public class ClusterGroupAdapter implements 
ClusterGroupEx, Externalizable {
 "', p='" + p.getClass().getName() + "']";
 }
 }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/51a25fa8/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java
--
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java
index 18eb3b7..ebc1097 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/ClusterGroupSelfTest.java
@@ -143,6 +143,31 @@ public class ClusterGroupSelfTest extends 
ClusterGroupAbstractTest {
 /**
  * @throws Exception If failed.
  */
+public void testForDaemons() throws Exception {
+assertEquals(4, ignite.cluster().nodes().size());
+
+ClusterGroup daemons = ignite.cluster().forDaemons();
+ClusterGroup srvs = ignite.cluster().forServers();
+
+assertEquals(0, daemons.nodes().size());
+assertEquals(2, srvs.nodes().size());
+
+Ignition.setDaemon(true);
+
+try (Ignite g = startGrid(NODES_CNT)) {
+Ignition.setDaemon(false);
+
+try (Ignite g1 = startGrid(NODES_CNT + 1)) {
+assertEquals(1, ignite.cluster().forDaemons().nodes().size());
+assertEquals(3, srvs.nodes().size());
+assertEquals(1, daemons.nodes().size());
+}
+}
+}
+
+/**
+ * @throws Exception If failed.
+ */
 public void testNewNodes() throws 

ignite git commit: IGNITE-3287: Implemented.

2016-06-09 Thread vozerov
Repository: ignite
Updated Branches:
  refs/heads/ignite-3287 [created] 66fb92230


IGNITE-3287: Implemented.


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

Branch: refs/heads/ignite-3287
Commit: 66fb922300e9dff9a1fde192c93c142f3d51aa62
Parents: ec5706f
Author: vozerov-gridgain 
Authored: Thu Jun 9 13:14:27 2016 +0300
Committer: vozerov-gridgain 
Committed: Thu Jun 9 13:14:27 2016 +0300

--
 .../processors/igfs/IgfsDeleteResult.java   |  62 +
 .../internal/processors/igfs/IgfsImpl.java  |  30 +--
 .../processors/igfs/IgfsMetaManager.java| 265 ++-
 .../internal/processors/igfs/IgfsPathIds.java   |  10 +
 .../processors/igfs/IgfsAbstractSelfTest.java   |  14 +-
 .../igfs/IgfsMetaManagerSelfTest.java   |  20 +-
 6 files changed, 177 insertions(+), 224 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/ignite/blob/66fb9223/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteResult.java
--
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteResult.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteResult.java
new file mode 100644
index 000..ff42762
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteResult.java
@@ -0,0 +1,62 @@
+/*
+ * 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.internal.processors.igfs;
+
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Result of deletion in IGFS.
+ */
+public class IgfsDeleteResult {
+/** Success flag. */
+private final boolean success;
+
+/** Entry info. */
+private final IgfsEntryInfo info;
+
+/**
+ * Constructor.
+ *
+ * @param success Success flag.
+ * @param info Entry info.
+ */
+public IgfsDeleteResult(boolean success, @Nullable IgfsEntryInfo info) {
+this.success = success;
+this.info = info;
+}
+
+/**
+ * @return Success flag.
+ */
+public boolean success() {
+return success;
+}
+
+/**
+ * @return Entry info.
+ */
+public IgfsEntryInfo info() {
+return info;
+}
+
+/** {@inheritDoc} */
+@Override public String toString() {
+return S.toString(IgfsDeleteResult.class, this);
+}
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/66fb9223/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
--
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
index bc26ace..0808619 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsImpl.java
@@ -104,7 +104,6 @@ import java.util.concurrent.atomic.AtomicLong;
 
 import static org.apache.ignite.events.EventType.EVT_IGFS_DIR_DELETED;
 import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_CLOSED_READ;
-import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_CLOSED_WRITE;
 import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_DELETED;
 import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_OPENED_READ;
 import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_OPENED_WRITE;
@@ -723,38 +722,21 @@ public final class IgfsImpl implements IgfsEx {
 if (IgfsPath.SLASH.equals(path.toString()))
 return false;
 
-IgfsMode mode = resolveMode(path);
-
  

ignite git commit: ignite-3261

2016-06-09 Thread sboikov
Repository: ignite
Updated Branches:
  refs/heads/ignite-3261 d8b17a33b -> fa1091836


ignite-3261


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

Branch: refs/heads/ignite-3261
Commit: fa1091836c9e9fbdf42630aa3e259eb595a0edea
Parents: d8b17a3
Author: sboikov 
Authored: Thu Jun 9 10:12:02 2016 +0300
Committer: sboikov 
Committed: Thu Jun 9 10:18:36 2016 +0300

--
 .../ignite/internal/binary/BinaryContext.java   | 51 ++--
 ...aultBinaryMappersBinaryMetaDataSelfTest.java | 17 +++
 2 files changed, 52 insertions(+), 16 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/ignite/blob/fa109183/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
--
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 3851678..d39f9c6 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -259,7 +259,7 @@ public class BinaryContext {
 registerPredefinedType(LinkedHashMap.class, 0);
 
 // Classes with overriden default serialization flag.
-registerPredefinedType(AffinityKey.class, 0, 
affinityFieldName(AffinityKey.class));
+registerPredefinedType(AffinityKey.class, 0, 
affinityFieldName(AffinityKey.class), false);
 
 registerPredefinedType(GridMapEntry.class, 60);
 registerPredefinedType(IgniteBiTuple.class, 61);
@@ -562,9 +562,37 @@ public class BinaryContext {
 if (desc == null)
 desc = registerClassDescriptor(cls, deserialize);
 else if (!desc.registered()) {
-assert desc.userType();
-
-desc = registerUserClassDescriptor(desc);
+if (!desc.userType()) {
+BinaryClassDescriptor desc0 = new BinaryClassDescriptor(
+this,
+desc.describedClass(),
+false,
+desc.typeId(),
+desc.typeName(),
+desc.affFieldKeyName(),
+desc.mapper(),
+desc.initialSerializer(),
+false,
+true
+);
+
+if (descByCls.replace(cls, desc, desc0)) {
+Collection schemas =
+desc0.schema() != null ? 
Collections.singleton(desc.schema()) : null;
+
+BinaryMetadata meta = new BinaryMetadata(desc0.typeId(),
+desc0.typeName(),
+desc0.fieldsMeta(),
+desc0.affFieldKeyName(),
+schemas, desc0.isEnum());
+
+metaHnd.addMeta(desc0.typeId(), meta.wrap(this));
+
+return desc0;
+}
+}
+else
+desc = registerUserClassDescriptor(desc);
 }
 
 return desc;
@@ -959,7 +987,7 @@ public class BinaryContext {
  * @return GridBinaryClassDescriptor.
  */
 public BinaryClassDescriptor registerPredefinedType(Class cls, int id) {
-return registerPredefinedType(cls, id, null);
+return registerPredefinedType(cls, id, null, true);
 }
 
 /**
@@ -968,7 +996,7 @@ public class BinaryContext {
  * @param affFieldName Affinity field name.
  * @return GridBinaryClassDescriptor.
  */
-public BinaryClassDescriptor registerPredefinedType(Class cls, int id, 
String affFieldName) {
+public BinaryClassDescriptor registerPredefinedType(Class cls, int id, 
String affFieldName, boolean registered) {
 String simpleClsName = 
SIMPLE_NAME_LOWER_CASE_MAPPER.typeName(cls.getName());
 
 if (id == 0)
@@ -984,7 +1012,7 @@ public class BinaryContext {
 SIMPLE_NAME_LOWER_CASE_MAPPER,
 new BinaryReflectiveSerializer(),
 false,
-true /* registered */
+registered /* registered */
 );
 
 predefinedTypeNames.put(simpleClsName, id);
@@ -995,15 +1023,6 @@ public class BinaryContext {
 if (affFieldName != null)
 affKeyFieldNames.putIfAbsent(id, affFieldName);
 
-if (affFieldName != null) {
-metaHnd.addMeta(id, new BinaryMetadata(id,
-simpleClsName,
-desc.fieldsMeta(),
-affFieldName,
-desc.schema() != null ?