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 2016/04/11 17:43:17 UTC
[01/50] [abbrv] ignite git commit: IGNITE-2849: BinaryObjectBuilder
doesn't properly check metadata
Repository: ignite
Updated Branches:
refs/heads/ignite-1837 [created] 08f465837
IGNITE-2849: BinaryObjectBuilder doesn't properly check metadata
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d36a2e51
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d36a2e51
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d36a2e51
Branch: refs/heads/ignite-1837
Commit: d36a2e51e3aa3105dff73839c84e52a531fbd918
Parents: 9e84e50
Author: Denis Magda <dm...@gridgain.com>
Authored: Thu Mar 24 20:07:48 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Mon Mar 28 17:34:19 2016 +0300
----------------------------------------------------------------------
.../cache/store/jdbc/CacheJdbcPojoStore.java | 2 +-
.../ignite/internal/binary/BinaryUtils.java | 16 ---
.../binary/builder/BinaryObjectBuilderImpl.java | 107 ++++++++------
.../BinaryObjectBuilderAdditionalSelfTest.java | 144 +++++++++++++++++--
...naryObjectBuilderDefaultMappersSelfTest.java | 2 +-
5 files changed, 197 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d36a2e51/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
index 200aa0f..b9a3118 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java
@@ -248,7 +248,7 @@ public class CacheJdbcPojoStore<K, V> extends CacheAbstractJdbcStore<K, V> {
Object colVal = getColumnValue(rs, colIdx, field.getJavaFieldType());
- builder.setField(field.getJavaFieldName(), colVal);
+ builder.setField(field.getJavaFieldName(), colVal, (Class<Object>)field.getJavaFieldType());
if (calcHash)
hashValues.add(colVal);
http://git-wip-us.apache.org/repos/asf/ignite/blob/d36a2e51/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index 4a79f22..eefdc3f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -317,22 +317,6 @@ public class BinaryUtils {
}
/**
- * @param typeName Field type name.
- * @return Field type ID;
- */
- @SuppressWarnings("StringEquality")
- public static int fieldTypeId(String typeName) {
- for (int i = 0; i < FIELD_TYPE_NAMES.length; i++) {
- String typeName0 = FIELD_TYPE_NAMES[i];
-
- if (typeName.equals(typeName0))
- return i;
- }
-
- throw new IllegalArgumentException("Invalid metadata type name: " + typeName);
- }
-
- /**
* @param typeId Field type ID.
* @return Field type name.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/d36a2e51/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
index 9043a8b..16c51b0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
@@ -195,6 +195,10 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
Set<Integer> remainsFlds = null;
+ BinaryType meta = ctx.metadata(typeId);
+
+ Map<String, Integer> fieldsMeta = null;
+
if (reader != null) {
BinarySchema schema = reader.schema();
@@ -204,9 +208,15 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
assignedFldsById = U.newHashMap(assignedVals.size());
for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
- int fieldId = ctx.fieldId(typeId, entry.getKey());
+ String name = entry.getKey();
+ Object val = entry.getValue();
+
+ int fieldId = ctx.fieldId(typeId, name);
- assignedFldsById.put(fieldId, entry.getValue());
+ assignedFldsById.put(fieldId, val);
+
+ if (val != REMOVED_FIELD_MARKER)
+ fieldsMeta = checkMetadata(meta, fieldsMeta, val, name);
}
remainsFlds = assignedFldsById.keySet();
@@ -280,10 +290,6 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
}
}
- BinaryType meta = ctx.metadata(typeId);
-
- Map<String, Integer> fieldsMeta = null;
-
if (assignedVals != null && (remainsFlds == null || !remainsFlds.isEmpty())) {
for (Map.Entry<String, Object> entry : assignedVals.entrySet()) {
Object val = entry.getValue();
@@ -302,43 +308,9 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
serializer.writeValue(writer, val);
- String oldFldTypeName = meta == null ? null : meta.fieldTypeName(name);
-
- boolean nullObjField = false;
-
- int newFldTypeId;
-
- if (val instanceof BinaryValueWithType) {
- newFldTypeId = ((BinaryValueWithType)val).typeId();
-
- if (newFldTypeId == GridBinaryMarshaller.OBJ && ((BinaryValueWithType)val).value() == null)
- nullObjField = true;
- }
- else
- newFldTypeId = BinaryUtils.typeByClass(val.getClass());
-
- String newFldTypeName = BinaryUtils.fieldTypeName(newFldTypeId);
-
- if (oldFldTypeName == null) {
- // It's a new field, we have to add it to metadata.
- if (fieldsMeta == null)
- fieldsMeta = new HashMap<>();
-
- fieldsMeta.put(name, BinaryUtils.fieldTypeId(newFldTypeName));
- }
- else if (!nullObjField) {
- String objTypeName = BinaryUtils.fieldTypeName(GridBinaryMarshaller.OBJ);
-
- if (!objTypeName.equals(oldFldTypeName) && !oldFldTypeName.equals(newFldTypeName)) {
- throw new BinaryObjectException(
- "Wrong value has been set [" +
- "typeName=" + (typeName == null ? meta.typeName() : typeName) +
- ", fieldName=" + name +
- ", fieldType=" + oldFldTypeName +
- ", assignedValueType=" + newFldTypeName + ']'
- );
- }
- }
+ if (reader == null)
+ // Metadata has already been checked.
+ fieldsMeta = checkMetadata(meta, fieldsMeta, val, name);
}
}
@@ -386,6 +358,55 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
}
}
+ /**
+ * Checks metadata when a BinaryObject is being serialized.
+ *
+ * @param meta Current metadata.
+ * @param fieldsMeta Map holding metadata information that has to be updated.
+ * @param newVal Field value being serialized.
+ * @param name Field name.
+ */
+ private Map<String, Integer> checkMetadata(BinaryType meta, Map<String, Integer> fieldsMeta, Object newVal,
+ String name) {
+ String oldFldTypeName = meta == null ? null : meta.fieldTypeName(name);
+
+ boolean nullFieldVal = false;
+
+ int newFldTypeId;
+
+ if (newVal instanceof BinaryValueWithType) {
+ newFldTypeId = ((BinaryValueWithType)newVal).typeId();
+
+ if (((BinaryValueWithType)newVal).value() == null)
+ nullFieldVal = true;
+ }
+ else
+ newFldTypeId = BinaryUtils.typeByClass(newVal.getClass());
+
+ if (oldFldTypeName == null) {
+ // It's a new field, we have to add it to metadata.
+ if (fieldsMeta == null)
+ fieldsMeta = new HashMap<>();
+
+ fieldsMeta.put(name, newFldTypeId);
+ }
+ else if (!nullFieldVal) {
+ String newFldTypeName = BinaryUtils.fieldTypeName(newFldTypeId);
+
+ if (!F.eq(newFldTypeName, oldFldTypeName)) {
+ throw new BinaryObjectException(
+ "Wrong value has been set [" +
+ "typeName=" + (typeName == null ? meta.typeName() : typeName) +
+ ", fieldName=" + name +
+ ", fieldType=" + oldFldTypeName +
+ ", assignedValueType=" + newFldTypeName + ']'
+ );
+ }
+ }
+
+ return fieldsMeta;
+ }
+
/** {@inheritDoc} */
@Override public BinaryObjectBuilderImpl hashCode(int hashCode) {
this.hashCode = hashCode;
http://git-wip-us.apache.org/repos/asf/ignite/blob/d36a2e51/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
index 804c060..e3e538b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
@@ -26,6 +26,7 @@ import org.apache.ignite.IgniteBinary;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -234,7 +235,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
public void testDateArrayModification() {
GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
- obj.dateArr = new Date[] {new Date(11111), new Date(11111), new Date(11111)};
+ obj.dateArr = new Date[] {new Date(11111), new Date(11111), new Date(11111)};
BinaryObjectBuilderImpl mutObj = wrap(obj);
@@ -498,7 +499,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
Object[] createdArr = {mutObj, "a", 1, new String[] {"s", "s"}, new byte[] {1, 2}, new UUID(3, 0)};
- mutObj.setField("foo", createdArr.clone());
+ mutObj.setField("foo", createdArr.clone(), Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
@@ -555,7 +556,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
ArrayList<Object> list = Lists.newArrayList(mutObj, "a", Lists.newArrayList(1, 2));
- mutObj.setField("foo", list);
+ mutObj.setField("foo", list, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
@@ -653,7 +654,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
List<Object> list = Lists.newLinkedList(Arrays.asList(mutObj, "a", Lists.newLinkedList(Arrays.asList(1, 2))));
- mutObj.setField("foo", list);
+ mutObj.setField("foo", list, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
@@ -736,7 +737,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
Set<Object> c = Sets.newHashSet(mutObj, "a", Sets.newHashSet(1, 2));
- mutObj.setField("foo", c);
+ mutObj.setField("foo", c, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
@@ -815,7 +816,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
Map<Object, Object> map = Maps.newHashMap(ImmutableMap.of(mutObj, "a", "b", mutObj));
- mutObj.setField("foo", map);
+ mutObj.setField("foo", map, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutObj.build().deserialize();
@@ -995,6 +996,123 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
/**
*
*/
+ public void testWrongMetadataNullField() {
+ BinaryObjectBuilder builder = binaries().builder("SomeType");
+
+ builder.setField("dateField", null);
+
+ builder.setField("objectField", null, Integer.class);
+
+ builder.build();
+
+ try {
+ builder = binaries().builder("SomeType");
+
+ builder.setField("dateField", new Date());
+
+ builder.build();
+ }
+ catch (BinaryObjectException ex) {
+ assertTrue(ex.getMessage().startsWith("Wrong value has been set"));
+ }
+
+ builder = binaries().builder("SomeType");
+
+ try {
+ builder.setField("objectField", new GridBinaryTestClasses.Company());
+
+ builder.build();
+
+ fail("BinaryObjectBuilder accepted wrong metadata");
+ }
+ catch (BinaryObjectException ex) {
+ assertTrue(ex.getMessage().startsWith("Wrong value has been set"));
+ }
+ }
+
+ /**
+ *
+ */
+ public void testWrongMetadataNullField2() {
+ BinaryObjectBuilder builder = binaries().builder("SomeType1");
+
+ builder.setField("dateField", null);
+
+ builder.setField("objectField", null, Integer.class);
+
+ BinaryObject obj = builder.build();
+
+ try {
+ builder = binaries().builder(obj);
+
+ builder.setField("dateField", new Date());
+
+ builder.build();
+ }
+ catch (BinaryObjectException ex) {
+ assertTrue(ex.getMessage().startsWith("Wrong value has been set"));
+ }
+
+ builder = binaries().builder(obj);
+
+ try {
+ builder.setField("objectField", new GridBinaryTestClasses.Company());
+
+ builder.build();
+
+ fail("BinaryObjectBuilder accepted wrong metadata");
+ }
+ catch (BinaryObjectException ex) {
+ assertTrue(ex.getMessage().startsWith("Wrong value has been set"));
+ }
+ }
+
+ /**
+ *
+ */
+ public void testCorrectMetadataNullField() {
+ BinaryObjectBuilder builder = binaries().builder("SomeType2");
+
+ builder.setField("dateField", null, Date.class);
+
+ builder.setField("objectField", null, GridBinaryTestClasses.Company.class);
+
+ builder.build();
+
+ builder = binaries().builder("SomeType2");
+
+ builder.setField("dateField", new Date());
+
+ builder.setField("objectField", new GridBinaryTestClasses.Company());
+
+ builder.build();
+
+ }
+
+ /**
+ *
+ */
+ public void testCorrectMetadataNullField2() {
+ BinaryObjectBuilder builder = binaries().builder("SomeType3");
+
+ builder.setField("dateField", null, Date.class);
+
+ builder.setField("objectField", null, GridBinaryTestClasses.Company.class);
+
+ BinaryObject obj = builder.build();
+
+ builder = binaries().builder(obj);
+
+ builder.setField("dateField", new Date());
+
+ builder.setField("objectField", new GridBinaryTestClasses.Company());
+
+ builder.build();
+ }
+
+ /**
+ *
+ */
public void testDateInObjectField() {
GridBinaryTestClasses.TestObjectContainer obj = new GridBinaryTestClasses.TestObjectContainer();
@@ -1053,9 +1171,9 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
BinaryObjectBuilderImpl mutableObj = wrap(obj);
- Date[] arr = { new Date() };
+ Date[] arr = {new Date()};
- mutableObj.setField("foo", arr);
+ mutableObj.setField("foo", arr, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutableObj.build().deserialize();
@@ -1072,9 +1190,9 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
BinaryObjectBuilderImpl mutableObj = wrap(obj);
- Timestamp[] arr = { new Timestamp(100020003) };
+ Timestamp[] arr = {new Timestamp(100020003)};
- mutableObj.setField("foo", arr);
+ mutableObj.setField("foo", arr, Object.class);
GridBinaryTestClasses.TestObjectContainer res = mutableObj.build().deserialize();
@@ -1264,7 +1382,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
CacheObjectBinaryProcessorImpl processor = (CacheObjectBinaryProcessorImpl)(
(IgniteBinaryImpl)binaries()).processor();
- return new BinaryObjectBuilderImpl(processor.binaryContext(), processor.typeId(aCls.getName()),
+ return new BinaryObjectBuilderImpl(processor.binaryContext(), processor.typeId(aCls.getName()),
processor.binaryContext().userTypeName(aCls.getName()));
}
@@ -1305,7 +1423,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
root.setField("linkedHashSet", linkedHashSet);
root.setField("singletonList", Collections.singletonList(Integer.MAX_VALUE), Collection.class);
- root.setField("singletonSet", Collections.singleton(Integer.MAX_VALUE), Collection.class);
+ root.setField("singletonSet", Collections.singleton(Integer.MAX_VALUE), Collection.class);
// maps
root.setField("hashMap", hashMap);
@@ -1319,7 +1437,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
root.setField("asMap", Collections.singletonMap("key", "val"));
root.setField("asListHint", Collections.singletonList(Integer.MAX_VALUE), List.class);
root.setField("asSetHint", Collections.singleton(Integer.MAX_VALUE), Set.class);
- root.setField("asMapHint", (AbstractMap) Collections.singletonMap("key", "val"), AbstractMap.class);
+ root.setField("asMapHint", (AbstractMap)Collections.singletonMap("key", "val"), AbstractMap.class);
BinaryObject binaryObj = root.build();
http://git-wip-us.apache.org/repos/asf/ignite/blob/d36a2e51/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
index 61b2731..fcf4413 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
@@ -151,7 +151,7 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
builder = builder(obj);
- builder.setField("objField", "value");
+ builder.setField("objField", "value", Object.class);
builder.setField("otherField", (Object)null);
obj = builder.build();
[40/50] [abbrv] ignite git commit: ignite-2835: Fixed
BinaryObjectOffHeapImpl leakage to public code
Posted by sb...@apache.org.
ignite-2835: Fixed BinaryObjectOffHeapImpl leakage to public code
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e85a7170
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e85a7170
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e85a7170
Branch: refs/heads/ignite-1837
Commit: e85a7170534cb66f40386cba689cfe632f4e66db
Parents: ec2ec99
Author: ashutak <as...@gridgain.com>
Authored: Tue Apr 5 14:56:01 2016 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Tue Apr 5 14:56:01 2016 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheMapEntry.java | 7 +-
.../transactions/IgniteTxLocalAdapter.java | 2 +-
.../BinaryObjectOffHeapUnswapTemporaryTest.java | 370 +++++++++++++++++++
.../GridCacheBinaryObjectsAbstractSelfTest.java | 181 ++++++---
.../IgniteBinaryObjectsTestSuite.java | 4 +-
5 files changed, 510 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e85a7170/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 5519070..83f5d5c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -34,6 +34,7 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.eviction.EvictableEntry;
+import org.apache.ignite.internal.binary.BinaryObjectOffheapImpl;
import org.apache.ignite.internal.managers.deployment.GridDeploymentInfo;
import org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
@@ -898,9 +899,12 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
}
- if (ret != null)
+ if (ret != null) {
+ assert tmp || !(ret instanceof BinaryObjectOffheapImpl);
+
// If return value is consistent, then done.
return retVer ? new T2<>(ret, resVer) : ret;
+ }
boolean loadedFromStore = false;
@@ -974,6 +978,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
assert ret == null || !retVer;
+ assert tmp || !(ret instanceof BinaryObjectOffheapImpl);
return ret;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e85a7170/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index fef91c8..785e937 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -1893,7 +1893,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
/*unmarshal*/true,
/*metrics*/true,
/*events*/!skipVals,
- /*temporary*/true,
+ /*temporary*/false,
CU.subjectId(IgniteTxLocalAdapter.this, cctx),
transformClo,
resolveTaskName(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/e85a7170/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java
new file mode 100644
index 0000000..4272a14
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java
@@ -0,0 +1,370 @@
+/*
+ * 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.cache;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.binary.BinaryObjectOffheapImpl;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_VALUES;
+
+/**
+ *
+ */
+public class BinaryObjectOffHeapUnswapTemporaryTest extends GridCommonAbstractTest {
+ /** */
+ private static final int CNT = 20;
+
+ /** */
+ @SuppressWarnings("serial")
+ private static final CacheEntryProcessor PROC = new CacheEntryProcessor() {
+ @Override public Object process(MutableEntry entry, Object... arguments) throws EntryProcessorException {
+ return entry.getValue();
+ }
+ };
+
+ /** */
+ private CacheAtomicityMode atomicityMode;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration c = super.getConfiguration(gridName);
+
+ c.setMarshaller(new BinaryMarshaller());
+
+ return c;
+ }
+
+ /**
+ * @param atomicityMode Atomicity mode.
+ * @param memoryMode Memory mode.
+ * @return Cache configuration.
+ */
+ private CacheConfiguration<Object, Object> cacheConfiguration(CacheAtomicityMode atomicityMode,
+ CacheMemoryMode memoryMode) {
+ this.atomicityMode = atomicityMode;
+
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setCacheMode(CacheMode.PARTITIONED);
+ cfg.setAtomicityMode(atomicityMode);
+ cfg.setMemoryMode(memoryMode);
+ cfg.setBackups(1);
+ cfg.setSwapEnabled(true);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGridsMultiThreaded(3);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxOffheapTiered() throws Exception {
+ ignite(0).getOrCreateCache(cacheConfiguration(TRANSACTIONAL, OFFHEAP_TIERED));
+
+ try {
+ doTest();
+ }
+ finally {
+ ignite(0).destroyCache(null);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxOffheapValues() throws Exception {
+ ignite(0).getOrCreateCache(cacheConfiguration(TRANSACTIONAL, OFFHEAP_VALUES));
+
+ try {
+ doTest();
+ }
+ finally {
+ ignite(0).destroyCache(null);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAtomicOffheapTiered() throws Exception {
+ ignite(0).getOrCreateCache(cacheConfiguration(ATOMIC, OFFHEAP_TIERED));
+
+ try {
+ doTest();
+ }
+ finally {
+ ignite(0).destroyCache(null);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAtomicOffheapValues() throws Exception {
+ ignite(0).getOrCreateCache(cacheConfiguration(ATOMIC, OFFHEAP_VALUES));
+
+ try {
+ doTest();
+ }
+ finally {
+ ignite(0).destroyCache(null);
+ }
+ }
+
+ /**
+ *
+ */
+ private void doTest() {
+ final IgniteCache<Integer, BinaryObject> cache = jcache(0).withKeepBinary();
+
+ for (int key = 0; key < CNT; key++)
+ jcache(0).put(key, new TestObject(key));
+
+ for (int key = CNT; key < 2 * CNT; key++) {
+ BinaryObjectBuilder builder = ignite(0).binary().builder("SomeType");
+ builder.setField("field1", key);
+ builder.setField("field2", "name_" + key);
+
+ cache.put(key, builder.build());
+ }
+
+ Set<Integer> keys = new LinkedHashSet<>();
+
+ for (int i = 0; i < 2 * CNT; i++)
+ keys.add(i);
+
+ check(new TestCheck<Integer>() {
+ @Override public void check(Integer key) {
+ assertFalse(cache.get(key) instanceof BinaryObjectOffheapImpl);
+ }
+ });
+
+ check(new TestCheck<Integer>() {
+ @Override public void check(Integer key) {
+ assertFalse(cache.getEntry(key) instanceof BinaryObjectOffheapImpl);
+ }
+ });
+
+ check(new TestCheck<Integer>() {
+ @Override public void check(Integer key) {
+ assertFalse(cache.getAndPut(key, cache.get(key)) instanceof BinaryObjectOffheapImpl);
+ }
+ });
+
+ check(new TestCheck<Integer>() {
+ @Override public void check(Integer key) {
+ assertFalse(cache.getAndReplace(key, cache.get(key)) instanceof BinaryObjectOffheapImpl);
+ }
+ });
+
+ check(new TestCheck<Integer>() {
+ @Override public void check(Integer key) {
+ assertFalse(cache.getAndPutIfAbsent(key, cache.get(key)) instanceof BinaryObjectOffheapImpl);
+ }
+ });
+
+ check(new TestCheck<Integer>() {
+ @Override public void check(Integer key) {
+ assertFalse(cache.localPeek(key) instanceof BinaryObjectOffheapImpl);
+ }
+ });
+
+ check(new TestCheck<Integer>() {
+ @Override public void check(Integer key) {
+ assertFalse(cache.getAndRemove(key) instanceof BinaryObjectOffheapImpl);
+ }
+ });
+
+ check(new TestCheck<Integer>() {
+ @Override public void check(Integer key) {
+ assertFalse(cache.invoke(key, PROC) instanceof BinaryObjectOffheapImpl);
+ }
+ });
+
+ // GetAll.
+ Map<Integer, BinaryObject> res = cache.getAll(keys);
+
+ for (BinaryObject val : res.values())
+ assertFalse(val instanceof BinaryObjectOffheapImpl);
+
+ if (atomicityMode == TRANSACTIONAL) {
+ for (TransactionIsolation isolation : TransactionIsolation.values()) {
+ for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
+ try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
+ res = cache.getAll(keys);
+
+ for (BinaryObject val : res.values())
+ assertFalse(val instanceof BinaryObjectOffheapImpl);
+
+ tx.commit();
+ }
+ }
+ }
+ }
+
+ // GetAllOutTx.
+ res = cache.getAllOutTx(keys);
+
+ for (BinaryObject val : res.values())
+ assertFalse(val instanceof BinaryObjectOffheapImpl);
+
+ if (atomicityMode == TRANSACTIONAL) {
+ for (TransactionIsolation isolation : TransactionIsolation.values()) {
+ for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
+ try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
+ res = cache.getAllOutTx(keys);
+
+ for (BinaryObject val : res.values())
+ assertFalse(val instanceof BinaryObjectOffheapImpl);
+
+ tx.commit();
+ }
+ }
+ }
+ }
+
+ // InvokeAll.
+ res = cache.invokeAll(keys, PROC);
+
+ for (BinaryObject val : res.values())
+ assertFalse(val instanceof BinaryObjectOffheapImpl);
+
+ if (atomicityMode == TRANSACTIONAL) {
+ for (TransactionIsolation isolation : TransactionIsolation.values()) {
+ for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
+ try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
+ res = cache.invokeAll(keys, PROC);
+
+ for (BinaryObject val : res.values())
+ assertFalse(val instanceof BinaryObjectOffheapImpl);
+
+ tx.commit();
+ }
+ }
+ }
+ }
+
+ // GetEntries.
+ Collection<CacheEntry<Integer, BinaryObject>> entries = cache.getEntries(keys);
+
+ for (CacheEntry<Integer, BinaryObject> e : entries)
+ assertFalse(e.getValue() instanceof BinaryObjectOffheapImpl);
+
+ if (atomicityMode == TRANSACTIONAL) {
+ for (TransactionIsolation isolation : TransactionIsolation.values()) {
+ for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
+ try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
+ entries = cache.getEntries(keys);
+
+ for (CacheEntry<Integer, BinaryObject> e : entries)
+ assertFalse(e.getValue() instanceof BinaryObjectOffheapImpl);
+
+ tx.commit();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private void check(TestCheck<Integer> checkOp) {
+ for (int key = 0; key < 2 * CNT; key++) {
+ checkOp.check(key);
+
+ if (atomicityMode == TRANSACTIONAL) {
+ for (TransactionIsolation isolation : TransactionIsolation.values()) {
+ for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
+ try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
+ checkOp.check(key);
+
+ tx.commit();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings("PackageVisibleField")
+ private static class TestObject {
+ /** */
+ String field;
+
+ /** */
+ int field2;
+
+ /**
+ * @param key Key.
+ */
+ TestObject(int key) {
+ field = "str" + key;
+ field2 = key;
+ }
+ }
+
+ /**
+ *
+ */
+ private static interface TestCheck<T> {
+ /**
+ * @param t Parameter.
+ */
+ public void check(T t);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e85a7170/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
index 36a9450..f776146 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
@@ -29,9 +29,15 @@ import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.IgniteCache;
import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CachePeekMode;
@@ -41,7 +47,9 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.binary.BinaryContext;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.binary.BinaryObjectImpl;
+import org.apache.ignite.internal.binary.BinaryObjectOffheapImpl;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
@@ -49,13 +57,6 @@ import org.apache.ignite.internal.util.typedef.P2;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiInClosure;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
-import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.binary.BinaryWriter;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -421,17 +422,33 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
/**
* @throws Exception If failed.
*/
- public void testGetTx() throws Exception {
+ public void testGetTx1() throws Exception {
+ checkGetTx(PESSIMISTIC, REPEATABLE_READ);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetTx2() throws Exception {
+ checkGetTx(PESSIMISTIC, READ_COMMITTED);
+ }
+
+ /**
+ * @param concurrency Concurrency.
+ * @param isolation Isolation.
+ */
+ private void checkGetTx(TransactionConcurrency concurrency, TransactionIsolation isolation) {
if (atomicityMode() != TRANSACTIONAL)
return;
IgniteCache<Integer, TestObject> c = jcache(0);
+ IgniteCache<Integer, BinaryObject> kbCache = keepBinaryCache();
for (int i = 0; i < ENTRY_CNT; i++)
c.put(i, new TestObject(i));
for (int i = 0; i < ENTRY_CNT; i++) {
- try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
TestObject obj = c.get(i);
assertEquals(i, obj.val);
@@ -441,32 +458,75 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
}
for (int i = 0; i < ENTRY_CNT; i++) {
- try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) {
- TestObject obj = c.get(i);
+ try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
+ BinaryObject val = kbCache.get(i);
- assertEquals(i, obj.val);
+ assertFalse("Key=" + i, val instanceof BinaryObjectOffheapImpl);
+
+ assertEquals(i, (int)val.field("val"));
+
+ kbCache.put(i, val);
tx.commit();
}
}
+ }
- IgniteCache<Integer, BinaryObject> kpc = keepBinaryCache();
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetTxAsync1() throws Exception {
+ checkGetAsyncTx(PESSIMISTIC, REPEATABLE_READ);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetTxAsync2() throws Exception {
+ checkGetAsyncTx(PESSIMISTIC, READ_COMMITTED);
+ }
+
+ /**
+ * @param concurrency Concurrency.
+ * @param isolation Isolation.
+ */
+ private void checkGetAsyncTx(TransactionConcurrency concurrency, TransactionIsolation isolation) {
+ if (atomicityMode() != TRANSACTIONAL)
+ return;
+
+ IgniteCache<Integer, TestObject> c = jcache(0);
+ IgniteCache<Integer, TestObject> cAsync = c.withAsync();
+ IgniteCache<Integer, BinaryObject> kbCache = keepBinaryCache();
+ IgniteCache<Integer, BinaryObject> kbCacheAsync = kbCache.withAsync();
+
+ for (int i = 0; i < ENTRY_CNT; i++)
+ c.put(i, new TestObject(i));
for (int i = 0; i < ENTRY_CNT; i++) {
- try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
- BinaryObject po = kpc.get(i);
+ try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
+ cAsync.get(i);
- assertEquals(i, (int)po.field("val"));
+ TestObject obj = (TestObject)cAsync.future().get();
+
+ assertEquals(i, obj.val);
tx.commit();
}
}
for (int i = 0; i < ENTRY_CNT; i++) {
- try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) {
- BinaryObject po = kpc.get(i);
+ try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
+ kbCacheAsync.get(i);
- assertEquals(i, (int)po.field("val"));
+ BinaryObject val = (BinaryObject)kbCacheAsync.future().get();
+
+ assertFalse("Key=" + i, val instanceof BinaryObjectOffheapImpl);
+
+ assertEquals(i, (int)val.field("val"));
+
+ kbCacheAsync.put(i, val);
+
+ kbCacheAsync.future().get();
tx.commit();
}
@@ -606,11 +666,27 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
/**
* @throws Exception If failed.
*/
- public void testGetAllTx() throws Exception {
+ public void testGetAllTx1() throws Exception {
+ checkGetAllTx(PESSIMISTIC, REPEATABLE_READ);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAllTx2() throws Exception {
+ checkGetAllTx(PESSIMISTIC, READ_COMMITTED);
+ }
+
+ /**
+ * @param concurrency Concurrency.
+ * @param isolation Isolation.
+ */
+ private void checkGetAllTx(TransactionConcurrency concurrency, TransactionIsolation isolation) {
if (atomicityMode() != TRANSACTIONAL)
return;
IgniteCache<Integer, TestObject> c = jcache(0);
+ IgniteCache<Integer, BinaryObject> kpc = keepBinaryCache();
for (int i = 0; i < ENTRY_CNT; i++)
c.put(i, new TestObject(i));
@@ -621,18 +697,7 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
for (int j = 0; j < 10; j++)
keys.add(i++);
- try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
- Map<Integer, TestObject> objs = c.getAll(keys);
-
- assertEquals(10, objs.size());
-
- for (Map.Entry<Integer, TestObject> e : objs.entrySet())
- assertEquals(e.getKey().intValue(), e.getValue().val);
-
- tx.commit();
- }
-
- try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) {
+ try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
Map<Integer, TestObject> objs = c.getAll(keys);
assertEquals(10, objs.size());
@@ -644,32 +709,26 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
}
}
- IgniteCache<Integer, BinaryObject> kpc = keepBinaryCache();
-
for (int i = 0; i < ENTRY_CNT; ) {
Set<Integer> keys = new HashSet<>();
for (int j = 0; j < 10; j++)
keys.add(i++);
- try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
Map<Integer, BinaryObject> objs = kpc.getAll(keys);
assertEquals(10, objs.size());
- for (Map.Entry<Integer, BinaryObject> e : objs.entrySet())
- assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val"));
-
- tx.commit();
- }
+ for (Map.Entry<Integer, BinaryObject> e : objs.entrySet()) {
+ BinaryObject val = e.getValue();
- try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, READ_COMMITTED)) {
- Map<Integer, BinaryObject> objs = kpc.getAll(keys);
+ assertEquals(new Integer(e.getKey().intValue()), val.field("val"));
- assertEquals(10, objs.size());
+ kpc.put(e.getKey(), val);
- for (Map.Entry<Integer, BinaryObject> e : objs.entrySet())
- assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val"));
+ assertFalse("Key=" + i, val instanceof BinaryObjectOffheapImpl);
+ }
tx.commit();
}
@@ -679,7 +738,22 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
/**
* @throws Exception If failed.
*/
- public void testGetAllAsyncTx() throws Exception {
+ public void testGetAllAsyncTx1() throws Exception {
+ checkGetAllAsyncTx(PESSIMISTIC, REPEATABLE_READ);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAllAsyncTx2() throws Exception {
+ checkGetAllAsyncTx(PESSIMISTIC, READ_COMMITTED);
+ }
+
+ /**
+ * @param concurrency Concurrency.
+ * @param isolation Isolation.
+ */
+ private void checkGetAllAsyncTx(TransactionConcurrency concurrency, TransactionIsolation isolation) {
if (atomicityMode() != TRANSACTIONAL)
return;
@@ -695,7 +769,7 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
for (int j = 0; j < 10; j++)
keys.add(i++);
- try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
cacheAsync.getAll(keys);
Map<Integer, TestObject> objs = cacheAsync.<Map<Integer, TestObject>>future().get();
@@ -719,15 +793,20 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
IgniteCache<Integer, BinaryObject> asyncCache = cache.withAsync();
- try (Transaction tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ try (Transaction tx = grid(0).transactions().txStart(concurrency, isolation)) {
asyncCache.getAll(keys);
Map<Integer, BinaryObject> objs = asyncCache.<Map<Integer, BinaryObject>>future().get();
assertEquals(10, objs.size());
- for (Map.Entry<Integer, BinaryObject> e : objs.entrySet())
- assertEquals(new Integer(e.getKey().intValue()), e.getValue().field("val"));
+ for (Map.Entry<Integer, BinaryObject> e : objs.entrySet()) {
+ BinaryObject val = e.getValue();
+
+ assertEquals(new Integer(e.getKey().intValue()), val.field("val"));
+
+ assertFalse("Key=" + e.getKey(), val instanceof BinaryObjectOffheapImpl);
+ }
tx.commit();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e85a7170/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
index 5eb7b66..2b49597 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
@@ -44,6 +44,7 @@ import org.apache.ignite.internal.binary.noncompact.BinaryMarshallerNonCompactSe
import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderAdditionalNonCompactSelfTest;
import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactDefaultMappersSelfTest;
import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest;
+import org.apache.ignite.internal.processors.cache.BinaryObjectOffHeapUnswapTemporaryTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesDefaultMappersSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreObjectsSelfTest;
@@ -77,7 +78,7 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
TestSuite suite = new TestSuite("Ignite Binary Objects Test Suite");
suite.addTestSuite(BinarySimpleNameTestPropertySelfTest.class);
-
+
suite.addTestSuite(BinaryBasicIdMapperSelfTest.class);
suite.addTestSuite(BinaryBasicNameMapperSelfTest.class);
@@ -114,6 +115,7 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
suite.addTestSuite(GridCacheBinaryObjectsPartitionedNearDisabledSelfTest.class);
suite.addTestSuite(GridCacheBinaryObjectsAtomicSelfTest.class);
suite.addTestSuite(GridCacheBinaryObjectsAtomicNearDisabledSelfTest.class);
+ suite.addTestSuite(BinaryObjectOffHeapUnswapTemporaryTest.class);
suite.addTestSuite(GridCacheBinaryObjectsLocalOffheapTieredSelfTest.class);
suite.addTestSuite(GridCacheBinaryObjectsAtomicOffheapTieredSelfTest.class);
[03/50] [abbrv] ignite git commit: IGNITE-1788: Removed duplicate
check of a single invariant from IgfsProcessor. This closes #221.
Posted by sb...@apache.org.
IGNITE-1788: Removed duplicate check of a single invariant from IgfsProcessor. This closes #221.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/85a675b7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/85a675b7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/85a675b7
Branch: refs/heads/ignite-1837
Commit: 85a675b7bfbc54745ee9ce95d5786b5bae5be963
Parents: 9e62b66
Author: iveselovskiy <iv...@gridgain.com>
Authored: Mon Jan 18 17:28:42 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:11:58 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/processors/igfs/IgfsProcessor.java | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/85a675b7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
index 5b8cf86..21446e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
@@ -297,9 +297,6 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
if (GridQueryProcessor.isEnabled(metaCacheCfg))
throw new IgniteCheckedException("IGFS metadata cache cannot start with enabled query indexing.");
- if (GridQueryProcessor.isEnabled(metaCacheCfg))
- throw new IgniteCheckedException("IGFS metadata cache cannot start with enabled query indexing.");
-
if (metaCacheCfg.getAtomicityMode() != TRANSACTIONAL)
throw new IgniteCheckedException("Meta cache should be transactional: " + cfg.getMetaCacheName());
[02/50] [abbrv] ignite git commit: IGNITE-2801 Coordinator floods
network with partitions full map exchange messages
Posted by sb...@apache.org.
IGNITE-2801 Coordinator floods network with partitions full map exchange messages
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9e62b667
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9e62b667
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9e62b667
Branch: refs/heads/ignite-1837
Commit: 9e62b667e73396d3affbc4d1e62449d07d08ec8b
Parents: d36a2e5
Author: Anton Vinogradov <av...@apache.org>
Authored: Tue Mar 29 14:56:21 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue Mar 29 14:56:21 2016 +0300
----------------------------------------------------------------------
.../GridCachePartitionExchangeManager.java | 8 +-
...cingDelayedPartitionMapExchangeSelfTest.java | 14 +-
.../GridCacheRebalancingSyncSelfTest.java | 187 ++++++++++++++++++-
.../junits/common/GridCommonAbstractTest.java | 53 +++++-
4 files changed, 238 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9e62b667/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 1681f2f..b54116c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -1264,13 +1264,9 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
break;
}
- // If not first preloading and no more topology events present,
- // then we periodically refresh partition map.
- if (!cctx.kernalContext().clientNode() && futQ.isEmpty() && preloadFinished) {
- refreshPartitions(timeout);
-
+ // If not first preloading and no more topology events present.
+ if (!cctx.kernalContext().clientNode() && futQ.isEmpty() && preloadFinished)
timeout = cctx.gridConfig().getNetworkTimeout();
- }
// After workers line up and before preloading starts we initialize all futures.
if (log.isDebugEnabled())
http://git-wip-us.apache.org/repos/asf/ignite/blob/9e62b667/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRabalancingDelayedPartitionMapExchangeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRabalancingDelayedPartitionMapExchangeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRabalancingDelayedPartitionMapExchangeSelfTest.java
index 2890fcb..2c47a1c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRabalancingDelayedPartitionMapExchangeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRabalancingDelayedPartitionMapExchangeSelfTest.java
@@ -24,6 +24,7 @@ import org.apache.ignite.cache.CacheRebalanceMode;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.managers.communication.GridIoMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -99,7 +100,7 @@ public class GridCacheRabalancingDelayedPartitionMapExchangeSelfTest extends Gri
* @throws Exception e.
*/
public void test() throws Exception {
- startGrid(0);
+ IgniteKernal ignite = (IgniteKernal)startGrid(0);
CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>();
@@ -114,26 +115,29 @@ public class GridCacheRabalancingDelayedPartitionMapExchangeSelfTest extends Gri
startGrid(2);
startGrid(3);
- awaitPartitionMapExchange(true);
+ awaitPartitionMapExchange(true, true);
for (int i = 0; i < 2; i++) {
stopGrid(3);
- awaitPartitionMapExchange(true);
+ awaitPartitionMapExchange(true, true);
startGrid(3);
- awaitPartitionMapExchange(true);
+ awaitPartitionMapExchange(true, true);
}
startGrid(4);
- awaitPartitionMapExchange(true);
+ awaitPartitionMapExchange(true, true);
assert rs.isEmpty();
record = true;
+ // Emulate latest GridDhtPartitionsFullMessages.
+ ignite.context().cache().context().exchange().scheduleResendPartitions();
+
while (rs.size() < 3) { // N - 1 nodes.
U.sleep(10);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9e62b667/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
index 4ee080f..cce6388 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
@@ -17,26 +17,50 @@
package org.apache.ignite.internal.processors.cache.distributed.rebalancing;
+import java.util.Collection;
+import java.util.List;
import java.util.Map;
import java.util.Random;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap2;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.IgniteSpiException;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import static org.apache.ignite.cache.CacheMode.LOCAL;
+import static org.apache.ignite.cache.CacheRebalanceMode.NONE;
+
/**
*
*/
@@ -68,6 +92,12 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
/** */
private volatile boolean concurrentStartFinished3;
+ /** */
+ private volatile boolean record = false;
+
+ /** */
+ private final ConcurrentHashMap<Class, AtomicInteger> map = new ConcurrentHashMap<>();
+
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration iCfg = super.getConfiguration(gridName);
@@ -75,6 +105,13 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setIpFinder(ipFinder);
((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setForceServerMode(true);
+ TcpCommunicationSpi commSpi = new CountingCommunicationSpi();
+
+ commSpi.setLocalPort(GridTestUtils.getNextCommPort(getClass()));
+ commSpi.setTcpNoDelay(true);
+
+ iCfg.setCommunicationSpi(commSpi);
+
if (getTestGridName(10).equals(gridName))
iCfg.setClientMode(true);
@@ -172,8 +209,9 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
log.info("<" + name + "> Checked " + (i + 1) * 100 / (TEST_SIZE) + "% entries. [count=" + TEST_SIZE +
", iteration=" + iter + ", cache=" + name + "]");
- assert ignite.cache(name).get(i) != null && ignite.cache(name).get(i).equals(i + name.hashCode() + iter) :
- i + " value " + (i + name.hashCode() + iter) + " does not match (" + ignite.cache(name).get(i) + ")";
+ assertTrue(i + " value " + (i + name.hashCode() + iter) + " does not match (" + ignite.cache(name).get(i) + ")",
+ ignite.cache(name).get(i) != null && ignite.cache(name).get(i).equals(i + name.hashCode() + iter));
+
}
}
@@ -181,7 +219,7 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testSimpleRebalancing() throws Exception {
- Ignite ignite = startGrid(0);
+ IgniteKernal ignite = (IgniteKernal)startGrid(0);
generateData(ignite, 0, 0);
@@ -194,19 +232,43 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
waitForRebalancing(0, 2);
waitForRebalancing(1, 2);
+ awaitPartitionMapExchange(true, true);
+
+ checkPartitionMapExchangeFinished();
+
+ checkPartitionMapMessagesAbsent();
+
stopGrid(0);
waitForRebalancing(1, 3);
+ awaitPartitionMapExchange(true, true);
+
+ checkPartitionMapExchangeFinished();
+
+ checkPartitionMapMessagesAbsent();
+
startGrid(2);
waitForRebalancing(1, 4);
waitForRebalancing(2, 4);
+ awaitPartitionMapExchange(true, true);
+
+ checkPartitionMapExchangeFinished();
+
+ checkPartitionMapMessagesAbsent();
+
stopGrid(2);
waitForRebalancing(1, 5);
+ awaitPartitionMapExchange(true, true);
+
+ checkPartitionMapExchangeFinished();
+
+ checkPartitionMapMessagesAbsent();
+
long spend = (System.currentTimeMillis() - start) / 1000;
checkData(grid(1), 0, 0);
@@ -269,7 +331,7 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
concurrentStartFinished = true;
- awaitPartitionMapExchange(true);
+ awaitPartitionMapExchange(true, true);
checkSupplyContextMapIsEmpty();
@@ -340,12 +402,79 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
Map map = U.field(supplier, "scMap");
synchronized (map) {
- assert map.isEmpty();
+ assertTrue(map.isEmpty());
}
}
}
}
+ protected void checkPartitionMapExchangeFinished() {
+ for (Ignite g : G.allGrids()) {
+ IgniteKernal g0 = (IgniteKernal)g;
+
+ for (IgniteCacheProxy<?, ?> c : g0.context().cache().jcaches()) {
+ CacheConfiguration cfg = c.context().config();
+
+ if (cfg.getCacheMode() != LOCAL && cfg.getRebalanceMode() != NONE) {
+ GridDhtCacheAdapter<?, ?> dht = dht(c);
+
+ GridDhtPartitionTopology top = dht.topology();
+
+ List<GridDhtLocalPartition> locs = top.localPartitions();
+
+ for (GridDhtLocalPartition loc : locs) {
+ assertTrue("Wrong partition state, should be OWNING [state=" + loc.state() + "]",
+ loc.state() == GridDhtPartitionState.OWNING);
+
+ Collection<ClusterNode> affNodes =
+ g0.affinity(cfg.getName()).mapPartitionToPrimaryAndBackups(loc.id());
+
+ assertTrue(affNodes.contains(g0.localNode()));
+ }
+
+ for (Ignite remote : G.allGrids()) {
+ IgniteKernal remote0 = (IgniteKernal)remote;
+
+ IgniteCacheProxy<?, ?> remoteC = remote0.context().cache().jcache(cfg.getName());
+
+ GridDhtCacheAdapter<?, ?> remoteDht = dht(remoteC);
+
+ GridDhtPartitionTopology remoteTop = remoteDht.topology();
+
+ GridDhtPartitionMap2 pMap = remoteTop.partitionMap(true).get(((IgniteKernal)g).getLocalNodeId());
+
+ assertEquals(pMap.size(), locs.size());
+
+ for (Map.Entry entry : pMap.entrySet()) {
+ assertTrue("Wrong partition state, should be OWNING [state=" + entry.getValue() + "]",
+ entry.getValue() == GridDhtPartitionState.OWNING);
+ }
+
+ for (GridDhtLocalPartition loc : locs) {
+ assertTrue(pMap.containsKey(loc.id()));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void checkPartitionMapMessagesAbsent() throws IgniteInterruptedCheckedException {
+ map.clear();
+
+ record = true;
+
+ U.sleep(30_000);
+
+ record = false;
+
+ AtomicInteger iF = map.get(GridDhtPartitionsFullMessage.class);
+ AtomicInteger iS = map.get(GridDhtPartitionsSingleMessage.class);
+
+ assertTrue(iF == null || iF.get() == 1); // 1 message can be sent right after all checks passed.
+ assertTrue(iS == null);
+ }
+
/** {@inheritDoc} */
@Override protected long getTestTimeout() {
return 10 * 60_000;
@@ -438,7 +567,7 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
waitForRebalancing(3, 5, 1);
waitForRebalancing(4, 5, 1);
- awaitPartitionMapExchange(true);
+ awaitPartitionMapExchange(true, true);
checkSupplyContextMapIsEmpty();
@@ -462,7 +591,7 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
waitForRebalancing(3, 6);
waitForRebalancing(4, 6);
- awaitPartitionMapExchange(true);
+ awaitPartitionMapExchange(true, true);
checkSupplyContextMapIsEmpty();
@@ -472,7 +601,7 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
waitForRebalancing(3, 7);
waitForRebalancing(4, 7);
- awaitPartitionMapExchange(true);
+ awaitPartitionMapExchange(true, true);
checkSupplyContextMapIsEmpty();
@@ -481,7 +610,11 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
waitForRebalancing(3, 8);
waitForRebalancing(4, 8);
- awaitPartitionMapExchange(true);
+ awaitPartitionMapExchange(true, true);
+
+ checkPartitionMapExchangeFinished();
+
+ checkPartitionMapMessagesAbsent();
checkSupplyContextMapIsEmpty();
@@ -506,4 +639,40 @@ public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
stopAllGrids();
}
+
+ /**
+ *
+ */
+ private class CountingCommunicationSpi extends TcpCommunicationSpi {
+ /** {@inheritDoc} */
+ @Override public void sendMessage(final ClusterNode node, final Message msg,
+ final IgniteInClosure<IgniteException> ackC) throws IgniteSpiException {
+ final Object msg0 = ((GridIoMessage)msg).message();
+
+ recordMessage(msg0);
+
+ super.sendMessage(node, msg, ackC);
+ }
+
+ /**
+ * @param msg
+ */
+ private void recordMessage(Object msg) {
+ if (record) {
+ Class id = msg.getClass();
+
+ AtomicInteger ai = map.get(id);
+
+ if (ai == null) {
+ ai = new AtomicInteger();
+
+ AtomicInteger oldAi = map.putIfAbsent(id, ai);
+
+ (oldAi != null ? oldAi : ai).incrementAndGet();
+ }
+ else
+ ai.incrementAndGet();
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9e62b667/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index c77530e..4d40c68 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -23,6 +23,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
@@ -68,6 +69,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartit
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap2;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
import org.apache.ignite.internal.processors.cache.local.GridLocalCache;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
@@ -416,15 +418,18 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
*/
@SuppressWarnings("BusyWait")
protected void awaitPartitionMapExchange() throws InterruptedException {
- awaitPartitionMapExchange(false);
+ awaitPartitionMapExchange(false, false);
}
/**
* @param waitEvicts If {@code true} will wait for evictions finished.
+ * @param waitNode2PartUpdate If {@code true} will wait for nodes node2part info update finished.
* @throws InterruptedException If interrupted.
*/
@SuppressWarnings("BusyWait")
- protected void awaitPartitionMapExchange(boolean waitEvicts) throws InterruptedException {
+ protected void awaitPartitionMapExchange(boolean waitEvicts, boolean waitNode2PartUpdate) throws InterruptedException {
+ long timeout = 30_000;
+
for (Ignite g : G.allGrids()) {
IgniteKernal g0 = (IgniteKernal)g;
@@ -468,7 +473,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
GridDhtLocalPartition loc = top.localPartition(p, readyVer, false);
if (affNodes.size() != owners.size() || !affNodes.containsAll(owners) ||
- (waitEvicts && loc != null && loc.state() == GridDhtPartitionState.RENTING)) {
+ (waitEvicts && loc != null && loc.state() != GridDhtPartitionState.OWNING)) {
LT.warn(log(), null, "Waiting for topology map update [" +
"grid=" + g.name() +
", cache=" + cfg.getName() +
@@ -501,7 +506,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
if (i == 0)
start = System.currentTimeMillis();
- if (System.currentTimeMillis() - start > 30_000) {
+ if (System.currentTimeMillis() - start > timeout) {
U.dumpThreads(log);
throw new IgniteException("Timeout of waiting for topology map update [" +
@@ -526,6 +531,46 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
break;
}
}
+
+ if (waitNode2PartUpdate) {
+ long start = System.currentTimeMillis();
+
+ boolean failed = true;
+
+ while (failed) {
+ failed = false;
+
+ for (GridDhtPartitionMap2 pMap : top.partitionMap(true).values()) {
+ if (failed)
+ break;
+
+ for (Map.Entry entry : pMap.entrySet()) {
+ if (System.currentTimeMillis() - start > timeout) {
+ U.dumpThreads(log);
+
+ throw new IgniteException("Timeout of waiting for partition state update [" +
+ "grid=" + g.name() +
+ ", cache=" + cfg.getName() +
+ ", cacheId=" + dht.context().cacheId() +
+ ", topVer=" + top.topologyVersion() +
+ ", locNode=" + g.cluster().localNode() + ']');
+ }
+
+ if (entry.getValue() != GridDhtPartitionState.OWNING) {
+ LT.warn(log(), null,
+ "Waiting for correct partition state, should be OWNING [state=" +
+ entry.getValue() + "]");
+
+ Thread.sleep(200); // Busy wait.
+
+ failed = true;
+
+ break;
+ }
+ }
+ }
+ }
+ }
}
}
}
[48/50] [abbrv] ignite git commit: IGNITE-2947 BinaryContext doesn't
honor custom loader set through IgniteConfiguration.classLoader Rollback
Posted by sb...@apache.org.
IGNITE-2947
BinaryContext doesn't honor custom loader set through IgniteConfiguration.classLoader
Rollback
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bbe1a7e5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bbe1a7e5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bbe1a7e5
Branch: refs/heads/ignite-1837
Commit: bbe1a7e52f177283969e81127216838f37b4205f
Parents: d92e617
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Apr 7 17:42:33 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Apr 7 17:42:33 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/binary/BinaryContext.java | 2 +-
...acheBinaryObjectUserClassloaderSelfTest.java | 147 -------------------
.../IgniteBinaryObjectsTestSuite.java | 3 -
3 files changed, 1 insertion(+), 151 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bbe1a7e5/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 9a9ef10..4d8c293 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
@@ -992,7 +992,7 @@ public class BinaryContext {
Class<?> cls = null;
try {
- cls = U.resolveClassLoader(configuration()).loadClass(clsName);
+ cls = Class.forName(clsName);
}
catch (ClassNotFoundException | NoClassDefFoundError ignored) {
// No-op.
http://git-wip-us.apache.org/repos/asf/ignite/blob/bbe1a7e5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java
deleted file mode 100644
index ca09e4c..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java
+++ /dev/null
@@ -1,147 +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.internal.processors.cache.binary;
-
-import java.util.Collections;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.binary.BinarySerializer;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
-import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.configuration.BinaryConfiguration;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import static org.apache.ignite.cache.CacheMode.REPLICATED;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-
-/**
- *
- */
-public class GridCacheBinaryObjectUserClassloaderSelfTest extends GridCommonAbstractTest {
- /** */
- private static volatile boolean customBinaryConf = false;
-
- /** */
- private static volatile boolean deserialized = false;
-
- /** */
- private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
- disco.setIpFinder(ipFinder);
-
- cfg.setDiscoverySpi(disco);
-
- cfg.setCacheConfiguration(cacheConfiguration(gridName));
-
- cfg.setMarshaller(new BinaryMarshaller());
-
- cfg.setClassLoader(getExternalClassLoader());
-
- if (customBinaryConf) {
- BinaryTypeConfiguration btcfg = new BinaryTypeConfiguration();
-
- btcfg.setTypeName("org.apache.ignite.tests.p2p.CacheDeploymentTestValue3");
-
- btcfg.setSerializer(new BinarySerializer() {
- /** {@inheritDoc} */
- @Override public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
- //No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
- deserialized = true;
- }
- });
-
- BinaryConfiguration bcfg = new BinaryConfiguration();
-
- bcfg.setTypeConfigurations(Collections.singletonList(btcfg));
-
- cfg.setBinaryConfiguration(bcfg);
- }
-
- return cfg;
- }
-
- /**
- * Gets cache configuration for grid with specified name.
- *
- * @param gridName Grid name.
- * @return Cache configuration.
- */
- CacheConfiguration cacheConfiguration(String gridName) {
- CacheConfiguration cacheCfg = defaultCacheConfiguration();
-
- cacheCfg.setCacheMode(REPLICATED);
- cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
-
- return cacheCfg;
- }
-
- /**
- * @throws Exception If test failed.
- */
- public void testConfigurationRegistration() throws Exception {
- try {
- customBinaryConf = true;
-
- Ignite i1 = startGrid(1);
- Ignite i2 = startGrid(2);
-
- IgniteCache<Integer, Object> cache1 = i1.cache(null);
- IgniteCache<Integer, Object> cache2 = i2.cache(null);
-
- ClassLoader ldr = i1.configuration().getClassLoader();
-
- Object v1 = ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestValue3").newInstance();
-
- cache1.put(1, v1);
-
- deserialized = false;
-
- cache2.get(1);
-
- assertTrue(deserialized);
- }
- finally {
- customBinaryConf = false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bbe1a7e5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
index f28d5a8..2b49597 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
@@ -45,7 +45,6 @@ import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderAdditiona
import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactDefaultMappersSelfTest;
import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest;
import org.apache.ignite.internal.processors.cache.BinaryObjectOffHeapUnswapTemporaryTest;
-import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryObjectUserClassloaderSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesDefaultMappersSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreObjectsSelfTest;
@@ -135,8 +134,6 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
suite.addTestSuite(BinaryTxCacheLocalEntriesSelfTest.class);
suite.addTestSuite(BinaryAtomicCacheLocalEntriesSelfTest.class);
- suite.addTestSuite(GridCacheBinaryObjectUserClassloaderSelfTest.class);
-
return suite;
}
}
[49/50] [abbrv] ignite git commit: ignite-1837
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/08f46583/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index be346b4..7a81ddc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -22,11 +22,10 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.UUID;
-import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -60,13 +59,11 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
import org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter;
-import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -107,26 +104,17 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
/** */
@GridToStringInclude
- private final Collection<UUID> rcvdIds = new GridConcurrentHashSet<>();
+ private final Set<UUID> remaining = new HashSet<>();
- /** Remote nodes. */
- private volatile Collection<ClusterNode> rmtNodes;
-
- /** Remote nodes. */
- @GridToStringInclude
- private volatile Collection<UUID> rmtIds;
+ /** */
+ private List<ClusterNode> srvNodes;
- /** Oldest node. */
- @GridToStringExclude
- private final AtomicReference<ClusterNode> oldestNode = new AtomicReference<>();
+ /** */
+ private ClusterNode crd;
/** ExchangeFuture id. */
private final GridDhtPartitionExchangeId exchId;
- /** Init flag. */
- @GridToStringInclude
- private final AtomicBoolean init = new AtomicBoolean(false);
-
/** Ready for reply flag. */
@GridToStringInclude
private final AtomicBoolean ready = new AtomicBoolean(false);
@@ -145,9 +133,6 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
/** Busy lock to prevent activities from accessing exchanger while it's stopping. */
private ReadWriteLock busyLock;
- /** */
- private AtomicBoolean added = new AtomicBoolean(false);
-
/** Event latch. */
@GridToStringExclude
private CountDownLatch evtLatch = new CountDownLatch(1);
@@ -165,10 +150,16 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
* Messages received on non-coordinator are stored in case if this node
* becomes coordinator.
*/
- private final Map<UUID, GridDhtPartitionsSingleMessage> singleMsgs = new ConcurrentHashMap8<>();
+ private final Map<ClusterNode, GridDhtPartitionsSingleMessage> singleMsgs = new ConcurrentHashMap8<>();
/** Messages received from new coordinator. */
- private final Map<UUID, GridDhtPartitionsFullMessage> fullMsgs = new ConcurrentHashMap8<>();
+ private final Map<ClusterNode, GridDhtPartitionsFullMessage> fullMsgs = new ConcurrentHashMap8<>();
+
+ /** */
+ private List<DiscoveryEvent> addedJoinEvts;
+
+ /** */
+ private GridDhtPartitionExchangeId resExchId;
/** */
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
@@ -355,23 +346,6 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
}
/**
- * @param cacheId Cache ID.
- * @return {@code True} if local client has been added.
- */
- public boolean isLocalClientAdded(int cacheId) {
- if (!F.isEmpty(reqs)) {
- for (DynamicCacheChangeRequest req : reqs) {
- if (req.start() && F.eq(req.initiatingNodeId(), cctx.localNodeId())) {
- if (CU.cacheId(req.cacheName()) == cacheId)
- return true;
- }
- }
- }
-
- return false;
- }
-
- /**
* @param cacheCtx Cache context.
* @throws IgniteCheckedException If failed.
*/
@@ -436,13 +410,6 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
}
/**
- * @return {@code True}
- */
- public boolean onAdded() {
- return added.compareAndSet(false, true);
- }
-
- /**
* Event callback.
*
* @param exchId Exchange ID.
@@ -499,420 +466,382 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
if (isDone())
return;
- if (init.compareAndSet(false, true)) {
- if (isDone())
- return;
+ initTs = U.currentTimeMillis();
- initTs = U.currentTimeMillis();
+ try {
+ // Wait for event to occur to make sure that discovery
+ // will return corresponding nodes.
+ U.await(evtLatch);
- try {
- // Wait for event to occur to make sure that discovery
- // will return corresponding nodes.
- U.await(evtLatch);
+ assert discoEvt != null : this;
+ assert !dummy && !forcePreload : this;
- assert discoEvt != null : this;
- assert !dummy && !forcePreload : this;
+ srvNodes = new ArrayList<>(cctx.discovery().aliveServerNodesWithCaches(topologyVersion()));
- ClusterNode oldest = CU.oldestAliveCacheServerNode(cctx, exchId.topologyVersion());
+ remaining.addAll(F.nodeIds(F.view(srvNodes, F.remoteNodes(cctx.localNodeId()))));
- oldestNode.set(oldest);
+ crd = srvNodes.isEmpty() ? null : srvNodes.get(0);
- if (!F.isEmpty(reqs))
- blockGateways();
+ if (!F.isEmpty(reqs))
+ blockGateways();
- startCaches();
+ startCaches();
- // True if client node joined or failed.
- boolean clientNodeEvt;
+ // True if client node joined or failed.
+ boolean clientNodeEvt;
- if (F.isEmpty(reqs)) {
- int type = discoEvt.type();
+ if (F.isEmpty(reqs)) {
+ int type = discoEvt.type();
- assert type == EVT_NODE_JOINED || type == EVT_NODE_LEFT || type == EVT_NODE_FAILED : discoEvt;
+ assert type == EVT_NODE_JOINED || type == EVT_NODE_LEFT || type == EVT_NODE_FAILED : discoEvt;
- clientNodeEvt = CU.clientNode(discoEvt.eventNode());
- }
- else {
- assert discoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT : discoEvt;
-
- boolean clientOnlyCacheEvt = true;
+ clientNodeEvt = CU.clientNode(discoEvt.eventNode());
+ }
+ else {
+ assert discoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT : discoEvt;
- for (DynamicCacheChangeRequest req : reqs) {
- if (req.clientStartOnly() || req.close())
- continue;
+ boolean clientOnlyCacheEvt = true;
- clientOnlyCacheEvt = false;
+ for (DynamicCacheChangeRequest req : reqs) {
+ if (req.clientStartOnly() || req.close())
+ continue;
- break;
- }
+ clientOnlyCacheEvt = false;
- clientNodeEvt = clientOnlyCacheEvt;
+ break;
}
- if (clientNodeEvt) {
- ClusterNode node = discoEvt.eventNode();
+ clientNodeEvt = clientOnlyCacheEvt;
+ }
- // Client need to initialize affinity for local join event or for stated client caches.
- if (!node.isLocal() || clientCacheClose()) {
- for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
- if (cacheCtx.isLocal())
- continue;
+ if (clientNodeEvt) {
+ ClusterNode node = discoEvt.eventNode();
- GridDhtPartitionTopology top = cacheCtx.topology();
+ // Client need to initialize affinity for local join event or for stated client caches.
+ if (!node.isLocal() || clientCacheClose()) {
+ for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
+ if (cacheCtx.isLocal())
+ continue;
- top.updateTopologyVersion(exchId, this, -1, stopping(cacheCtx.cacheId()));
+ GridDhtPartitionTopology top = cacheCtx.topology();
- if (cacheCtx.affinity().affinityTopologyVersion() == AffinityTopologyVersion.NONE) {
- initTopology(cacheCtx);
+ top.updateTopologyVersion(exchId, this, -1, stopping(cacheCtx.cacheId()));
- top.beforeExchange(this);
- }
- else
- cacheCtx.affinity().clientEventTopologyChange(discoEvt, exchId.topologyVersion());
+ if (cacheCtx.affinity().affinityTopologyVersion() == AffinityTopologyVersion.NONE) {
+ initTopology(cacheCtx);
- if (!exchId.isJoined())
- cacheCtx.preloader().unwindUndeploys();
+ top.beforeExchange(this);
}
+ else
+ cacheCtx.affinity().clientEventTopologyChange(discoEvt, exchId.topologyVersion());
- if (exchId.isLeft())
- cctx.mvcc().removeExplicitNodeLocks(exchId.nodeId(), exchId.topologyVersion());
+ if (!exchId.isJoined())
+ cacheCtx.preloader().unwindUndeploys();
+ }
- rmtIds = Collections.emptyList();
- rmtNodes = Collections.emptyList();
+ if (exchId.isLeft())
+ cctx.mvcc().removeExplicitNodeLocks(exchId.nodeId(), exchId.topologyVersion());
- onDone(exchId.topologyVersion());
+ onDone(exchId.topologyVersion());
- skipPreload = cctx.kernalContext().clientNode();
+ skipPreload = cctx.kernalContext().clientNode();
- return;
- }
+ return;
}
+ }
- clientOnlyExchange = clientNodeEvt || cctx.kernalContext().clientNode();
+ clientOnlyExchange = clientNodeEvt || cctx.kernalContext().clientNode();
- if (clientOnlyExchange) {
- skipPreload = cctx.kernalContext().clientNode();
+ if (clientOnlyExchange) {
+ skipPreload = cctx.kernalContext().clientNode();
- for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
- if (cacheCtx.isLocal())
- continue;
+ for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
+ if (cacheCtx.isLocal())
+ continue;
- GridDhtPartitionTopology top = cacheCtx.topology();
+ GridDhtPartitionTopology top = cacheCtx.topology();
- top.updateTopologyVersion(exchId, this, -1, stopping(cacheCtx.cacheId()));
- }
+ top.updateTopologyVersion(exchId, this, -1, stopping(cacheCtx.cacheId()));
+ }
- for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
- if (cacheCtx.isLocal())
- continue;
+ for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
+ if (cacheCtx.isLocal())
+ continue;
- initTopology(cacheCtx);
- }
+ initTopology(cacheCtx);
+ }
- if (oldest != null) {
- rmtNodes = new ConcurrentLinkedQueue<>(CU.aliveRemoteServerNodesWithCaches(cctx,
- exchId.topologyVersion()));
+ if (crd != null) {
+ initFut.onDone(true);
- rmtIds = Collections.unmodifiableSet(new HashSet<>(F.nodeIds(rmtNodes)));
+ if (log.isDebugEnabled())
+ log.debug("Initialized future: " + this);
- initFut.onDone(true);
+ if (cctx.localNode().equals(crd)) {
+ for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
+ boolean updateTop = !cacheCtx.isLocal() &&
+ exchId.topologyVersion().equals(cacheCtx.startTopologyVersion());
- if (log.isDebugEnabled())
- log.debug("Initialized future: " + this);
+ if (updateTop) {
+ for (GridClientPartitionTopology top : cctx.exchange().clientTopologies()) {
+ if (top.cacheId() == cacheCtx.cacheId()) {
+ cacheCtx.topology().update(exchId,
+ top.partitionMap(true),
+ top.updateCounters());
- if (cctx.localNode().equals(oldest)) {
- for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
- boolean updateTop = !cacheCtx.isLocal() &&
- exchId.topologyVersion().equals(cacheCtx.startTopologyVersion());
-
- if (updateTop) {
- for (GridClientPartitionTopology top : cctx.exchange().clientTopologies()) {
- if (top.cacheId() == cacheCtx.cacheId()) {
- cacheCtx.topology().update(exchId,
- top.partitionMap(true),
- top.updateCounters());
-
- break;
- }
+ break;
}
-
}
- }
- onDone(exchId.topologyVersion());
+ }
}
- else
- sendPartitions(oldest);
- }
- else {
- rmtIds = Collections.emptyList();
- rmtNodes = Collections.emptyList();
onDone(exchId.topologyVersion());
}
-
- return;
+ else
+ sendPartitions(crd);
}
+ else
+ onDone(exchId.topologyVersion());
- assert oldestNode.get() != null;
+ return;
+ }
- for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
- if (isCacheAdded(cacheCtx.cacheId(), exchId.topologyVersion())) {
- if (cacheCtx.discovery().cacheAffinityNodes(cacheCtx.name(), topologyVersion()).isEmpty())
- U.quietAndWarn(log, "No server nodes found for cache client: " + cacheCtx.namex());
- }
+ assert crd != null;
- cacheCtx.preloader().onExchangeFutureAdded();
+ for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
+ if (isCacheAdded(cacheCtx.cacheId(), exchId.topologyVersion())) {
+ if (cacheCtx.discovery().cacheAffinityNodes(cacheCtx.name(), topologyVersion()).isEmpty())
+ U.quietAndWarn(log, "No server nodes found for cache client: " + cacheCtx.namex());
}
- List<String> cachesWithoutNodes = null;
-
- if (exchId.isLeft()) {
- for (String name : cctx.cache().cacheNames()) {
- if (cctx.discovery().cacheAffinityNodes(name, topologyVersion()).isEmpty()) {
- if (cachesWithoutNodes == null)
- cachesWithoutNodes = new ArrayList<>();
-
- cachesWithoutNodes.add(name);
-
- // Fire event even if there is no client cache started.
- if (cctx.gridEvents().isRecordable(EventType.EVT_CACHE_NODES_LEFT)) {
- Event evt = new CacheEvent(
- name,
- cctx.localNode(),
- cctx.localNode(),
- "All server nodes have left the cluster.",
- EventType.EVT_CACHE_NODES_LEFT,
- 0,
- false,
- null,
- null,
- null,
- null,
- false,
- null,
- false,
- null,
- null,
- null
- );
-
- cctx.gridEvents().record(evt);
- }
+ cacheCtx.preloader().onExchangeFutureAdded();
+ }
+
+ List<String> cachesWithoutNodes = null;
+
+ if (exchId.isLeft()) {
+ for (String name : cctx.cache().cacheNames()) {
+ if (cctx.discovery().cacheAffinityNodes(name, topologyVersion()).isEmpty()) {
+ if (cachesWithoutNodes == null)
+ cachesWithoutNodes = new ArrayList<>();
+
+ cachesWithoutNodes.add(name);
+
+ // Fire event even if there is no client cache started.
+ if (cctx.gridEvents().isRecordable(EventType.EVT_CACHE_NODES_LEFT)) {
+ Event evt = new CacheEvent(
+ name,
+ cctx.localNode(),
+ cctx.localNode(),
+ "All server nodes have left the cluster.",
+ EventType.EVT_CACHE_NODES_LEFT,
+ 0,
+ false,
+ null,
+ null,
+ null,
+ null,
+ false,
+ null,
+ false,
+ null,
+ null,
+ null
+ );
+
+ cctx.gridEvents().record(evt);
}
}
}
+ }
- if (cachesWithoutNodes != null) {
- StringBuilder sb =
- new StringBuilder("All server nodes for the following caches have left the cluster: ");
-
- for (int i = 0; i < cachesWithoutNodes.size(); i++) {
- String cache = cachesWithoutNodes.get(i);
+ if (cachesWithoutNodes != null) {
+ StringBuilder sb =
+ new StringBuilder("All server nodes for the following caches have left the cluster: ");
- sb.append('\'').append(cache).append('\'');
+ for (int i = 0; i < cachesWithoutNodes.size(); i++) {
+ String cache = cachesWithoutNodes.get(i);
- if (i != cachesWithoutNodes.size() - 1)
- sb.append(", ");
- }
+ sb.append('\'').append(cache).append('\'');
- U.quietAndWarn(log, sb.toString());
-
- U.quietAndWarn(log, "Must have server nodes for caches to operate.");
+ if (i != cachesWithoutNodes.size() - 1)
+ sb.append(", ");
}
- assert discoEvt != null;
-
- assert exchId.nodeId().equals(discoEvt.eventNode().id());
+ U.quietAndWarn(log, sb.toString());
- for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
- GridClientPartitionTopology clientTop = cctx.exchange().clearClientTopology(
- cacheCtx.cacheId());
+ U.quietAndWarn(log, "Must have server nodes for caches to operate.");
+ }
- long updSeq = clientTop == null ? -1 : clientTop.lastUpdateSequence();
+ assert discoEvt != null;
- // Update before waiting for locks.
- if (!cacheCtx.isLocal())
- cacheCtx.topology().updateTopologyVersion(exchId, this, updSeq, stopping(cacheCtx.cacheId()));
- }
+ assert exchId.nodeId().equals(discoEvt.eventNode().id());
- // Grab all alive remote nodes with order of equal or less than last joined node.
- rmtNodes = new ConcurrentLinkedQueue<>(CU.aliveRemoteServerNodesWithCaches(cctx,
- exchId.topologyVersion()));
+ for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
+ GridClientPartitionTopology clientTop = cctx.exchange().clearClientTopology(
+ cacheCtx.cacheId());
- rmtIds = Collections.unmodifiableSet(new HashSet<>(F.nodeIds(rmtNodes)));
+ long updSeq = clientTop == null ? -1 : clientTop.lastUpdateSequence();
- for (Map.Entry<UUID, GridDhtPartitionsSingleMessage> m : singleMsgs.entrySet())
- // If received any messages, process them.
- onReceive(m.getKey(), m.getValue());
+ // Update before waiting for locks.
+ if (!cacheCtx.isLocal())
+ cacheCtx.topology().updateTopologyVersion(exchId, this, updSeq, stopping(cacheCtx.cacheId()));
+ }
- for (Map.Entry<UUID, GridDhtPartitionsFullMessage> m : fullMsgs.entrySet())
- // If received any messages, process them.
- onReceive(m.getKey(), m.getValue());
+ AffinityTopologyVersion topVer = exchId.topologyVersion();
- AffinityTopologyVersion topVer = exchId.topologyVersion();
+ for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
+ if (cacheCtx.isLocal())
+ continue;
- for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
- if (cacheCtx.isLocal())
- continue;
-
- // Must initialize topology after we get discovery event.
- initTopology(cacheCtx);
+ // Must initialize topology after we get discovery event.
+ initTopology(cacheCtx);
- cacheCtx.preloader().onTopologyChanged(exchId.topologyVersion());
+ cacheCtx.preloader().onTopologyChanged(exchId.topologyVersion());
- cacheCtx.preloader().updateLastExchangeFuture(this);
- }
+ cacheCtx.preloader().updateLastExchangeFuture(this);
+ }
- IgniteInternalFuture<?> partReleaseFut = cctx.partitionReleaseFuture(topVer);
+ IgniteInternalFuture<?> partReleaseFut = cctx.partitionReleaseFuture(topVer);
- // Assign to class variable so it will be included into toString() method.
- this.partReleaseFut = partReleaseFut;
+ // Assign to class variable so it will be included into toString() method.
+ this.partReleaseFut = partReleaseFut;
- if (exchId.isLeft())
- cctx.mvcc().removeExplicitNodeLocks(exchId.nodeId(), exchId.topologyVersion());
+ if (exchId.isLeft())
+ cctx.mvcc().removeExplicitNodeLocks(exchId.nodeId(), exchId.topologyVersion());
- if (log.isDebugEnabled())
- log.debug("Before waiting for partition release future: " + this);
+ if (log.isDebugEnabled())
+ log.debug("Before waiting for partition release future: " + this);
- int dumpedObjects = 0;
+ int dumpedObjects = 0;
- while (true) {
- try {
- partReleaseFut.get(2 * cctx.gridConfig().getNetworkTimeout(), TimeUnit.MILLISECONDS);
+ while (true) {
+ try {
+ partReleaseFut.get(2 * cctx.gridConfig().getNetworkTimeout(), TimeUnit.MILLISECONDS);
- break;
- }
- catch (IgniteFutureTimeoutCheckedException ignored) {
- // Print pending transactions and locks that might have led to hang.
- if (dumpedObjects < DUMP_PENDING_OBJECTS_THRESHOLD) {
- dumpPendingObjects();
+ break;
+ }
+ catch (IgniteFutureTimeoutCheckedException ignored) {
+ // Print pending transactions and locks that might have led to hang.
+ if (dumpedObjects < DUMP_PENDING_OBJECTS_THRESHOLD) {
+ dumpPendingObjects();
- dumpedObjects++;
- }
+ dumpedObjects++;
}
}
+ }
- if (log.isDebugEnabled())
- log.debug("After waiting for partition release future: " + this);
+ if (log.isDebugEnabled())
+ log.debug("After waiting for partition release future: " + this);
- IgniteInternalFuture<?> locksFut = cctx.mvcc().finishLocks(exchId.topologyVersion());
+ IgniteInternalFuture<?> locksFut = cctx.mvcc().finishLocks(exchId.topologyVersion());
- dumpedObjects = 0;
+ dumpedObjects = 0;
- while (true) {
- try {
- locksFut.get(2 * cctx.gridConfig().getNetworkTimeout(), TimeUnit.MILLISECONDS);
+ while (true) {
+ try {
+ locksFut.get(2 * cctx.gridConfig().getNetworkTimeout(), TimeUnit.MILLISECONDS);
- break;
- }
- catch (IgniteFutureTimeoutCheckedException ignored) {
- if (dumpedObjects < DUMP_PENDING_OBJECTS_THRESHOLD) {
- U.warn(log, "Failed to wait for locks release future. " +
- "Dumping pending objects that might be the cause: " + cctx.localNodeId());
+ break;
+ }
+ catch (IgniteFutureTimeoutCheckedException ignored) {
+ if (dumpedObjects < DUMP_PENDING_OBJECTS_THRESHOLD) {
+ U.warn(log, "Failed to wait for locks release future. " +
+ "Dumping pending objects that might be the cause: " + cctx.localNodeId());
- U.warn(log, "Locked keys:");
+ U.warn(log, "Locked keys:");
- for (IgniteTxKey key : cctx.mvcc().lockedKeys())
- U.warn(log, "Locked key: " + key);
+ for (IgniteTxKey key : cctx.mvcc().lockedKeys())
+ U.warn(log, "Locked key: " + key);
- for (IgniteTxKey key : cctx.mvcc().nearLockedKeys())
- U.warn(log, "Locked near key: " + key);
+ for (IgniteTxKey key : cctx.mvcc().nearLockedKeys())
+ U.warn(log, "Locked near key: " + key);
- Map<IgniteTxKey, Collection<GridCacheMvccCandidate>> locks =
- cctx.mvcc().unfinishedLocks(exchId.topologyVersion());
+ Map<IgniteTxKey, Collection<GridCacheMvccCandidate>> locks =
+ cctx.mvcc().unfinishedLocks(exchId.topologyVersion());
- for (Map.Entry<IgniteTxKey, Collection<GridCacheMvccCandidate>> e : locks.entrySet())
- U.warn(log, "Awaited locked entry [key=" + e.getKey() + ", mvcc=" + e.getValue() + ']');
+ for (Map.Entry<IgniteTxKey, Collection<GridCacheMvccCandidate>> e : locks.entrySet())
+ U.warn(log, "Awaited locked entry [key=" + e.getKey() + ", mvcc=" + e.getValue() + ']');
- dumpedObjects++;
- }
+ dumpedObjects++;
}
}
+ }
- boolean topChanged = discoEvt.type() != EVT_DISCOVERY_CUSTOM_EVT;
+ boolean topChanged = discoEvt.type() != EVT_DISCOVERY_CUSTOM_EVT;
- for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
- if (cacheCtx.isLocal())
- continue;
+ for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
+ if (cacheCtx.isLocal())
+ continue;
- // Notify replication manager.
- GridCacheContext drCacheCtx = cacheCtx.isNear() ? cacheCtx.near().dht().context() : cacheCtx;
+ // Notify replication manager.
+ GridCacheContext drCacheCtx = cacheCtx.isNear() ? cacheCtx.near().dht().context() : cacheCtx;
- if (drCacheCtx.isDrEnabled())
- drCacheCtx.dr().beforeExchange(topVer, exchId.isLeft());
+ if (drCacheCtx.isDrEnabled())
+ drCacheCtx.dr().beforeExchange(topVer, exchId.isLeft());
- if (topChanged)
- cacheCtx.continuousQueries().beforeExchange(exchId.topologyVersion());
+ if (topChanged)
+ cacheCtx.continuousQueries().beforeExchange(exchId.topologyVersion());
- // Partition release future is done so we can flush the write-behind store.
- cacheCtx.store().forceFlush();
+ // Partition release future is done so we can flush the write-behind store.
+ cacheCtx.store().forceFlush();
- if (!exchId.isJoined())
- // Process queued undeploys prior to sending/spreading map.
- cacheCtx.preloader().unwindUndeploys();
+ if (!exchId.isJoined())
+ // Process queued undeploys prior to sending/spreading map.
+ cacheCtx.preloader().unwindUndeploys();
- GridDhtPartitionTopology top = cacheCtx.topology();
+ GridDhtPartitionTopology top = cacheCtx.topology();
- assert topVer.equals(top.topologyVersion()) :
- "Topology version is updated only in this class instances inside single ExchangeWorker thread.";
+ assert topVer.equals(top.topologyVersion()) :
+ "Topology version is updated only in this class instances inside single ExchangeWorker thread.";
- top.beforeExchange(this);
- }
+ top.beforeExchange(this);
+ }
- for (GridClientPartitionTopology top : cctx.exchange().clientTopologies()) {
- top.updateTopologyVersion(exchId, this, -1, stopping(top.cacheId()));
+ for (GridClientPartitionTopology top : cctx.exchange().clientTopologies()) {
+ top.updateTopologyVersion(exchId, this, -1, stopping(top.cacheId()));
- top.beforeExchange(this);
- }
+ top.beforeExchange(this);
}
- catch (IgniteInterruptedCheckedException e) {
- onDone(e);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ onDone(e);
- throw e;
- }
- catch (Throwable e) {
- U.error(log, "Failed to reinitialize local partitions (preloading will be stopped): " + exchId, e);
+ throw e;
+ }
+ catch (Throwable e) {
+ U.error(log, "Failed to reinitialize local partitions (preloading will be stopped): " + exchId, e);
- onDone(e);
+ onDone(e);
- if (e instanceof Error)
- throw (Error)e;
+ if (e instanceof Error)
+ throw (Error)e;
- return;
- }
+ return;
+ }
- if (F.isEmpty(rmtIds)) {
- onDone(exchId.topologyVersion());
+ if (crd.isLocal()) {
+ if (F.isEmpty(remaining)) {
+ if (onAllReceived())
+ return;
+
+ onDone(resExchId.topologyVersion());
return;
}
+ }
+ else
+ sendPartitions(crd);
- ready.set(true);
-
- initFut.onDone(true);
-
- if (log.isDebugEnabled())
- log.debug("Initialized future: " + this);
-
- ClusterNode oldest = oldestNode.get();
+ ready.set(true);
- // If this node is not oldest.
- if (!oldest.id().equals(cctx.localNodeId()))
- sendPartitions(oldest);
- else {
- boolean allReceived = allReceived();
+ initFut.onDone(true);
- if (allReceived && replied.compareAndSet(false, true)) {
- if (spreadPartitions())
- onDone(exchId.topologyVersion());
- }
- }
+ if (log.isDebugEnabled())
+ log.debug("Initialized future: " + this);
- scheduleRecheck();
- }
- else
- assert false : "Skipped init future: " + this;
+ scheduleRecheck();
}
/**
@@ -1006,14 +935,15 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
/**
* @param nodes Nodes.
- * @param id ID.
* @throws IgniteCheckedException If failed.
*/
- private void sendAllPartitions(Collection<? extends ClusterNode> nodes, GridDhtPartitionExchangeId id)
+ private void sendAllPartitions(Collection<? extends ClusterNode> nodes)
throws IgniteCheckedException {
- GridDhtPartitionsFullMessage m = new GridDhtPartitionsFullMessage(id,
+ AffinityTopologyVersion resTopVer = resExchId.topologyVersion();
+
+ GridDhtPartitionsFullMessage m = new GridDhtPartitionsFullMessage(resExchId,
lastVer.get(),
- id.topologyVersion());
+ resTopVer);
boolean useOldApi = false;
@@ -1026,13 +956,17 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
if (!cacheCtx.isLocal()) {
AffinityTopologyVersion startTopVer = cacheCtx.startTopologyVersion();
- boolean ready = startTopVer == null || startTopVer.compareTo(id.topologyVersion()) <= 0;
+ boolean ready = startTopVer == null || startTopVer.compareTo(resTopVer) <= 0;
if (ready) {
GridDhtPartitionFullMap locMap = cacheCtx.topology().partitionMap(true);
- if (useOldApi)
- locMap = new GridDhtPartitionFullMap(locMap.nodeId(), locMap.nodeOrder(), locMap.updateSequence(), locMap);
+ if (useOldApi) {
+ locMap = new GridDhtPartitionFullMap(locMap.nodeId(),
+ locMap.nodeOrder(),
+ locMap.updateSequence(),
+ locMap);
+ }
m.addFullPartitionsMap(cacheCtx.cacheId(), locMap);
@@ -1078,21 +1012,22 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
/**
* @return {@code True} if succeeded.
*/
- private boolean spreadPartitions() {
- try {
- sendAllPartitions(rmtNodes, exchId);
-
- return true;
- }
- catch (IgniteCheckedException e) {
- scheduleRecheck();
-
- if (!X.hasCause(e, InterruptedException.class))
- U.error(log, "Failed to send full partition map to nodes (will retry after timeout) [nodes=" +
- F.nodeId8s(rmtNodes) + ", exchangeId=" + exchId + ']', e);
-
- return false;
- }
+ private void spreadPartitions() {
+ // TODO IGNITE-1837.
+// try {
+// sendAllPartitions(rmtNodes, exchId);
+//
+// return true;
+// }
+// catch (IgniteCheckedException e) {
+// scheduleRecheck();
+//
+// if (!X.hasCause(e, InterruptedException.class))
+// U.error(log, "Failed to send full partition map to nodes (will retry after timeout) [nodes=" +
+// F.nodeId8s(rmtNodes) + ", exchangeId=" + exchId + ']', e);
+//
+// return false;
+// }
}
/** {@inheritDoc} */
@@ -1112,7 +1047,9 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
cctx.cache().onExchangeDone(exchId.topologyVersion(), reqs, err);
- cctx.exchange().onExchangeDone(this, err);
+ log.info("Finish exchange [topVer=" + topologyVersion() + ", resTopVer=" + res + ", evt=" + discoEvt + ']');
+
+ cctx.exchange().onExchangeDone(this, res, err);
if (super.onDone(res, err) && !dummy && !forcePreload) {
if (log.isDebugEnabled())
@@ -1164,37 +1101,17 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
topSnapshot.set(null);
singleMsgs.clear();
fullMsgs.clear();
- rcvdIds.clear();
- oldestNode.set(null);
partReleaseFut = null;
-
- Collection<ClusterNode> rmtNodes = this.rmtNodes;
-
- if (rmtNodes != null)
- rmtNodes.clear();
}
/**
- * @return {@code True} if all replies are received.
- */
- private boolean allReceived() {
- Collection<UUID> rmtIds = this.rmtIds;
-
- assert rmtIds != null : "Remote Ids can't be null: " + this;
-
- synchronized (rcvdIds) {
- return rcvdIds.containsAll(rmtIds);
- }
- }
-
- /**
- * @param nodeId Sender node id.
+ * @param node Sender node.
* @param msg Single partition info.
*/
- public void onReceive(final UUID nodeId, final GridDhtPartitionsSingleMessage msg) {
+ public void onReceive(final ClusterNode node, final GridDhtPartitionsSingleMessage msg) {
assert msg != null;
- assert msg.exchangeId().equals(exchId);
+ assert msg.exchangeId().compareTo(exchId) >= 0;
// Update last seen version.
while (true) {
@@ -1213,7 +1130,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
log.debug("Received message for finished future (will reply only to sender) [msg=" + msg +
", fut=" + this + ']');
- sendAllPartitions(nodeId, cctx.gridConfig().getNetworkSendRetryCount());
+ sendAllPartitions(node.id(), cctx.gridConfig().getNetworkSendRetryCount());
}
else {
initFut.listen(new CI1<IgniteInternalFuture<Boolean>>() {
@@ -1228,50 +1145,111 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
return;
}
- ClusterNode loc = cctx.localNode();
+ boolean allReceived = false;
- singleMsgs.put(nodeId, msg);
+ List<ClusterNode> rmtNodes = null;
- boolean match = true;
+ synchronized (mux) {
+ log.info("Future received message [node=" + node.id() + ", remaining=" + remaining + ']');
- // Check if oldest node has changed.
- if (!oldestNode.get().equals(loc)) {
- match = false;
+ assert crd != null;
- synchronized (mux) {
- // Double check.
- if (oldestNode.get().equals(loc))
- match = true;
- }
- }
+ if (crd.isLocal()) {
+ if (remaining.remove(node.id())) {
+ updatePartitionSingleMap(msg);
- if (match) {
- boolean allReceived;
+ allReceived = remaining.isEmpty();
- synchronized (rcvdIds) {
- if (rcvdIds.add(nodeId))
- updatePartitionSingleMap(msg);
+ if (allReceived) {
+ rmtNodes = new ArrayList<>(srvNodes);
- allReceived = allReceived();
+ rmtNodes.remove(crd);
+ }
+ }
}
+ else
+ singleMsgs.put(node, msg);
+ }
- // If got all replies, and initialization finished, and reply has not been sent yet.
- if (allReceived && ready.get() && replied.compareAndSet(false, true)) {
- spreadPartitions();
+ if (allReceived && onAllReceived())
+ return;
- onDone(exchId.topologyVersion());
+ // If got all replies, and initialization finished, and reply has not been sent yet.
+ if (allReceived && ready.get() && replied.compareAndSet(false, true)) {
+ try {
+ sendAllPartitions(rmtNodes);
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to send partitions full message: " + e, e);
}
- else if (log.isDebugEnabled())
- log.debug("Exchange future full map is not sent [allReceived=" + allReceived() +
- ", ready=" + ready + ", replied=" + replied.get() + ", init=" + init.get() +
- ", fut=" + GridDhtPartitionsExchangeFuture.this + ']');
+
+ onDone(resExchId.topologyVersion());
}
+ else if (log.isDebugEnabled())
+ log.debug("Exchange future full map is not sent [ready=" + ready +
+ ", replied=" + replied.get() + ", fut=" + GridDhtPartitionsExchangeFuture.this + ']');
}
});
}
}
/**
+ * @param evts Events.
+ */
+ public void processJoinExchanges(Collection<DiscoveryEvent> evts) {
+ synchronized (mux) {
+ if (addedJoinEvts == null)
+ addedJoinEvts = new ArrayList<>();
+
+ addedJoinEvts.addAll(evts);
+
+ for (DiscoveryEvent evt : evts) {
+ log.info("Future add join message [node=" + evt.eventNode().id() + ", remaining=" + remaining + ']');
+
+ boolean add = remaining.add(evt.eventNode().id());
+
+ assert add : evt;
+
+ add = srvNodes.add(evt.eventNode());
+
+ assert add : evt;
+ }
+ }
+ }
+
+ private boolean onAllReceived() {
+ if (discoEvt.type() == EVT_NODE_JOINED) {
+ if (cctx.exchange().beforeFinishJoinExchange(this))
+ return true;
+ }
+
+ resExchId = exchId;
+
+ List<DiscoveryEvent> addedJoinEvts;
+
+ synchronized (mux) {
+ addedJoinEvts = this.addedJoinEvts;
+ }
+
+ if (addedJoinEvts != null) {
+ for (DiscoveryEvent evt : addedJoinEvts) {
+ AffinityTopologyVersion topVer = new AffinityTopologyVersion(evt.topologyVersion());
+
+ for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
+ if (cacheCtx.isLocal())
+ continue;
+
+ cacheCtx.affinity().calculateAffinity(topVer, evt);
+ }
+
+ resExchId = new GridDhtPartitionExchangeId(evt.eventNode().id(), evt.type(), topVer);
+ }
+ }
+
+ return false;
+ }
+
+ /**
* @param nodeId Node ID.
* @param retryCnt Number of retries.
*/
@@ -1280,7 +1258,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
try {
if (n != null)
- sendAllPartitions(F.asList(n), exchId);
+ sendAllPartitions(F.asList(n));
}
catch (IgniteCheckedException e) {
if (e instanceof ClusterTopologyCheckedException || !cctx.discovery().alive(n)) {
@@ -1308,10 +1286,10 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
}
/**
- * @param nodeId Sender node ID.
+ * @param node Sender node.
* @param msg Full partition info.
*/
- public void onReceive(final UUID nodeId, final GridDhtPartitionsFullMessage msg) {
+ public void onReceive(final ClusterNode node, final GridDhtPartitionsFullMessage msg) {
assert msg != null;
if (isDone()) {
@@ -1322,9 +1300,9 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
}
if (log.isDebugEnabled())
- log.debug("Received full partition map from node [nodeId=" + nodeId + ", msg=" + msg + ']');
+ log.debug("Received full partition map from node [node=" + node + ", msg=" + msg + ']');
- assert exchId.topologyVersion().equals(msg.topologyVersion());
+ assert msg.topologyVersion().compareTo(exchId.topologyVersion()) >= 0;
initFut.listen(new CI1<IgniteInternalFuture<Boolean>>() {
@Override public void apply(IgniteInternalFuture<Boolean> f) {
@@ -1338,39 +1316,62 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
return;
}
- ClusterNode curOldest = oldestNode.get();
-
- if (!nodeId.equals(curOldest.id())) {
- if (log.isDebugEnabled())
- log.debug("Received full partition map from unexpected node [oldest=" + curOldest.id() +
- ", unexpectedNodeId=" + nodeId + ']');
-
- ClusterNode snd = cctx.discovery().node(nodeId);
+ synchronized (mux) {
+ if (crd == null)
+ return;
- if (snd == null) {
+ if (!crd.equals(node)) {
if (log.isDebugEnabled())
- log.debug("Sender node left grid, will ignore message from unexpected node [nodeId=" + nodeId +
- ", exchId=" + msg.exchangeId() + ']');
+ log.debug("Received full partition map from unexpected node [oldest=" + crd.id() +
+ ", nodeId=" + node.id() + ']');
+
+ if (node.order() > crd.order())
+ fullMsgs.put(node, msg);
return;
}
-
- // Will process message later if sender node becomes oldest node.
- if (snd.order() > curOldest.order())
- fullMsgs.put(nodeId, msg);
-
- return;
}
- assert msg.exchangeId().equals(exchId);
+ assert msg.exchangeId().compareTo(exchId) >= 0;
assert msg.lastVersion() != null;
- cctx.versions().onReceived(nodeId, msg.lastVersion());
+ cctx.versions().onReceived(node.id(), msg.lastVersion());
updatePartitionFullMap(msg);
- onDone(exchId.topologyVersion());
+ final AffinityTopologyVersion resTopVer = msg.topologyVersion();
+
+ if (!resTopVer.equals(topologyVersion())) {
+ assert resTopVer.compareTo(topologyVersion()) >= 0;
+
+ IgniteInternalFuture<Map<AffinityTopologyVersion, DiscoveryEvent>> discoFut =
+ cctx.exchange().discoveryFuture(topologyVersion(), resTopVer);
+
+ discoFut.listen(new CI1<IgniteInternalFuture<Map<AffinityTopologyVersion, DiscoveryEvent>>>() {
+ @Override public void apply(IgniteInternalFuture<Map<AffinityTopologyVersion, DiscoveryEvent>> fut) {
+ try {
+ Map<AffinityTopologyVersion, DiscoveryEvent> evts = fut.get();
+
+ for (Map.Entry<AffinityTopologyVersion, DiscoveryEvent> e : evts.entrySet()) {
+ for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
+ if (cacheCtx.isLocal())
+ continue;
+
+ cacheCtx.affinity().calculateAffinity(e.getKey(), e.getValue());
+ }
+ }
+
+ onDone(resTopVer);
+ }
+ catch (IgniteCheckedException e) {
+ onDone(e);
+ }
+ }
+ });
+ }
+
+ onDone(resTopVer);
}
});
}
@@ -1389,12 +1390,12 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
GridCacheContext cacheCtx = cctx.cacheContext(cacheId);
if (cacheCtx != null)
- cacheCtx.topology().update(exchId, entry.getValue(), cntrMap);
+ cacheCtx.topology().update(msg.exchangeId(), entry.getValue(), cntrMap);
else {
ClusterNode oldest = CU.oldestAliveCacheServerNode(cctx, AffinityTopologyVersion.NONE);
if (oldest != null && oldest.isLocal())
- cctx.exchange().clientTopology(cacheId, this).update(exchId, entry.getValue(), cntrMap);
+ cctx.exchange().clientTopology(cacheId, this).update(msg.exchangeId(), entry.getValue(), cntrMap);
}
}
}
@@ -1412,14 +1413,14 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
GridDhtPartitionTopology top = cacheCtx != null ? cacheCtx.topology() :
cctx.exchange().clientTopology(cacheId, this);
- top.update(exchId, entry.getValue(), msg.partitionUpdateCounters(cacheId));
+ top.update(msg.exchangeId(), entry.getValue(), msg.partitionUpdateCounters(cacheId));
}
}
/**
- * @param nodeId Left node id.
+ * @param node Left node.
*/
- public void onNodeLeft(final UUID nodeId) {
+ public void onNodeLeft(final ClusterNode node) {
if (isDone())
return;
@@ -1447,94 +1448,67 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
return;
try {
- // Pretend to have received message from this node.
- rcvdIds.add(nodeId);
-
- Collection<UUID> rmtIds = GridDhtPartitionsExchangeFuture.this.rmtIds;
-
- assert rmtIds != null;
-
- ClusterNode oldest = oldestNode.get();
-
- if (oldest.id().equals(nodeId)) {
- if (log.isDebugEnabled())
- log.debug("Oldest node left or failed on partition exchange " +
- "(will restart exchange process)) [oldestNodeId=" + oldest.id() +
- ", exchangeId=" + exchId + ']');
-
- boolean set = false;
-
- ClusterNode newOldest = CU.oldestAliveCacheServerNode(cctx, exchId.topologyVersion());
-
- if (newOldest != null) {
- // If local node is now oldest.
- if (newOldest.id().equals(cctx.localNodeId())) {
- synchronized (mux) {
- if (oldestNode.compareAndSet(oldest, newOldest)) {
- // If local node is just joining.
- if (exchId.nodeId().equals(cctx.localNodeId())) {
- try {
- for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
- if (!cacheCtx.isLocal())
- cacheCtx.topology().beforeExchange(
- GridDhtPartitionsExchangeFuture.this);
- }
- }
- catch (IgniteCheckedException e) {
- onDone(e);
-
- return;
- }
- }
-
- set = true;
- }
- }
- }
- else {
- synchronized (mux) {
- set = oldestNode.compareAndSet(oldest, newOldest);
- }
+ boolean crdChanged = false;
+ boolean allReceived = false;
- if (set && log.isDebugEnabled())
- log.debug("Reassigned oldest node [this=" + cctx.localNodeId() +
- ", old=" + oldest.id() + ", new=" + newOldest.id() + ']');
- }
- }
- else {
- ClusterTopologyCheckedException err = new ClusterTopologyCheckedException("Failed to " +
- "wait for exchange future, all server nodes left.");
+ ClusterNode crd0;
+
+ synchronized (mux) {
+ srvNodes.remove(node);
+
+ boolean rmvd = remaining.remove(node.id());
+
+ if (node.equals(crd)) {
+ crdChanged = true;
- onDone(err);
+ crd = srvNodes.size() > 0 ? srvNodes.get(0) : null;
}
- if (set) {
- // If received any messages, process them.
- for (Map.Entry<UUID, GridDhtPartitionsSingleMessage> m : singleMsgs.entrySet())
- onReceive(m.getKey(), m.getValue());
+ if (crd != null && crd.isLocal() && rmvd)
+ allReceived = remaining.isEmpty();
- for (Map.Entry<UUID, GridDhtPartitionsFullMessage> m : fullMsgs.entrySet())
- onReceive(m.getKey(), m.getValue());
+ crd0 = crd;
+ }
- // Reassign oldest node and resend.
- recheck();
+ if (crd0 == null) {
+ assert cctx.kernalContext().clientNode() || cctx.localNode().isDaemon() : cctx.localNode();
+
+ List<ClusterNode> empty = Collections.emptyList();
+
+ for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
+ List<List<ClusterNode>> affAssignment = new ArrayList<>(cacheCtx.affinity().partitions());
+
+ for (int i = 0; i < cacheCtx.affinity().partitions(); i++)
+ affAssignment.add(empty);
+
+ cacheCtx.affinity().initializeAffinity(topologyVersion(), affAssignment);
}
+
+ onDone(topologyVersion());
+
+ return;
}
- else if (rmtIds.contains(nodeId)) {
- if (log.isDebugEnabled())
- log.debug("Remote node left of failed during partition exchange (will ignore) " +
- "[rmtNode=" + nodeId + ", exchangeId=" + exchId + ']');
- assert rmtNodes != null;
+ if (crd0.isLocal()) {
+ if (allReceived) {
+ if (onAllReceived())
+ return;
- for (Iterator<ClusterNode> it = rmtNodes.iterator(); it.hasNext(); ) {
- if (it.next().id().equals(nodeId))
- it.remove();
+ onDone(resExchId.topologyVersion());
+
+ return;
}
- if (allReceived() && ready.get() && replied.compareAndSet(false, true))
- if (spreadPartitions())
- onDone(exchId.topologyVersion());
+ for (Map.Entry<ClusterNode, GridDhtPartitionsSingleMessage> m : singleMsgs.entrySet())
+ onReceive(m.getKey(), m.getValue());
+ }
+ else {
+ if (crdChanged) {
+ sendPartitions(crd0);
+
+ for (Map.Entry<ClusterNode, GridDhtPartitionsFullMessage> m : fullMsgs.entrySet())
+ onReceive(m.getKey(), m.getValue());
+ }
}
}
finally {
@@ -1552,33 +1526,42 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
*
*/
private void recheck() {
- ClusterNode oldest = oldestNode.get();
+ ClusterNode oldest;
- // If this is the oldest node.
- if (oldest.id().equals(cctx.localNodeId())) {
- Collection<UUID> remaining = remaining();
-
- if (!remaining.isEmpty()) {
- try {
- cctx.io().safeSend(cctx.discovery().nodes(remaining),
- new GridDhtPartitionsSingleRequest(exchId), SYSTEM_POOL, null);
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to request partitions from nodes [exchangeId=" + exchId +
- ", nodes=" + remaining + ']', e);
- }
- }
- // Resend full partition map because last attempt failed.
- else {
- if (spreadPartitions())
- onDone(exchId.topologyVersion());
- }
+ synchronized (mux) {
+ oldest = crd;
}
- else
- sendPartitions(oldest);
- // Schedule another send.
- scheduleRecheck();
+ if (oldest == null)
+ return;
+
+ // TODO IGNITE-1837.
+
+ // If this is the oldest node.
+// if (oldest.id().equals(cctx.localNodeId())) {
+// Collection<UUID> remaining = remaining();
+//
+// if (!remaining.isEmpty()) {
+// try {
+// cctx.io().safeSend(cctx.discovery().nodes(remaining),
+// new GridDhtPartitionsSingleRequest(exchId), SYSTEM_POOL, null);
+// }
+// catch (IgniteCheckedException e) {
+// U.error(log, "Failed to request partitions from nodes [exchangeId=" + exchId +
+// ", nodes=" + remaining + ']', e);
+// }
+// }
+// // Resend full partition map because last attempt failed.
+// else {
+// if (spreadPartitions())
+// onDone(exchId.topologyVersion());
+// }
+// }
+// else
+// sendPartitions(oldest);
+//
+// // Schedule another send.
+// scheduleRecheck();
}
/**
@@ -1605,12 +1588,11 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
try {
U.warn(log,
"Retrying preload partition exchange due to timeout [done=" + isDone() +
- ", dummy=" + dummy + ", exchId=" + exchId + ", rcvdIds=" + F.id8s(rcvdIds) +
- ", rmtIds=" + F.id8s(rmtIds) + ", remaining=" + F.id8s(remaining()) +
- ", init=" + init + ", initFut=" + initFut.isDone() +
- ", ready=" + ready + ", replied=" + replied + ", added=" + added +
- ", oldest=" + U.id8(oldestNode.get().id()) + ", oldestOrder=" +
- oldestNode.get().order() + ", evtLatch=" + evtLatch.getCount() +
+ ", dummy=" + dummy + ", exchId=" + exchId +
+ ", rmtIds=" + ", remaining=" +
+ ", initFut=" + initFut.isDone() +
+ ", ready=" + ready + ", replied=" + replied +
+ ", oldest=" + crd + ", evtLatch=" + evtLatch.getCount() +
", locNodeOrder=" + cctx.localNode().order() +
", locNodeId=" + cctx.localNode().id() + ']',
"Retrying preload partition exchange due to timeout.");
@@ -1631,16 +1613,6 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
}
}
- /**
- * @return Remaining node IDs.
- */
- Collection<UUID> remaining() {
- if (rmtIds == null)
- return Collections.emptyList();
-
- return F.lose(rmtIds, true, rcvdIds);
- }
-
/** {@inheritDoc} */
@Override public int compareTo(GridDhtPartitionsExchangeFuture fut) {
return exchId.compareTo(fut.exchId);
@@ -1663,13 +1635,19 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
/** {@inheritDoc} */
@Override public String toString() {
- ClusterNode oldestNode = this.oldestNode.get();
+ ClusterNode oldestNode;
+ Set<UUID> remaining;
+
+ synchronized (mux) {
+ oldestNode = this.crd;
+ remaining = new HashSet<>(this.remaining);
+ }
return S.toString(GridDhtPartitionsExchangeFuture.class, this,
"oldest", oldestNode == null ? "null" : oldestNode.id(),
"oldestOrder", oldestNode == null ? "null" : oldestNode.order(),
"evtLatch", evtLatch == null ? "null" : evtLatch.getCount(),
- "remaining", remaining(),
+ "remaining", remaining,
"super", super.toString());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/08f46583/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
index 6194552..0360678 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsFullMessage.java
@@ -21,6 +21,7 @@ import java.io.Externalizable;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridDirectTransient;
@@ -78,7 +79,7 @@ public class GridDhtPartitionsFullMessage extends GridDhtPartitionsAbstractMessa
@NotNull AffinityTopologyVersion topVer) {
super(id, lastVer);
- assert id == null || topVer.equals(id.topologyVersion());
+ assert id == null || topVer.compareTo(id.topologyVersion()) >= 0;
this.topVer = topVer;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/08f46583/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java b/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
index 8a602ad..07d61fa 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/TestRecordingCommunicationSpi.java
@@ -82,6 +82,8 @@ public class TestRecordingCommunicationSpi extends TcpCommunicationSpi {
}
if (block) {
+ ignite.log().info("Block message [node=" + node.id() + ", msg=" + ioMsg.message() + ']');
+
blockedMsgs.add(new T2<>(node, ioMsg));
return;
@@ -148,8 +150,14 @@ public class TestRecordingCommunicationSpi extends TcpCommunicationSpi {
synchronized (this) {
blockCls.clear();
- for (T2<ClusterNode, GridIoMessage> msg : blockedMsgs)
+ blockP = null;
+
+ for (T2<ClusterNode, GridIoMessage> msg : blockedMsgs) {
+ ignite.log().info("Send blocked message [node=" + msg.get1().id() +
+ ", msg=" + msg.get2().message() + ']');
+
super.sendMessage(msg.get1(), msg.get2());
+ }
blockedMsgs.clear();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/08f46583/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimizedPartitionsExchangeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimizedPartitionsExchangeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimizedPartitionsExchangeTest.java
new file mode 100644
index 0000000..5b38680
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteOptimizedPartitionsExchangeTest.java
@@ -0,0 +1,207 @@
+/*
+ * 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.cache.distributed;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.TestRecordingCommunicationSpi;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class IgniteOptimizedPartitionsExchangeTest extends GridCommonAbstractTest {
+ /** */
+ protected static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private boolean client;
+
+ /** */
+ private ThreadLocal<IgnitePredicate<GridIoMessage>> blockP = new ThreadLocal<>();
+
+ /** */
+ private final Map<String, TestRecordingCommunicationSpi> commSpis = new HashMap<>();
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ cfg.setClientMode(client);
+
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ cfg.setCacheConfiguration(ccfg);
+
+ TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
+
+ IgnitePredicate<GridIoMessage> p = blockP.get();
+
+ if (p != null) {
+ commSpi.blockMessages(p);
+
+ blockP.remove();
+ }
+
+ synchronized (commSpis) {
+ commSpis.put(gridName, commSpi);
+
+ commSpis.notifyAll();
+ }
+
+ cfg.setCommunicationSpi(commSpi);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+
+ super.afterTest();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultipleJoin() throws Exception {
+ Ignite ignite0 = startGrid(0);
+
+ TestRecordingCommunicationSpi spi0 = waitSpi(getTestGridName(0));
+
+ spi0.record(GridDhtPartitionsFullMessage.class);
+
+ IgniteInternalFuture<?> fut1 = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ blockP.set(blockSinglePartitions(2));
+
+ startGrid(1);
+
+ return null;
+ }
+ }, "start-1");
+
+ ((IgniteKernal)ignite0).context().discovery().topologyFuture(2).get();
+
+ IgniteInternalFuture<?> fut2 = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ blockP.set(blockSinglePartitions(3));
+
+ startGrid(2);
+
+ return null;
+ }
+ }, "start-2");
+
+ TestRecordingCommunicationSpi spi1 = waitSpi(getTestGridName(1));
+ TestRecordingCommunicationSpi spi2 = waitSpi(getTestGridName(2));
+
+ ((IgniteKernal)ignite0).context().discovery().topologyFuture(3).get();
+
+ spi1.stopBlock();
+ spi2.stopBlock();
+
+ fut1.get();
+ fut2.get();
+
+ assertEquals(2, spi0.recordedMessages().size());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultipleJoinJoinedLeft() throws Exception {
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultipleJoinClients() throws Exception {
+
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultipleJoinCoordinatorLeft() throws Exception {
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultipleJoinJoinedStartCache() throws Exception {
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testJoiningNodeBecomeCoordinator() throws Exception {
+ }
+
+ /**
+ * @param topVer Message topology version.
+ * @return Message block predicate.
+ */
+ private IgnitePredicate<GridIoMessage> blockSinglePartitions(final long topVer) {
+ return new IgnitePredicate<GridIoMessage>() {
+ @Override public boolean apply(GridIoMessage msg0) {
+ Message msg = msg0.message();
+
+ if (msg instanceof GridDhtPartitionsSingleMessage) {
+ GridDhtPartitionsSingleMessage pMsg = (GridDhtPartitionsSingleMessage)msg;
+
+ return pMsg.exchangeId().topologyVersion().topologyVersion() == topVer;
+ }
+
+ return false;
+ }
+ };
+ }
+
+ /**
+ * @param nodeName Node name.
+ * @return Communication SPI.
+ * @throws Exception If failed.
+ */
+ private TestRecordingCommunicationSpi waitSpi(String nodeName) throws Exception {
+ synchronized (commSpis) {
+ while (!commSpis.containsKey(nodeName))
+ commSpis.wait();
+
+ return commSpis.get(nodeName);
+ }
+ }
+}
[22/50] [abbrv] ignite git commit: IGNITE-2860: IGFS: Fixed minor bug
in append() operation.
Posted by sb...@apache.org.
IGNITE-2860: IGFS: Fixed minor bug in append() operation.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8de40f2f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8de40f2f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8de40f2f
Branch: refs/heads/ignite-1837
Commit: 8de40f2f8649c9ffecf86202f9fd4efbc3827e83
Parents: bfa7bf6
Author: thatcoach <pp...@list.ru>
Authored: Fri Mar 18 21:15:04 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:42 2016 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/processors/igfs/IgfsMetaManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8de40f2f/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index 84e4dae..d66d9be 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -3549,7 +3549,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteUuid oldId = pathIds.lastId();
id2InfoPrj.invoke(trashId, new ListingAddProcessor(oldId.toString(),
- new IgfsListingEntry(oldId, true)));
+ new IgfsListingEntry(oldInfo)));
// Second step: replace ID in parent directory.
String name = pathIds.lastPart();
[44/50] [abbrv] ignite git commit: IGNITE-2947 BinaryContext doesn't
honor custom loader set through IgniteConfiguration.classLoader
Posted by sb...@apache.org.
IGNITE-2947
BinaryContext doesn't honor custom loader set through IgniteConfiguration.classLoader
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/86347272
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/86347272
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/86347272
Branch: refs/heads/ignite-1837
Commit: 86347272e712a0e61a5a763dda3458fde79f29c4
Parents: 87f7522
Author: Anton Vinogradov <av...@apache.org>
Authored: Wed Apr 6 11:35:36 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Apr 6 11:35:36 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/binary/BinaryContext.java | 2 +-
...acheBinaryObjectUserClassloaderSelfTest.java | 147 +++++++++++++++++++
.../IgniteBinaryObjectsTestSuite.java | 3 +
3 files changed, 151 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/86347272/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 4d8c293..9a9ef10 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
@@ -992,7 +992,7 @@ public class BinaryContext {
Class<?> cls = null;
try {
- cls = Class.forName(clsName);
+ cls = U.resolveClassLoader(configuration()).loadClass(clsName);
}
catch (ClassNotFoundException | NoClassDefFoundError ignored) {
// No-op.
http://git-wip-us.apache.org/repos/asf/ignite/blob/86347272/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java
new file mode 100644
index 0000000..ca09e4c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java
@@ -0,0 +1,147 @@
+/*
+ * 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.cache.binary;
+
+import java.util.Collections;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinarySerializer;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class GridCacheBinaryObjectUserClassloaderSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static volatile boolean customBinaryConf = false;
+
+ /** */
+ private static volatile boolean deserialized = false;
+
+ /** */
+ private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(ipFinder);
+
+ cfg.setDiscoverySpi(disco);
+
+ cfg.setCacheConfiguration(cacheConfiguration(gridName));
+
+ cfg.setMarshaller(new BinaryMarshaller());
+
+ cfg.setClassLoader(getExternalClassLoader());
+
+ if (customBinaryConf) {
+ BinaryTypeConfiguration btcfg = new BinaryTypeConfiguration();
+
+ btcfg.setTypeName("org.apache.ignite.tests.p2p.CacheDeploymentTestValue3");
+
+ btcfg.setSerializer(new BinarySerializer() {
+ /** {@inheritDoc} */
+ @Override public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
+ //No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
+ deserialized = true;
+ }
+ });
+
+ BinaryConfiguration bcfg = new BinaryConfiguration();
+
+ bcfg.setTypeConfigurations(Collections.singletonList(btcfg));
+
+ cfg.setBinaryConfiguration(bcfg);
+ }
+
+ return cfg;
+ }
+
+ /**
+ * Gets cache configuration for grid with specified name.
+ *
+ * @param gridName Grid name.
+ * @return Cache configuration.
+ */
+ CacheConfiguration cacheConfiguration(String gridName) {
+ CacheConfiguration cacheCfg = defaultCacheConfiguration();
+
+ cacheCfg.setCacheMode(REPLICATED);
+ cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ return cacheCfg;
+ }
+
+ /**
+ * @throws Exception If test failed.
+ */
+ public void testConfigurationRegistration() throws Exception {
+ try {
+ customBinaryConf = true;
+
+ Ignite i1 = startGrid(1);
+ Ignite i2 = startGrid(2);
+
+ IgniteCache<Integer, Object> cache1 = i1.cache(null);
+ IgniteCache<Integer, Object> cache2 = i2.cache(null);
+
+ ClassLoader ldr = i1.configuration().getClassLoader();
+
+ Object v1 = ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestValue3").newInstance();
+
+ cache1.put(1, v1);
+
+ deserialized = false;
+
+ cache2.get(1);
+
+ assertTrue(deserialized);
+ }
+ finally {
+ customBinaryConf = false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/86347272/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
index 2b49597..f28d5a8 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
@@ -45,6 +45,7 @@ import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderAdditiona
import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactDefaultMappersSelfTest;
import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest;
import org.apache.ignite.internal.processors.cache.BinaryObjectOffHeapUnswapTemporaryTest;
+import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryObjectUserClassloaderSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesDefaultMappersSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreObjectsSelfTest;
@@ -134,6 +135,8 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
suite.addTestSuite(BinaryTxCacheLocalEntriesSelfTest.class);
suite.addTestSuite(BinaryAtomicCacheLocalEntriesSelfTest.class);
+ suite.addTestSuite(GridCacheBinaryObjectUserClassloaderSelfTest.class);
+
return suite;
}
}
[42/50] [abbrv] ignite git commit: IGNITE-2822 Continuous query local
listener can be notified with empty list of events
Posted by sb...@apache.org.
IGNITE-2822
Continuous query local listener can be notified with empty list of events
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2397552d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2397552d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2397552d
Branch: refs/heads/ignite-1837
Commit: 2397552daf6d8cff9b59515c1c8983abdc60f5f4
Parents: d33b434
Author: vdpyatkov <vp...@gridgain.com>
Authored: Tue Apr 5 18:03:55 2016 +0300
Committer: vdpyatkov <vp...@gridgain.com>
Committed: Tue Apr 5 18:03:55 2016 +0300
----------------------------------------------------------------------
.../continuous/CacheContinuousQueryHandler.java | 3 +-
...acheContinuousQueryExecuteInPrimaryTest.java | 306 +++++++++++++++++++
.../IgniteCacheQuerySelfTestSuite3.java | 2 +
3 files changed, 310 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2397552d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index 6243af7..767697a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -382,7 +382,8 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
}
);
- locLsnr.onUpdated(evts);
+ if (!F.isEmpty(evts))
+ locLsnr.onUpdated(evts);
if (!internal && !skipPrimaryCheck)
sendBackupAcknowledge(ackBuf.onAcknowledged(entry), routineId, ctx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2397552d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java
new file mode 100644
index 0000000..1a52909
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryExecuteInPrimaryTest.java
@@ -0,0 +1,306 @@
+/*
+ * 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.cache.query.continuous;
+
+import javax.cache.Cache;
+import javax.cache.configuration.FactoryBuilder;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.jetbrains.annotations.NotNull;
+
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryUpdatedListener;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.LOCAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ * Continuous queries execute in primary node tests.
+ */
+public class CacheContinuousQueryExecuteInPrimaryTest extends GridCommonAbstractTest
+ implements Serializable {
+
+ /** Latch timeout. */
+ protected static final long LATCH_TIMEOUT = 5000;
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setPeerClassLoadingEnabled(true);
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
+ return cfg;
+ }
+
+ /**
+ * @return Cache configuration.
+ */
+ @NotNull
+ protected CacheConfiguration<Integer, String> cacheConfiguration(
+ CacheAtomicityMode cacheAtomicityMode,
+ CacheMode cacheMode) {
+ CacheConfiguration<Integer, String> ccfg = new CacheConfiguration<>();
+
+ ccfg.setAtomicityMode(cacheAtomicityMode);
+ ccfg.setCacheMode(cacheMode);
+ ccfg.setMemoryMode(CacheMemoryMode.ONHEAP_TIERED);
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+ ccfg.setAtomicWriteOrderMode(PRIMARY);
+
+ return ccfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGridsMultiThreaded(1);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocalCache() throws Exception {
+ CacheConfiguration<Integer, String> ccfg = cacheConfiguration(ATOMIC, LOCAL);
+
+ doTestWithoutEventsEntries(ccfg);
+ doTestWithEventsEntries(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReplicatedCache() throws Exception {
+ CacheConfiguration<Integer, String> ccfg = cacheConfiguration(ATOMIC, REPLICATED);
+
+ doTestWithoutEventsEntries(ccfg);
+ doTestWithEventsEntries(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPartitionedCache() throws Exception {
+ CacheConfiguration<Integer, String> ccfg = cacheConfiguration(ATOMIC, PARTITIONED);
+
+ doTestWithoutEventsEntries(ccfg);
+ doTestWithEventsEntries(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTransactionLocalCache() throws Exception {
+ CacheConfiguration<Integer, String> ccfg = cacheConfiguration(TRANSACTIONAL, LOCAL);
+
+ doTestWithoutEventsEntries(ccfg);
+ doTestWithEventsEntries(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTransactionReplicatedCache() throws Exception {
+ CacheConfiguration<Integer, String> ccfg = cacheConfiguration(TRANSACTIONAL, REPLICATED);
+
+ doTestWithoutEventsEntries(ccfg);
+ doTestWithEventsEntries(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTransactionPartitionedCache() throws Exception {
+ CacheConfiguration<Integer, String> ccfg = cacheConfiguration(TRANSACTIONAL, PARTITIONED);
+
+ doTestWithoutEventsEntries(ccfg);
+ doTestWithEventsEntries(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void doTestWithoutEventsEntries(CacheConfiguration<Integer, String> ccfg) throws Exception {
+
+ try (IgniteCache<Integer, String> cache = grid(0).createCache(ccfg)) {
+
+ int ITERATION_CNT = 100;
+ final AtomicBoolean noOneListen = new AtomicBoolean(true);
+
+ for (int i = 0; i < ITERATION_CNT; i++) {
+ ContinuousQuery<Integer, String> qry = new ContinuousQuery<>();
+
+ qry.setLocalListener(new CacheEntryUpdatedListener<Integer, String>() {
+ @Override public void onUpdated(
+ Iterable<CacheEntryEvent<? extends Integer, ? extends String>> iterable)
+ throws CacheEntryListenerException {
+ noOneListen.set(false);
+ }
+ });
+
+ qry.setRemoteFilterFactory(FactoryBuilder.factoryOf(
+ new CacheEntryEventSerializableFilter<Integer, String>() {
+ @Override public boolean evaluate(
+ CacheEntryEvent<? extends Integer, ? extends String> cacheEntryEvent)
+ throws CacheEntryListenerException {
+ return false;
+ }
+ }));
+
+ executeQuery(cache, qry, ccfg.getAtomicityMode() == TRANSACTIONAL);
+ }
+
+ assertTrue(noOneListen.get());
+
+ }
+ finally {
+ ignite(0).destroyCache(ccfg.getName());
+ }
+ }
+
+ private void executeQuery(IgniteCache<Integer, String> cache, ContinuousQuery<Integer, String> qry,
+ boolean isTransactional) {
+ try (QueryCursor<Cache.Entry<Integer, String>> qryCursor = cache.query(qry)) {
+ Transaction tx = null;
+
+ if (isTransactional)
+ tx = cache.unwrap(Ignite.class).transactions().txStart();
+
+ try {
+ for (int key = 0; key < 8; key++)
+ cache.put(key, Integer.toString(key));
+
+ Map<Integer, String> map = new HashMap<>(8);
+
+ for (int key = 8; key < 16; key++)
+ map.put(key, Integer.toString(key));
+
+ cache.putAll(map);
+
+ if (isTransactional)
+ tx.commit();
+
+ }
+ finally {
+ if (isTransactional)
+ tx.close();
+ }
+
+ for (int key = 0; key < 8; key++) {
+ cache.invoke(key, new EntryProcessor<Integer, String, Object>() {
+ @Override public Object process(MutableEntry<Integer, String> entry,
+ Object... objects) throws EntryProcessorException {
+ entry.setValue(Integer.toString(entry.getKey() + 1));
+ return null;
+ }
+
+ });
+ }
+
+ Map<Integer, EntryProcessor<Integer, String, Object>> invokeMap = new HashMap<>(8);
+
+ for (int key = 8; key < 16; key++) {
+ invokeMap.put(key, new EntryProcessor<Integer, String, Object>() {
+ @Override public Object process(MutableEntry<Integer, String> entry,
+ Object... objects) throws EntryProcessorException {
+ entry.setValue(Integer.toString(entry.getKey() - 1));
+
+ return null;
+ }
+ });
+ }
+
+ cache.invokeAll(invokeMap);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void doTestWithEventsEntries(CacheConfiguration<Integer, String> ccfg) throws Exception {
+ try (IgniteCache<Integer, String> cache = grid(0).createCache(ccfg)) {
+
+ ContinuousQuery<Integer, String> qry = new ContinuousQuery<>();
+
+ final CountDownLatch latch = new CountDownLatch(16);
+ final AtomicInteger cnt = new AtomicInteger(0);
+
+ qry.setLocalListener(new CacheEntryUpdatedListener<Integer, String>() {
+ @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends String>> iterable)
+ throws CacheEntryListenerException {
+ for (CacheEntryEvent<? extends Integer, ? extends String> e : iterable) {
+ cnt.incrementAndGet();
+ latch.countDown();
+ }
+ }
+ });
+
+ qry.setRemoteFilterFactory(FactoryBuilder.factoryOf(
+ new CacheEntryEventSerializableFilter<Integer, String>() {
+ @Override public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends String> e)
+ throws CacheEntryListenerException {
+ return e.getKey() % 2 == 0;
+ }
+ }
+ ));
+
+ // Execute query.
+ executeQuery(cache, qry, ccfg.getAtomicityMode() == TRANSACTIONAL);
+
+ assertTrue(latch.await(LATCH_TIMEOUT, MILLISECONDS));
+ assertEquals(16, cnt.get());
+ }
+ finally {
+ ignite(0).destroyCache(ccfg.getName());
+ }
+
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2397552d/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
index 73c856b..fbb3091 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite3.java
@@ -20,6 +20,7 @@ package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousBatchAckTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousBatchForceServerModeAckTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryExecuteInPrimaryTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFactoryFilterTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryOperationP2PTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTest;
@@ -91,6 +92,7 @@ public class IgniteCacheQuerySelfTestSuite3 extends TestSuite {
suite.addTestSuite(CacheContinuousQueryOperationP2PTest.class);
suite.addTestSuite(CacheContinuousBatchAckTest.class);
suite.addTestSuite(CacheContinuousBatchForceServerModeAckTest.class);
+ suite.addTestSuite(CacheContinuousQueryExecuteInPrimaryTest.class);
return suite;
}
[06/50] [abbrv] ignite git commit: IGNITE-2754: IGFS: Created
separate processor for listing remove operation.
Posted by sb...@apache.org.
IGNITE-2754: IGFS: Created separate processor for listing remove operation.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/219238f2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/219238f2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/219238f2
Branch: refs/heads/ignite-1837
Commit: 219238f2793a3f3f9f5705a065c67510c286df1c
Parents: 99028b5
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Mar 3 13:25:43 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:12:44 2016 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsMetaManager.java | 160 ++++++++++++-------
1 file changed, 105 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/219238f2/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index 0ba78c5..c120b9d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -43,6 +43,7 @@ import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.EntryProcessorResult;
import javax.cache.processor.MutableEntry;
+
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteInterruptedException;
@@ -847,7 +848,7 @@ public class IgfsMetaManager extends IgfsManager {
if (!id2InfoPrj.putIfAbsent(fileId, newFileInfo))
throw fsException("Failed to add file details into cache: " + newFileInfo);
- id2InfoPrj.invoke(parentId, new UpdateListing(fileName, new IgfsListingEntry(newFileInfo), false));
+ id2InfoPrj.invoke(parentId, new ListingAdd(fileName, new IgfsListingEntry(newFileInfo)));
return null;
}
@@ -956,8 +957,8 @@ public class IgfsMetaManager extends IgfsManager {
// 8. Actual move: remove from source parent and add to destination target.
IgfsListingEntry entry = srcTargetInfo.listing().get(srcName);
- id2InfoPrj.invoke(srcTargetId, new UpdateListing(srcName, entry, true));
- id2InfoPrj.invoke(dstTargetId, new UpdateListing(dstName, entry, false));
+ id2InfoPrj.invoke(srcTargetId, new ListingRemove(srcName, entry.fileId()));
+ id2InfoPrj.invoke(dstTargetId, new ListingAdd(dstName, entry));
tx.commit();
@@ -1093,10 +1094,10 @@ public class IgfsMetaManager extends IgfsManager {
", destParentId=" + destParentId + ", destEntry=" + destEntry + ']'));
// Remove listing entry from the source parent listing.
- id2InfoPrj.invoke(srcParentId, new UpdateListing(srcFileName, srcEntry, true));
+ id2InfoPrj.invoke(srcParentId, new ListingRemove(srcFileName, srcEntry.fileId()));
// Add listing entry into the destination parent listing.
- id2InfoPrj.invoke(destParentId, new UpdateListing(destFileName, srcEntry, false));
+ id2InfoPrj.invoke(destParentId, new ListingAdd(destFileName, srcEntry));
}
/**
@@ -1134,8 +1135,8 @@ public class IgfsMetaManager extends IgfsManager {
id2InfoPrj.put(newInfo.id(), newInfo);
// Add new info to trash listing.
- id2InfoPrj.invoke(TRASH_ID, new UpdateListing(newInfo.id().toString(),
- new IgfsListingEntry(newInfo), false));
+ id2InfoPrj.invoke(TRASH_ID, new ListingAdd(newInfo.id().toString(),
+ new IgfsListingEntry(newInfo)));
// Remove listing entries from root.
// Note that root directory properties and other attributes are preserved:
@@ -1233,10 +1234,10 @@ public class IgfsMetaManager extends IgfsManager {
assert victimId.equals(srcEntry.fileId());
- id2InfoPrj.invoke(srcParentId, new UpdateListing(srcFileName, srcEntry, true));
+ id2InfoPrj.invoke(srcParentId, new ListingRemove(srcFileName, srcEntry.fileId()));
// Add listing entry into the destination parent listing.
- id2InfoPrj.invoke(TRASH_ID, new UpdateListing(destFileName, srcEntry, false));
+ id2InfoPrj.invoke(TRASH_ID, new ListingAdd(destFileName, srcEntry));
if (victimInfo.isFile())
// Update a file info of the removed file with a file path,
@@ -1313,12 +1314,12 @@ public class IgfsMetaManager extends IgfsManager {
id2InfoPrj.getAndPut(newInfo.id(), newInfo);
// Add new info to trash listing.
- id2InfoPrj.invoke(TRASH_ID, new UpdateListing(newInfo.id().toString(),
- new IgfsListingEntry(newInfo), false));
+ id2InfoPrj.invoke(TRASH_ID, new ListingAdd(newInfo.id().toString(),
+ new IgfsListingEntry(newInfo)));
// Remove listing entries from root.
for (Map.Entry<String, IgfsListingEntry> entry : transferListing.entrySet())
- id2InfoPrj.invoke(ROOT_ID, new UpdateListing(entry.getKey(), entry.getValue(), true));
+ id2InfoPrj.invoke(ROOT_ID, new ListingRemove(entry.getKey(), entry.getValue().fileId()));
resId = newInfo.id();
}
@@ -1468,7 +1469,7 @@ public class IgfsMetaManager extends IgfsManager {
IgfsListingEntry listingEntry = parentInfo.listing().get(name);
if (listingEntry != null)
- id2InfoPrj.invoke(parentId, new UpdateListing(name, listingEntry, true));
+ id2InfoPrj.invoke(parentId, new ListingRemove(name, listingEntry.fileId()));
IgfsFileInfo deleted = id2InfoPrj.getAndRemove(id);
@@ -1599,7 +1600,7 @@ public class IgfsMetaManager extends IgfsManager {
assert id2InfoPrj.get(parentId) != null;
- id2InfoPrj.invoke(parentId, new UpdateListing(fileName, entry, false));
+ id2InfoPrj.invoke(parentId, new ListingAdd(fileName, entry));
}
return newInfo;
@@ -2009,9 +2010,9 @@ public class IgfsMetaManager extends IgfsManager {
id2InfoPrj.put(newInfo.id(), newInfo); // Put the new one.
id2InfoPrj.invoke(parentInfo.id(),
- new UpdateListing(path.name(), parentInfo.listing().get(path.name()), true));
+ new ListingRemove(path.name(), parentInfo.listing().get(path.name()).fileId()));
id2InfoPrj.invoke(parentInfo.id(),
- new UpdateListing(path.name(), new IgfsListingEntry(newInfo), false));
+ new ListingAdd(path.name(), new IgfsListingEntry(newInfo)));
IgniteInternalFuture<?> delFut = igfsCtx.data().delete(oldInfo);
}
@@ -3213,10 +3214,82 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
+ * Remove entry from directory listing.
+ */
+ @GridInternal
+ private static final class ListingRemove implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** File name. */
+ private String fileName;
+
+ /** Expected ID. */
+ private IgniteUuid fileId;
+
+ /**
+ * Default constructor.
+ */
+ public ListingRemove() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param fileName File name.
+ * @param fileId File ID.
+ */
+ public ListingRemove(String fileName, IgniteUuid fileId) {
+ this.fileName = fileName;
+ this.fileId = fileId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> e, Object... args)
+ throws EntryProcessorException {
+ IgfsFileInfo fileInfo = e.getValue();
+
+ assert fileInfo != null;
+ assert fileInfo.isDirectory();
+
+ Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
+
+ listing.putAll(fileInfo.listing());
+
+ IgfsListingEntry oldEntry = listing.get(fileName);
+
+ if (oldEntry == null || !oldEntry.fileId().equals(fileId))
+ throw new IgniteException("Directory listing doesn't contain expected file" +
+ " [listing=" + listing + ", fileName=" + fileName + "]");
+
+ // Modify listing in-place.
+ listing.remove(fileName);
+
+ e.setValue(new IgfsFileInfo(listing, fileInfo));
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeString(out, fileName);
+ U.writeGridUuid(out, fileId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ fileName = U.readString(in);
+ fileId = U.readGridUuid(in);
+ }
+ }
+
+ /**
* Update directory listing closure.
*/
@GridInternal
- private static final class UpdateListing implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static final class ListingAdd implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3227,30 +3300,25 @@ public class IgfsMetaManager extends IgfsManager {
/** File ID.*/
private IgfsListingEntry entry;
- /** Update operation: remove entry from listing if {@code true} or add entry to listing if {@code false}. */
- private boolean rmv;
-
/**
* Constructs update directory listing closure.
*
* @param fileName File name to add into parent listing.
* @param entry Listing entry to add or remove.
- * @param rmv Remove entry from listing if {@code true} or add entry to listing if {@code false}.
*/
- private UpdateListing(String fileName, IgfsListingEntry entry, boolean rmv) {
+ private ListingAdd(String fileName, IgfsListingEntry entry) {
assert fileName != null;
assert entry != null;
this.fileName = fileName;
this.entry = entry;
- this.rmv = rmv;
}
/**
* Empty constructor required for {@link Externalizable}.
*
*/
- public UpdateListing() {
+ public ListingAdd() {
// No-op.
}
@@ -3261,30 +3329,15 @@ public class IgfsMetaManager extends IgfsManager {
assert fileInfo != null : "File info not found for the child: " + entry.fileId();
assert fileInfo.isDirectory();
- Map<String, IgfsListingEntry> listing =
- U.newHashMap(fileInfo.listing().size() + (rmv ? 0 : 1));
-
- listing.putAll(fileInfo.listing());
-
- if (rmv) {
- IgfsListingEntry oldEntry = listing.get(fileName);
+ Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
- if (oldEntry == null || !oldEntry.fileId().equals(entry.fileId()))
- throw new IgniteException("Directory listing doesn't contain expected file" +
- " [listing=" + listing + ", fileName=" + fileName + ", entry=" + entry + ']');
+ // Modify listing in-place.
+ IgfsListingEntry oldEntry = listing.put(fileName, entry);
- // Modify listing in-place.
- listing.remove(fileName);
- }
- else {
- // Modify listing in-place.
- IgfsListingEntry oldEntry = listing.put(fileName, entry);
-
- if (oldEntry != null && !oldEntry.fileId().equals(entry.fileId()))
- throw new IgniteException("Directory listing contains unexpected file" +
- " [listing=" + listing + ", fileName=" + fileName + ", entry=" + entry +
- ", oldEntry=" + oldEntry + ']');
- }
+ if (oldEntry != null && !oldEntry.fileId().equals(entry.fileId()))
+ throw new IgniteException("Directory listing contains unexpected file" +
+ " [listing=" + listing + ", fileName=" + fileName + ", entry=" + entry +
+ ", oldEntry=" + oldEntry + ']');
e.setValue(new IgfsFileInfo(listing, fileInfo));
@@ -3295,19 +3348,17 @@ public class IgfsMetaManager extends IgfsManager {
@Override public void writeExternal(ObjectOutput out) throws IOException {
U.writeString(out, fileName);
out.writeObject(entry);
- out.writeBoolean(rmv);
}
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
fileName = U.readString(in);
entry = (IgfsListingEntry)in.readObject();
- rmv = in.readBoolean();
}
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(UpdateListing.class, this);
+ return S.toString(ListingAdd.class, this);
}
}
@@ -3482,11 +3533,11 @@ public class IgfsMetaManager extends IgfsManager {
assert deletedEntry != null;
- id2InfoPrj.invoke(parentId, new UpdateListing(name, deletedEntry, true));
+ id2InfoPrj.invoke(parentId, new ListingRemove(name, deletedEntry.fileId()));
// Add listing entry into the destination parent listing.
- id2InfoPrj.invoke(TRASH_ID, new UpdateListing(
- lowermostExistingInfo.id().toString(), deletedEntry, false));
+ id2InfoPrj.invoke(TRASH_ID, new ListingAdd(
+ lowermostExistingInfo.id().toString(), deletedEntry));
// Update a file info of the removed file with a file path,
// which will be used by delete worker for event notifications.
@@ -3505,7 +3556,7 @@ public class IgfsMetaManager extends IgfsManager {
assert put;
id2InfoPrj.invoke(parentId,
- new UpdateListing(name, new IgfsListingEntry(newFileInfo), false));
+ new ListingAdd(name, new IgfsListingEntry(newFileInfo)));
IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(newFileInfo, parentId);
@@ -3679,8 +3730,7 @@ public class IgfsMetaManager extends IgfsManager {
throws IgniteCheckedException {
assert childInfo != null;
- id2InfoPrj.invoke(lowermostExistingId,
- new UpdateListing(childName, new IgfsListingEntry(childInfo), false));
+ id2InfoPrj.invoke(lowermostExistingId, new ListingAdd(childName, new IgfsListingEntry(childInfo)));
}
/**
[08/50] [abbrv] ignite git commit: IGNITE-2810: IGFS: Striped trash
directory to reduce contention during removals.
Posted by sb...@apache.org.
IGNITE-2810: IGFS: Striped trash directory to reduce contention during removals.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/37c4d508
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/37c4d508
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/37c4d508
Branch: refs/heads/ignite-1837
Commit: 37c4d508c9e40dcba274ae1625d7bf59bfeef144
Parents: ff5b68c
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Mar 14 11:49:03 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:12:54 2016 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsDeleteWorker.java | 28 ++--
.../internal/processors/igfs/IgfsFileInfo.java | 9 +-
.../internal/processors/igfs/IgfsImpl.java | 5 +-
.../processors/igfs/IgfsMetaManager.java | 146 ++++++++++---------
.../processors/igfs/IgfsOutputStreamImpl.java | 2 +-
.../internal/processors/igfs/IgfsUtils.java | 72 +++++++++
.../processors/igfs/IgfsAbstractSelfTest.java | 21 ++-
.../igfs/IgfsDataManagerSelfTest.java | 6 +-
.../igfs/IgfsMetaManagerSelfTest.java | 2 +-
.../processors/igfs/IgfsProcessorSelfTest.java | 9 +-
.../processors/igfs/IgfsSizeSelfTest.java | 13 +-
11 files changed, 199 insertions(+), 114 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/37c4d508/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
index 95a6a5d..ffddd3e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
@@ -39,7 +39,6 @@ import org.apache.ignite.lang.IgniteUuid;
import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_PURGED;
import static org.apache.ignite.internal.GridTopic.TOPIC_IGFS;
-import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.TRASH_ID;
/**
* IGFS worker for removal from the trash directory.
@@ -150,13 +149,23 @@ public class IgfsDeleteWorker extends IgfsThread {
}
/**
- * Perform cleanup of the trash directory.
+ * Perform cleanup of trash directories.
*/
private void delete() {
+ for (int i = 0; i < IgfsUtils.TRASH_CONCURRENCY; i++)
+ delete(IgfsUtils.trashId(i));
+ }
+
+ /**
+ * Perform cleanup of concrete trash directory.
+ *
+ * @param trashId Trash ID.
+ */
+ private void delete(IgniteUuid trashId) {
IgfsFileInfo info = null;
try {
- info = meta.info(TRASH_ID);
+ info = meta.info(trashId);
}
catch(ClusterTopologyServerNotFoundException e) {
LT.warn(log, e, "Server nodes not found.");
@@ -174,7 +183,7 @@ public class IgfsDeleteWorker extends IgfsThread {
try {
if (!cancelled) {
- if (delete(entry.getKey(), fileId)) {
+ if (delete(trashId, entry.getKey(), fileId)) {
if (log.isDebugEnabled())
log.debug("Sending delete confirmation message [name=" + entry.getKey() +
", fileId=" + fileId + ']');
@@ -200,12 +209,13 @@ public class IgfsDeleteWorker extends IgfsThread {
/**
* Remove particular entry from the TRASH directory.
*
+ * @param trashId ID of the trash directory.
* @param name Entry name.
* @param id Entry ID.
* @return {@code True} in case the entry really was deleted form the file system by this call.
* @throws IgniteCheckedException If failed.
*/
- private boolean delete(String name, IgniteUuid id) throws IgniteCheckedException {
+ private boolean delete(IgniteUuid trashId, String name, IgniteUuid id) throws IgniteCheckedException {
assert name != null;
assert id != null;
@@ -214,10 +224,10 @@ public class IgfsDeleteWorker extends IgfsThread {
if (info != null) {
if (info.isDirectory()) {
- if (!deleteDirectoryContents(TRASH_ID, id))
+ if (!deleteDirectoryContents(trashId, id))
return false;
- if (meta.delete(TRASH_ID, name, id))
+ if (meta.delete(trashId, name, id))
return true;
}
else {
@@ -235,7 +245,7 @@ public class IgfsDeleteWorker extends IgfsThread {
// In case this node crashes, other node will re-delete the file.
data.delete(lockedInfo).get();
- boolean ret = meta.delete(TRASH_ID, name, id);
+ boolean ret = meta.delete(trashId, name, id);
if (info.path() != null)
IgfsUtils.sendEvents(igfsCtx.kernalContext(), info.path(), EVT_IGFS_FILE_PURGED);
@@ -299,7 +309,7 @@ public class IgfsDeleteWorker extends IgfsThread {
// File is already locked:
failedFiles++;
else {
- assert IgfsMetaManager.DELETE_LOCK_ID.equals(lockedInfo.lockId());
+ assert IgfsUtils.DELETE_LOCK_ID.equals(lockedInfo.lockId());
fut.add(data.delete(lockedInfo));
http://git-wip-us.apache.org/repos/asf/ignite/blob/37c4d508/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
index a69920b..0a85657 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
@@ -23,7 +23,6 @@ import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Collections;
import java.util.Map;
-import java.util.UUID;
import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.util.GridLeanMap;
@@ -41,12 +40,6 @@ public final class IgfsFileInfo implements Externalizable {
/** */
private static final long serialVersionUID = 0L;
- /** ID for the root directory. */
- public static final IgniteUuid ROOT_ID = new IgniteUuid(new UUID(0, 0), 0);
-
- /** ID of the trash directory. */
- public static final IgniteUuid TRASH_ID = new IgniteUuid(new UUID(0, 1), 0);
-
/** Special access time value, indicating that the modification time value should be taken. */
private static final long ACCESS_TIME_TAKE_MODIFICATION_TIME = -1L;
@@ -94,7 +87,7 @@ public final class IgfsFileInfo implements Externalizable {
* {@link Externalizable} support.
*/
public IgfsFileInfo() {
- this(ROOT_ID);
+ this(IgfsUtils.ROOT_ID);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/37c4d508/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 c1e47a8..0e52927 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
@@ -111,7 +111,6 @@ import static org.apache.ignite.igfs.IgfsMode.PRIMARY;
import static org.apache.ignite.igfs.IgfsMode.PROXY;
import static org.apache.ignite.internal.GridTopic.TOPIC_IGFS;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGFS;
-import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.ROOT_ID;
/**
* Cache-based IGFS implementation.
@@ -1206,7 +1205,7 @@ public final class IgfsImpl implements IgfsEx {
@Override public IgfsMetrics call() throws Exception {
IgfsPathSummary sum = new IgfsPathSummary();
- summary0(ROOT_ID, sum);
+ summary0(IgfsUtils.ROOT_ID, sum);
long secondarySpaceSize = 0;
@@ -1279,7 +1278,7 @@ public final class IgfsImpl implements IgfsEx {
if (info != null) {
if (info.isDirectory()) {
- if (!ROOT_ID.equals(info.id()))
+ if (!IgfsUtils.ROOT_ID.equals(info.id()))
sum.directoriesCount(sum.directoriesCount() + 1);
for (IgfsListingEntry entry : info.listing().values())
http://git-wip-us.apache.org/repos/asf/ignite/blob/37c4d508/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index c120b9d..89ddd02 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -37,7 +37,6 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
-import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
@@ -91,8 +90,6 @@ import static org.apache.ignite.events.EventType.EVT_IGFS_DIR_RENAMED;
import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_CREATED;
import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_RENAMED;
import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_OPENED_WRITE;
-import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.ROOT_ID;
-import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.TRASH_ID;
import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.builder;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
@@ -102,9 +99,6 @@ import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_REA
*/
@SuppressWarnings("all")
public class IgfsMetaManager extends IgfsManager {
- /** Lock Id used to lock files being deleted from TRASH. This is a global constant. */
- static final IgniteUuid DELETE_LOCK_ID = new IgniteUuid(new UUID(0L, 0L), 0L);
-
/** Comparator for Id sorting. */
private static final Comparator<IgniteUuid> PATH_ID_SORTING_COMPARATOR
= new Comparator<IgniteUuid>() {
@@ -359,9 +353,9 @@ public class IgfsMetaManager extends IgfsManager {
// Collection of file IDs for components of specified path.
List<IgniteUuid> ids = new ArrayList<>(components.size() + 1);
- ids.add(ROOT_ID); // Always add root ID.
+ ids.add(IgfsUtils.ROOT_ID); // Always add root ID.
- IgniteUuid fileId = ROOT_ID;
+ IgniteUuid fileId = IgfsUtils.ROOT_ID;
for (String s : components) {
assert !s.isEmpty();
@@ -416,8 +410,8 @@ public class IgfsMetaManager extends IgfsManager {
IgfsFileInfo info = id2InfoPrj.get(fileId);
// Force root ID always exist in cache.
- if (info == null && ROOT_ID.equals(fileId))
- id2InfoPrj.putIfAbsent(ROOT_ID, info = new IgfsFileInfo());
+ if (info == null && IgfsUtils.ROOT_ID.equals(fileId))
+ id2InfoPrj.putIfAbsent(IgfsUtils.ROOT_ID, info = new IgfsFileInfo());
return info;
}
@@ -448,14 +442,14 @@ public class IgfsMetaManager extends IgfsManager {
Map<IgniteUuid, IgfsFileInfo> map = id2InfoPrj.getAll(fileIds);
// Force root ID always exist in cache.
- if (fileIds.contains(ROOT_ID) && !map.containsKey(ROOT_ID)) {
+ if (fileIds.contains(IgfsUtils.ROOT_ID) && !map.containsKey(IgfsUtils.ROOT_ID)) {
IgfsFileInfo info = new IgfsFileInfo();
- id2InfoPrj.putIfAbsent(ROOT_ID, info);
+ id2InfoPrj.putIfAbsent(IgfsUtils.ROOT_ID, info);
map = new GridLeanMap<>(map);
- map.put(ROOT_ID, info);
+ map.put(IgfsUtils.ROOT_ID, info);
}
return map;
@@ -545,7 +539,7 @@ public class IgfsMetaManager extends IgfsManager {
*/
private IgniteUuid composeLockId(boolean isDeleteLock) {
if (isDeleteLock)
- return DELETE_LOCK_ID;
+ return IgfsUtils.DELETE_LOCK_ID;
return IgniteUuid.fromUuid(locNode.id());
}
@@ -675,36 +669,38 @@ public class IgfsMetaManager extends IgfsManager {
if (log.isDebugEnabled())
log.debug("Locked file ids: " + fileIds);
- // Force root & trash IDs always exist in cache.
- addInfoIfNeeded(fileIds, map, ROOT_ID);
- addInfoIfNeeded(fileIds, map, TRASH_ID);
+ for (IgniteUuid fileId : fileIds) {
+ if (IgfsUtils.isRootOrTrashId(fileId)) {
+ if (!map.containsKey(fileId))
+ map.put(fileId, createSystemEntryIfAbsent(fileId));
+ }
+ }
// Returns detail's map for locked IDs.
return map;
}
/**
- * Adds FileInfo into the cache if it is requested in fileIds and is not present in the map.
+ * create system entry if it is absent.
*
- * @param fileIds A list that may contain the id.
- * @param map The map that may not contain the id.
- * @param id The id to check.
+ * @param id System entry ID.
+ * @return Value of created or existing system entry.
* @throws IgniteCheckedException On error.
*/
- private void addInfoIfNeeded(Collection<IgniteUuid> fileIds, Map<IgniteUuid, IgfsFileInfo> map, IgniteUuid id)
+ private IgfsFileInfo createSystemEntryIfAbsent(IgniteUuid id)
throws IgniteCheckedException {
assert validTxState(true);
- if (fileIds.contains(id) && !map.containsKey(id)) {
- IgfsFileInfo info = new IgfsFileInfo(id);
+ assert IgfsUtils.isRootOrTrashId(id);
- IgfsFileInfo anotherInfo = id2InfoPrj.getAndPutIfAbsent(id, info);
+ IgfsFileInfo info = new IgfsFileInfo(id);
- if (anotherInfo != null)
- info = anotherInfo;
+ IgfsFileInfo oldInfo = id2InfoPrj.getAndPutIfAbsent(id, info);
- map.put(id, info);
- }
+ if (oldInfo != null)
+ info = oldInfo;
+
+ return info;
}
/**
@@ -737,7 +733,7 @@ public class IgfsMetaManager extends IgfsManager {
public IgfsFileInfo fileForFragmentizer(Collection<IgniteUuid> exclude) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
- return fileForFragmentizer0(ROOT_ID, exclude);
+ return fileForFragmentizer0(IgfsUtils.ROOT_ID, exclude);
}
finally {
busyLock.leaveBusy();
@@ -1112,11 +1108,13 @@ public class IgfsMetaManager extends IgfsManager {
try {
assert validTxState(false);
+ IgniteUuid trashId = IgfsUtils.randomTrashId();
+
final IgniteInternalTx tx = startTx();
try {
// NB: We may lock root because its id is less than any other id:
- final IgfsFileInfo rootInfo = lockIds(ROOT_ID, TRASH_ID).get(ROOT_ID);
+ final IgfsFileInfo rootInfo = lockIds(IgfsUtils.ROOT_ID, trashId).get(IgfsUtils.ROOT_ID);
assert rootInfo != null;
@@ -1135,12 +1133,12 @@ public class IgfsMetaManager extends IgfsManager {
id2InfoPrj.put(newInfo.id(), newInfo);
// Add new info to trash listing.
- id2InfoPrj.invoke(TRASH_ID, new ListingAdd(newInfo.id().toString(),
+ id2InfoPrj.invoke(trashId, new ListingAdd(newInfo.id().toString(),
new IgfsListingEntry(newInfo)));
// Remove listing entries from root.
// Note that root directory properties and other attributes are preserved:
- id2InfoPrj.put(ROOT_ID, new IgfsFileInfo(null/*listing*/, rootInfo));
+ id2InfoPrj.put(IgfsUtils.ROOT_ID, new IgfsFileInfo(null/*listing*/, rootInfo));
tx.commit();
@@ -1182,15 +1180,16 @@ public class IgfsMetaManager extends IgfsManager {
final IgniteUuid victimId = pathIdList.get(pathIdList.size() - 1);
- assert !TRASH_ID.equals(victimId) : "TRASH does not have path, it cannot ever be deletion victim.";
- assert !ROOT_ID.equals(victimId); // root deletion is prevented in earlier stages.
+ assert !IgfsUtils.isRootOrTrashId(victimId) : "Cannot delete root or trash directories.";
allIds.addAll(pathIdList);
if (allIds.remove(null))
return null; // A fragment of the path no longer exists.
- boolean added = allIds.add(TRASH_ID);
+ IgniteUuid trashId = IgfsUtils.randomTrashId();
+
+ boolean added = allIds.add(trashId);
assert added;
final IgniteInternalTx tx = startTx();
@@ -1209,7 +1208,7 @@ public class IgfsMetaManager extends IgfsManager {
throw new IgfsDirectoryNotEmptyException("Failed to remove directory (directory is not " +
"empty and recursive flag is not set).");
- IgfsFileInfo destInfo = infoMap.get(TRASH_ID);
+ IgfsFileInfo destInfo = infoMap.get(trashId);
assert destInfo != null;
@@ -1237,7 +1236,7 @@ public class IgfsMetaManager extends IgfsManager {
id2InfoPrj.invoke(srcParentId, new ListingRemove(srcFileName, srcEntry.fileId()));
// Add listing entry into the destination parent listing.
- id2InfoPrj.invoke(TRASH_ID, new ListingAdd(destFileName, srcEntry));
+ id2InfoPrj.invoke(trashId, new ListingAdd(destFileName, srcEntry));
if (victimInfo.isFile())
// Update a file info of the removed file with a file path,
@@ -1269,10 +1268,12 @@ public class IgfsMetaManager extends IgfsManager {
* @param parentId Parent ID.
* @param name Path name.
* @param id Path ID.
+ * @param trashId Trash ID.
* @return ID of an entry located directly under the trash directory.
* @throws IgniteCheckedException If failed.
*/
- @Nullable private IgniteUuid softDeleteNonTx(@Nullable IgniteUuid parentId, @Nullable String name, IgniteUuid id)
+ @Nullable private IgniteUuid softDeleteNonTx(@Nullable IgniteUuid parentId, @Nullable String name, IgniteUuid id,
+ IgniteUuid trashId)
throws IgniteCheckedException {
assert validTxState(true);
@@ -1280,16 +1281,15 @@ public class IgfsMetaManager extends IgfsManager {
if (parentId == null) {
// Handle special case when we deleting root directory.
- assert ROOT_ID.equals(id);
+ assert IgfsUtils.ROOT_ID.equals(id);
- IgfsFileInfo rootInfo = id2InfoPrj.get(ROOT_ID);
+ IgfsFileInfo rootInfo = id2InfoPrj.get(IgfsUtils.ROOT_ID);
if (rootInfo == null)
return null; // Root was never created.
// Ensure trash directory existence.
- if (id2InfoPrj.get(TRASH_ID) == null)
- id2InfoPrj.getAndPut(TRASH_ID, new IgfsFileInfo(TRASH_ID));
+ createSystemEntryIfAbsent(trashId);
Map<String, IgfsListingEntry> rootListing = rootInfo.listing();
@@ -1314,12 +1314,12 @@ public class IgfsMetaManager extends IgfsManager {
id2InfoPrj.getAndPut(newInfo.id(), newInfo);
// Add new info to trash listing.
- id2InfoPrj.invoke(TRASH_ID, new ListingAdd(newInfo.id().toString(),
+ id2InfoPrj.invoke(trashId, new ListingAdd(newInfo.id().toString(),
new IgfsListingEntry(newInfo)));
// Remove listing entries from root.
for (Map.Entry<String, IgfsListingEntry> entry : transferListing.entrySet())
- id2InfoPrj.invoke(ROOT_ID, new ListingRemove(entry.getKey(), entry.getValue().fileId()));
+ id2InfoPrj.invoke(IgfsUtils.ROOT_ID, new ListingRemove(entry.getKey(), entry.getValue().fileId()));
resId = newInfo.id();
}
@@ -1328,10 +1328,9 @@ public class IgfsMetaManager extends IgfsManager {
}
else {
// Ensure trash directory existence.
- if (id2InfoPrj.get(TRASH_ID) == null)
- id2InfoPrj.getAndPut(TRASH_ID, new IgfsFileInfo(TRASH_ID));
+ createSystemEntryIfAbsent(trashId);
- moveNonTx(id, name, parentId, id.toString(), TRASH_ID);
+ moveNonTx(id, name, parentId, id.toString(), trashId);
resId = id;
}
@@ -1390,7 +1389,7 @@ public class IgfsMetaManager extends IgfsManager {
if (entryInfo != null) {
// File must be locked for deletion:
- assert entryInfo.isDirectory() || DELETE_LOCK_ID.equals(entryInfo.lockId());
+ assert entryInfo.isDirectory() || IgfsUtils.DELETE_LOCK_ID.equals(entryInfo.lockId());
// Delete only files or empty folders.
if (entryInfo.isFile() || entryInfo.isDirectory() && entryInfo.listing().isEmpty()) {
@@ -1457,8 +1456,8 @@ public class IgfsMetaManager extends IgfsManager {
if (victim == null)
return res;
- assert victim.isDirectory() || DELETE_LOCK_ID.equals(victim.lockId()) :
- " isDir: " + victim.isDirectory() + ", lockId: " + victim.lockId();
+ assert victim.isDirectory() || IgfsUtils.DELETE_LOCK_ID.equals(victim.lockId()) :
+ " isDir: " + victim.isDirectory() + ", lockId: " + victim.lockId();
// Proceed only in case both parent and child exist.
if (infos.containsKey(parentId) && infos.containsKey(id)) {
@@ -1504,21 +1503,24 @@ public class IgfsMetaManager extends IgfsManager {
public Collection<IgniteUuid> pendingDeletes() throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
- IgfsFileInfo trashInfo = id2InfoPrj.get(TRASH_ID);
+ Collection<IgniteUuid> ids = new HashSet<>();
- if (trashInfo != null) {
- Map<String, IgfsListingEntry> listing = trashInfo.listing();
+ for (int i = 0; i < IgfsUtils.TRASH_CONCURRENCY; i++) {
+ IgniteUuid trashId = IgfsUtils.trashId(i);
- if (listing != null && !listing.isEmpty()) {
- return F.viewReadOnly(listing.values(), new IgniteClosure<IgfsListingEntry, IgniteUuid>() {
- @Override public IgniteUuid apply(IgfsListingEntry e) {
- return e.fileId();
- }
- });
+ IgfsFileInfo trashInfo = id2InfoPrj.get(trashId);
+
+ if (trashInfo != null) {
+ Map<String, IgfsListingEntry> listing = trashInfo.listing();
+
+ if (listing != null && !listing.isEmpty()) {
+ for (IgfsListingEntry entry : listing.values())
+ ids.add(entry.fileId());
+ }
}
}
- return Collections.emptySet();
+ return ids;
}
finally {
busyLock.leaveBusy();
@@ -2455,6 +2457,8 @@ public class IgfsMetaManager extends IgfsManager {
assert fs != null;
assert path != null;
+ final IgniteUuid trashId = IgfsUtils.randomTrashId();
+
SynchronizationTask<Boolean> task = new SynchronizationTask<Boolean>() {
@Override public Boolean onSuccess(Map<IgfsPath, IgfsFileInfo> infos) throws Exception {
IgfsFileInfo info = infos.get(path);
@@ -2468,12 +2472,12 @@ public class IgfsMetaManager extends IgfsManager {
if (path.parent() != null) {
assert infos.containsKey(path.parent());
- softDeleteNonTx(infos.get(path.parent()).id(), path.name(), info.id());
+ softDeleteNonTx(infos.get(path.parent()).id(), path.name(), info.id(), trashId);
}
else {
- assert ROOT_ID.equals(info.id());
+ assert IgfsUtils.ROOT_ID.equals(info.id());
- softDeleteNonTx(null, path.name(), info.id());
+ softDeleteNonTx(null, path.name(), info.id(), trashId);
}
// Update the deleted file info with path information for delete worker.
@@ -2491,7 +2495,7 @@ public class IgfsMetaManager extends IgfsManager {
}
};
- Boolean res = synchronizeAndExecute(task, fs, false, Collections.singleton(TRASH_ID), path);
+ Boolean res = synchronizeAndExecute(task, fs, false, Collections.singleton(trashId), path);
delWorker.signal();
@@ -3441,6 +3445,8 @@ public class IgfsMetaManager extends IgfsManager {
DirectoryChainBuilder b = null;
+ IgniteUuid trashId = IgfsUtils.randomTrashId();
+
while (true) {
if (busyLock.enterBusy()) {
try {
@@ -3461,11 +3467,11 @@ public class IgfsMetaManager extends IgfsManager {
if (overwrite)
// Lock also the TRASH directory because in case of overwrite we
// may need to delete the old file:
- b.idSet.add(TRASH_ID);
+ b.idSet.add(trashId);
final Map<IgniteUuid, IgfsFileInfo> lockedInfos = lockIds(b.idSet);
- assert !overwrite || lockedInfos.get(TRASH_ID) != null; // TRASH must exist at this point.
+ assert !overwrite || lockedInfos.get(trashId) != null; // TRASH must exist at this point.
// If the path was changed, we close the current Tx and repeat the procedure again
// starting from taking the path ids.
@@ -3536,8 +3542,8 @@ public class IgfsMetaManager extends IgfsManager {
id2InfoPrj.invoke(parentId, new ListingRemove(name, deletedEntry.fileId()));
// Add listing entry into the destination parent listing.
- id2InfoPrj.invoke(TRASH_ID, new ListingAdd(
- lowermostExistingInfo.id().toString(), deletedEntry));
+ id2InfoPrj.invoke(trashId,
+ new ListingAdd(lowermostExistingInfo.id().toString(), deletedEntry));
// Update a file info of the removed file with a file path,
// which will be used by delete worker for event notifications.
@@ -3697,7 +3703,7 @@ public class IgfsMetaManager extends IgfsManager {
idIdx++;
}
- assert idSet.contains(ROOT_ID);
+ assert idSet.contains(IgfsUtils.ROOT_ID);
this.lowermostExistingId = lowermostExistingId;
http://git-wip-us.apache.org/repos/asf/ignite/blob/37c4d508/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
index c9225ae..83056af 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
@@ -121,7 +121,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
if (fileInfo.lockId() == null)
throw new IgfsException("Failed to acquire file lock (concurrently modified?): " + path);
- assert !IgfsMetaManager.DELETE_LOCK_ID.equals(fileInfo.lockId());
+ assert !IgfsUtils.DELETE_LOCK_ID.equals(fileInfo.lockId());
this.igfsCtx = igfsCtx;
meta = igfsCtx.meta();
http://git-wip-us.apache.org/repos/asf/ignite/blob/37c4d508/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index 07fdda4..6f8960a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -18,6 +18,9 @@
package org.apache.ignite.internal.processors.igfs;
import java.lang.reflect.Constructor;
+import java.util.UUID;
+import java.util.concurrent.ThreadLocalRandom;
+
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteSystemProperties;
@@ -36,6 +39,7 @@ import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.transactions.Transaction;
import org.jetbrains.annotations.Nullable;
@@ -47,10 +51,78 @@ import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_REA
* Common IGFS utility methods.
*/
public class IgfsUtils {
+ /** ID for the root directory. */
+ public static final IgniteUuid ROOT_ID = new IgniteUuid(new UUID(0, 0), 0);
+
+ /** Lock Id used to lock files being deleted from TRASH. This is a global constant. */
+ public static final IgniteUuid DELETE_LOCK_ID = new IgniteUuid(new UUID(0, 0), 0);
+
+ /** Constant trash concurrency level. */
+ public static final int TRASH_CONCURRENCY = 16;
+
+ /** Trash directory IDs. */
+ private static final IgniteUuid[] TRASH_IDS;
+
/** Maximum number of file unlock transaction retries when topology changes. */
private static final int MAX_CACHE_TX_RETRIES = IgniteSystemProperties.getInteger(IGNITE_CACHE_RETRIES_COUNT, 100);
/**
+ * Static initializer.
+ */
+ static {
+ TRASH_IDS = new IgniteUuid[TRASH_CONCURRENCY];
+
+ for (int i = 0; i < TRASH_CONCURRENCY; i++)
+ TRASH_IDS[i] = new IgniteUuid(new UUID(0, i + 1), 0);
+ }
+
+ /**
+ * Get random trash ID.
+ *
+ * @return Trash ID.
+ */
+ public static IgniteUuid randomTrashId() {
+ return TRASH_IDS[ThreadLocalRandom.current().nextInt(TRASH_CONCURRENCY)];
+ }
+
+ /**
+ * Get trash ID for the given index.
+ *
+ * @param idx Index.
+ * @return Trahs ID.
+ */
+ public static IgniteUuid trashId(int idx) {
+ assert idx >= 0 && idx < TRASH_CONCURRENCY;
+
+ return TRASH_IDS[idx];
+ }
+
+ /**
+ * Check whether provided ID is trash ID.
+ *
+ * @param id ID.
+ * @return {@code True} if this is trash ID.
+ */
+ public static boolean isTrashId(IgniteUuid id) {
+ assert id != null;
+
+ UUID gid = id.globalId();
+
+ return id.localId() == 0 && gid.getMostSignificantBits() == 0 &&
+ gid.getLeastSignificantBits() > 0 && gid.getLeastSignificantBits() <= TRASH_CONCURRENCY;
+ }
+
+ /**
+ * Check whether provided ID is either root ID or trash ID.
+ *
+ * @param id ID.
+ * @return {@code True} if this is root ID or trash ID.
+ */
+ public static boolean isRootOrTrashId(IgniteUuid id) {
+ return ROOT_ID.equals(id) || isTrashId(id);
+ }
+
+ /**
* Converts any passed exception to IGFS exception.
*
* @param err Initial exception.
http://git-wip-us.apache.org/repos/asf/ignite/blob/37c4d508/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
index 015b992..52d8bd5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
@@ -3138,14 +3138,22 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
igfs.format();
int prevDifferentSize = Integer.MAX_VALUE; // Previous different size.
- int size;
int constCnt = 0, totalCnt = 0;
final int constThreshold = 20;
final long sleepPeriod = 500L;
final long totalThreshold = CACHE_EMPTY_TIMEOUT / sleepPeriod;
while (true) {
- size = sumCacheSize(igfs);
+ int metaSize = 0;
+
+ for (IgniteUuid metaId : getMetaCache(igfs).keySet()) {
+ if (!IgfsUtils.isRootOrTrashId(metaId))
+ metaSize++;
+ }
+
+ int dataSize = getDataCache(igfs).size();
+
+ int size = metaSize + dataSize;
if (size <= 2)
return; // Caches are cleared, we're done. (2 because ROOT & TRASH always exist).
@@ -3206,15 +3214,6 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
}
/**
- * Gets summary IGFS cache size.
- * @param igfs The IGFS to measure.
- * @return data cache size + meta cache size.
- */
- private static int sumCacheSize(IgniteFileSystem igfs) {
- return getMetaCache(igfs).size() + getDataCache(igfs).size();
- }
-
- /**
* Clear particular {@link UniversalFileSystemAdapter}.
*
* @param uni IGFS.
http://git-wip-us.apache.org/repos/asf/ignite/blob/37c4d508/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
index 8d5ae7a..06ae40b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
@@ -168,7 +168,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
- IgfsFileInfo info = new IgfsFileInfo(200, 0L, null, IgfsMetaManager.DELETE_LOCK_ID,
+ IgfsFileInfo info = new IgfsFileInfo(200, 0L, null, IgfsUtils.DELETE_LOCK_ID,
false, null, t, t);
assertNull(mgr.dataBlock(info, path, 0, null).get());
@@ -253,7 +253,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 0L, null, IgfsMetaManager.DELETE_LOCK_ID,
+ IgfsFileInfo info = new IgfsFileInfo(blockSize, 0L, null, IgfsUtils.DELETE_LOCK_ID,
false, null, t, t);
assertNull(mgr.dataBlock(info, path, 0, null).get());
@@ -345,7 +345,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
IgfsFileInfo info =
- new IgfsFileInfo(blockSize, 0L, null, IgfsMetaManager.DELETE_LOCK_ID,
+ new IgfsFileInfo(blockSize, 0L, null, IgfsUtils.DELETE_LOCK_ID,
false, null, t, t);
IgfsFileAffinityRange range = new IgfsFileAffinityRange();
http://git-wip-us.apache.org/repos/asf/ignite/blob/37c4d508/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
index df519ed..f3d35f4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
@@ -42,7 +42,7 @@ import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.ROOT_ID;
+import static org.apache.ignite.internal.processors.igfs.IgfsUtils.ROOT_ID;
import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
import static org.apache.ignite.testframework.GridTestUtils.assertThrowsInherited;
http://git-wip-us.apache.org/repos/asf/ignite/blob/37c4d508/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
index c6853ae..f567099 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
@@ -778,7 +778,14 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
assert !igfs.exists(path(dirPath));
assert !igfs.exists(path(filePath));
- assert grid(0).cachex(igfs.configuration().getMetaCacheName()).size() == 2; // ROOT + TRASH.
+ int metaSize = 0;
+
+ for (Object metaId : grid(0).cachex(igfs.configuration().getMetaCacheName()).keySet()) {
+ if (!IgfsUtils.isRootOrTrashId((IgniteUuid)metaId))
+ metaSize++;
+ }
+
+ assert metaSize == 0;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/37c4d508/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
index 9c90534..fcf4b3b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
@@ -59,8 +59,6 @@ import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
-import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.ROOT_ID;
-import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.TRASH_ID;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
@@ -538,26 +536,27 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
}).start();
// Now add file ID to trash listing so that delete worker could "see" it.
+ IgniteUuid trashId = IgfsUtils.randomTrashId();
try (Transaction tx = metaCache.unwrap(Ignite.class).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
Map<String, IgfsListingEntry> listing = Collections.singletonMap(path.name(),
new IgfsListingEntry(info));
// Clear root listing.
- metaCache.put(ROOT_ID, new IgfsFileInfo(ROOT_ID));
+ metaCache.put(IgfsUtils.ROOT_ID, new IgfsFileInfo(IgfsUtils.ROOT_ID));
// Add file to trash listing.
- IgfsFileInfo trashInfo = metaCache.get(TRASH_ID);
+ IgfsFileInfo trashInfo = metaCache.get(trashId);
if (trashInfo == null)
- metaCache.put(TRASH_ID, new IgfsFileInfo(listing, new IgfsFileInfo(TRASH_ID)));
+ metaCache.put(trashId, new IgfsFileInfo(listing, new IgfsFileInfo(trashId)));
else
- metaCache.put(TRASH_ID, new IgfsFileInfo(listing, trashInfo));
+ metaCache.put(trashId, new IgfsFileInfo(listing, trashInfo));
tx.commit();
}
- assert metaCache.get(TRASH_ID) != null;
+ assert metaCache.get(trashId) != null;
// Now the file is locked and is located in trash, try adding some more data.
os = igfs.create(otherPath, false);
[12/50] [abbrv] ignite git commit: IGNITE-2838: IGFS: Opimized format
of IgfsListingEntry. Now it contains only file ID and boolean flag endicating
whether this a directory or file.
Posted by sb...@apache.org.
IGNITE-2838: IGFS: Opimized format of IgfsListingEntry. Now it contains only file ID and boolean flag endicating whether this a directory or file.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ba30ddbc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ba30ddbc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ba30ddbc
Branch: refs/heads/ignite-1837
Commit: ba30ddbc599d67f398ffba1263d174f5b58b4b7d
Parents: a7c1f44
Author: thatcoach <pp...@list.ru>
Authored: Tue Mar 15 20:46:13 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:14 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsFileImpl.java | 29 ---
.../internal/processors/igfs/IgfsFileInfo.java | 38 +++-
.../internal/processors/igfs/IgfsImpl.java | 8 +-
.../processors/igfs/IgfsListingEntry.java | 129 ++---------
.../processors/igfs/IgfsMetaManager.java | 221 +++----------------
.../processors/igfs/IgfsOutputStreamImpl.java | 2 -
6 files changed, 88 insertions(+), 339 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ba30ddbc/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
index 4a96e81..3576a06 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
@@ -124,35 +124,6 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable {
modificationTime = info.modificationTime();
}
- /**
- * Constructs file instance.
- *
- * @param path Path.
- * @param entry Listing entry.
- */
- public IgfsFileImpl(IgfsPath path, IgfsListingEntry entry, long globalGrpSize) {
- A.notNull(path, "path");
- A.notNull(entry, "entry");
-
- this.path = path;
- fileId = entry.fileId();
-
- blockSize = entry.blockSize();
-
- // By contract file must have blockSize > 0, while directory's blockSize == 0:
- assert entry.isFile() == (blockSize > 0);
- assert entry.isDirectory() == (blockSize == 0);
-
- grpBlockSize = entry.affinityKey() == null ? globalGrpSize :
- entry.length() == 0 ? globalGrpSize : entry.length();
-
- len = entry.length();
- props = entry.properties();
-
- accessTime = entry.accessTime();
- modificationTime = entry.modificationTime();
- }
-
/** {@inheritDoc} */
@Override public IgfsPath path() {
return path;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ba30ddbc/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
index 0a85657..ba484bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
@@ -297,9 +297,6 @@ public final class IgfsFileInfo implements Externalizable {
this.props = props == null || props.isEmpty() ? null :
cpProps ? new GridLeanMap<>(props) : props;
- if (listing == null && isDir)
- this.listing = Collections.emptyMap();
-
this.lockId = lockId;
this.evictExclude = evictExclude;
}
@@ -410,13 +407,38 @@ public final class IgfsFileInfo implements Externalizable {
* @return Directory listing.
*/
public Map<String, IgfsListingEntry> listing() {
- // Always wrap into unmodifiable map to be able to avoid illegal modifications in order pieces of the code.
- if (isFile())
- return Collections.unmodifiableMap(Collections.<String, IgfsListingEntry>emptyMap());
+ return listing != null ? listing : Collections.<String, IgfsListingEntry>emptyMap();
+ }
+
+ /**
+ * @return {@code True} if at least one child exists.
+ */
+ public boolean hasChildren() {
+ return !F.isEmpty(listing);
+ }
+
+ /**
+ * @param name Child name.
+ * @return {@code True} if child with such name exists.
+ */
+ public boolean hasChild(String name) {
+ return listing != null && listing.containsKey(name);
+ }
- assert listing != null;
+ /**
+ * @param name Child name.
+ * @param expId Expected child ID.
+ * @return {@code True} if child with such name exists.
+ */
+ public boolean hasChild(String name, IgniteUuid expId) {
+ if (listing != null) {
+ IgfsListingEntry entry = listing.get(name);
+
+ if (entry != null)
+ return F.eq(expId, entry.fileId());
+ }
- return Collections.unmodifiableMap(listing);
+ return false;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/ba30ddbc/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 0e52927..f44eda8 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
@@ -870,9 +870,13 @@ public final class IgfsImpl implements IgfsEx {
// Perform the listing.
for (Map.Entry<String, IgfsListingEntry> e : info.listing().entrySet()) {
- IgfsPath p = new IgfsPath(path, e.getKey());
+ IgfsFileInfo childInfo = meta.info(e.getValue().fileId());
- files.add(new IgfsFileImpl(p, e.getValue(), data.groupBlockSize()));
+ if (childInfo != null) {
+ IgfsPath childPath = new IgfsPath(path, e.getKey());
+
+ files.add(new IgfsFileImpl(childPath, childInfo, data.groupBlockSize()));
+ }
}
}
} else if (mode == PRIMARY) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/ba30ddbc/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
index 1cdc8a9..61d9265 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
@@ -21,7 +21,8 @@ import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.util.Map;
+
+import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -34,25 +35,10 @@ public class IgfsListingEntry implements Externalizable {
private static final long serialVersionUID = 0L;
/** File id. */
- private IgniteUuid fileId;
-
- /** File affinity key. */
- private IgniteUuid affKey;
-
- /** Positive block size if file, 0 if directory. */
- private int blockSize;
-
- /** File length. */
- private long len;
-
- /** Last access time. */
- private long accessTime;
+ private IgniteUuid id;
- /** Last modification time. */
- private long modificationTime;
-
- /** File properties. */
- private Map<String, String> props;
+ /** Directory marker. */
+ private boolean dir;
/**
* Empty constructor required by {@link Externalizable}.
@@ -65,132 +51,51 @@ public class IgfsListingEntry implements Externalizable {
* @param fileInfo File info to construct listing entry from.
*/
public IgfsListingEntry(IgfsFileInfo fileInfo) {
- fileId = fileInfo.id();
- affKey = fileInfo.affinityKey();
-
- if (fileInfo.isFile()) {
- blockSize = fileInfo.blockSize();
- len = fileInfo.length();
- }
-
- props = fileInfo.properties();
- accessTime = fileInfo.accessTime();
- modificationTime = fileInfo.modificationTime();
- }
-
- /**
- * Creates listing entry with updated length.
- *
- * @param entry Entry.
- * @param len New length.
- */
- public IgfsListingEntry(IgfsListingEntry entry, long len, long accessTime, long modificationTime) {
- fileId = entry.fileId;
- affKey = entry.affKey;
- blockSize = entry.blockSize;
- props = entry.props;
- this.accessTime = accessTime;
- this.modificationTime = modificationTime;
-
- this.len = len;
+ id = fileInfo.id();
+ dir = fileInfo.isDirectory();
}
/**
* @return Entry file ID.
*/
public IgniteUuid fileId() {
- return fileId;
- }
-
- /**
- * @return File affinity key, if specified.
- */
- public IgniteUuid affinityKey() {
- return affKey;
+ return id;
}
/**
* @return {@code True} if entry represents file.
*/
public boolean isFile() {
- return blockSize > 0;
+ return !dir;
}
/**
* @return {@code True} if entry represents directory.
*/
public boolean isDirectory() {
- return blockSize == 0;
- }
-
- /**
- * @return Block size.
- */
- public int blockSize() {
- return blockSize;
- }
-
- /**
- * @return Length.
- */
- public long length() {
- return len;
- }
-
- /**
- * @return Last access time.
- */
- public long accessTime() {
- return accessTime;
- }
-
- /**
- * @return Last modification time.
- */
- public long modificationTime() {
- return modificationTime;
- }
-
- /**
- * @return Properties map.
- */
- public Map<String, String> properties() {
- return props;
+ return dir;
}
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeGridUuid(out, fileId);
- out.writeInt(blockSize);
- out.writeLong(len);
- U.writeStringMap(out, props);
- out.writeLong(accessTime);
- out.writeLong(modificationTime);
+ U.writeGridUuid(out, id);
+ out.writeBoolean(dir);
}
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- fileId = U.readGridUuid(in);
- blockSize = in.readInt();
- len = in.readLong();
- props = U.readStringMap(in);
- accessTime = in.readLong();
- modificationTime = in.readLong();
+ id = U.readGridUuid(in);
+ dir = in.readBoolean();
}
/** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof IgfsListingEntry)) return false;
-
- IgfsListingEntry that = (IgfsListingEntry)o;
-
- return fileId.equals(that.fileId);
+ @Override public boolean equals(Object other) {
+ return this == other || other instanceof IgfsListingEntry && F.eq(id, ((IgfsListingEntry)other).id);
}
/** {@inheritDoc} */
@Override public int hashCode() {
- return fileId.hashCode();
+ return id.hashCode();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/ba30ddbc/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index d3aae58..463e7a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -801,18 +801,12 @@ public class IgfsMetaManager extends IgfsManager {
if (!parentInfo.isDirectory())
throw fsException(new IgfsPathIsNotDirectoryException("Parent file is not a directory: " + parentInfo));
- Map<String, IgfsListingEntry> parentListing = parentInfo.listing();
+ IgfsListingEntry childEntry = parentInfo.listing().get(fileName);
- assert parentListing != null;
+ if (childEntry != null)
+ return childEntry.fileId();
- IgfsListingEntry entry = parentListing.get(fileName);
-
- if (entry != null)
- return entry.fileId();
-
- IgniteUuid fileId = newFileInfo.id();
-
- if (!id2InfoPrj.putIfAbsent(fileId, newFileInfo))
+ if (!id2InfoPrj.putIfAbsent(newFileInfo.id(), newFileInfo))
throw fsException("Failed to add file details into cache: " + newFileInfo);
id2InfoPrj.invoke(parentId, new ListingAdd(fileName, new IgfsListingEntry(newFileInfo)));
@@ -915,7 +909,7 @@ public class IgfsMetaManager extends IgfsManager {
assert dstTargetInfo.isDirectory();
// 7. Last check: does destination target already have listing entry with the same name?
- if (dstTargetInfo.listing().containsKey(dstName)) {
+ if (dstTargetInfo.hasChild(dstName)) {
throw new IgfsPathAlreadyExistsException("Failed to perform move because destination already " +
"contains entry with the same name existing file [src=" + srcPath +
", dst=" + dstPath + ']');
@@ -973,14 +967,8 @@ public class IgfsMetaManager extends IgfsManager {
// If parent info is null, it doesn't exist.
if (parentInfo != null) {
- IgfsListingEntry childEntry = parentInfo.listing().get(pathParts.get(i));
-
- // If expected child exists.
- if (childEntry != null) {
- // If child ID matches expected ID.
- if (F.eq(childEntry.fileId(), expIds.get(i + 1)))
- continue;
- }
+ if (parentInfo.hasChild(pathParts.get(i), expIds.get(i + 1)))
+ continue;
}
}
@@ -1046,7 +1034,6 @@ public class IgfsMetaManager extends IgfsManager {
fileId + ']'));
IgfsListingEntry srcEntry = srcInfo.listing().get(srcFileName);
- IgfsListingEntry destEntry = destInfo.listing().get(destFileName);
// If source file does not exist or was re-created.
if (srcEntry == null || !srcEntry.fileId().equals(fileId))
@@ -1055,10 +1042,10 @@ public class IgfsMetaManager extends IgfsManager {
", srcParentId=" + srcParentId + ", srcEntry=" + srcEntry + ']'));
// If stored file already exist.
- if (destEntry != null)
+ if (destInfo.hasChild(destFileName))
throw fsException(new IgfsPathAlreadyExistsException("Failed to add file name into the destination " +
" directory (file already exists) [fileId=" + fileId + ", destFileName=" + destFileName +
- ", destParentId=" + destParentId + ", destEntry=" + destEntry + ']'));
+ ", destParentId=" + destParentId + ']'));
// Remove listing entry from the source parent listing.
id2InfoPrj.invoke(srcParentId, new ListingRemove(srcFileName, srcEntry.fileId()));
@@ -1174,7 +1161,7 @@ public class IgfsMetaManager extends IgfsManager {
final IgfsFileInfo victimInfo = infoMap.get(victimId);
- if (!recursive && victimInfo.isDirectory() && !victimInfo.listing().isEmpty())
+ if (!recursive && victimInfo.hasChildren())
// Throw exception if not empty and not recursive.
throw new IgfsDirectoryNotEmptyException("Failed to remove directory (directory is not " +
"empty and recursive flag is not set).");
@@ -1187,7 +1174,7 @@ public class IgfsMetaManager extends IgfsManager {
final String destFileName = victimId.toString();
- assert destInfo.listing().get(destFileName) == null : "Failed to add file name into the " +
+ assert !destInfo.hasChild(destFileName) : "Failed to add file name into the " +
"destination directory (file already exists) [destName=" + destFileName + ']';
IgfsFileInfo srcParentInfo = infoMap.get(pathIdList.get(pathIdList.size() - 2));
@@ -1338,8 +1325,8 @@ public class IgfsMetaManager extends IgfsManager {
int i = 1;
- for (IgfsListingEntry entry : listing.values())
- allIds[i++] = entry.fileId();
+ for (IgfsListingEntry childEntry : listing.values())
+ allIds[i++] = childEntry.fileId();
Map<IgniteUuid, IgfsFileInfo> locks = lockIds(allIds);
@@ -1347,35 +1334,37 @@ public class IgfsMetaManager extends IgfsManager {
// Ensure parent is still in place.
if (parentInfo != null) {
- Map<String, IgfsListingEntry> newListing =
- new HashMap<>(parentInfo.listing().size(), 1.0f);
+ Map<String, IgfsListingEntry> parentListing = parentInfo.listing();
+
+ Map<String, IgfsListingEntry> newListing = new HashMap<>(parentListing.size(), 1.0f);
- newListing.putAll(parentInfo.listing());
+ newListing.putAll(parentListing);
// Remove child entries if possible.
for (Map.Entry<String, IgfsListingEntry> entry : listing.entrySet()) {
- IgniteUuid entryId = entry.getValue().fileId();
+ String childName = entry.getKey();
+ IgniteUuid childId = entry.getValue().fileId();
- IgfsFileInfo entryInfo = locks.get(entryId);
+ IgfsFileInfo entryInfo = locks.get(childId);
if (entryInfo != null) {
// File must be locked for deletion:
assert entryInfo.isDirectory() || IgfsUtils.DELETE_LOCK_ID.equals(entryInfo.lockId());
// Delete only files or empty folders.
- if (entryInfo.isFile() || entryInfo.isDirectory() && entryInfo.listing().isEmpty()) {
- id2InfoPrj.getAndRemove(entryId);
+ if (!entryInfo.hasChildren()) {
+ id2InfoPrj.getAndRemove(childId);
- newListing.remove(entry.getKey());
+ newListing.remove(childName);
- res.add(entryId);
+ res.add(childId);
}
}
else {
// Entry was deleted concurrently.
- newListing.remove(entry.getKey());
+ newListing.remove(childName);
- res.add(entryId);
+ res.add(childId);
}
}
@@ -1436,10 +1425,10 @@ public class IgfsMetaManager extends IgfsManager {
assert parentInfo != null;
- IgfsListingEntry listingEntry = parentInfo.listing().get(name);
+ IgfsListingEntry childEntry = parentInfo.listing().get(name);
- if (listingEntry != null)
- id2InfoPrj.invoke(parentId, new ListingRemove(name, listingEntry.fileId()));
+ if (childEntry != null)
+ id2InfoPrj.invoke(parentId, new ListingRemove(name, childEntry.fileId()));
IgfsFileInfo deleted = id2InfoPrj.getAndRemove(id);
@@ -1481,13 +1470,9 @@ public class IgfsMetaManager extends IgfsManager {
IgfsFileInfo trashInfo = id2InfoPrj.get(trashId);
- if (trashInfo != null) {
- Map<String, IgfsListingEntry> listing = trashInfo.listing();
-
- if (listing != null && !listing.isEmpty()) {
- for (IgfsListingEntry entry : listing.values())
- ids.add(entry.fileId());
- }
+ if (trashInfo != null && trashInfo.hasChildren()) {
+ for (IgfsListingEntry entry : trashInfo.listing().values())
+ ids.add(entry.fileId());
}
}
@@ -1543,11 +1528,7 @@ public class IgfsMetaManager extends IgfsManager {
return null; // File not found.
if (parentInfo != null) {
- Map<String, IgfsListingEntry> listing = parentInfo.listing();
-
- IgfsListingEntry entry = listing.get(fileName);
-
- if (entry == null || !entry.fileId().equals(fileId)) // File was removed or recreated.
+ if (!parentInfo.hasChild(fileName, fileId)) // File was removed or recreated.
return null;
}
@@ -1622,35 +1603,6 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * Asynchronously updates record in parent listing.
- *
- * @param parentId Parent ID.
- * @param fileId File ID.
- * @param fileName File name.
- * @param lenDelta Length delta.
- * @param modificationTime Last modification time.
- */
- public void updateParentListingAsync(IgniteUuid parentId, IgniteUuid fileId, String fileName, long lenDelta,
- long modificationTime) {
- if (busyLock.enterBusy()) {
- try {
- assert parentId != null;
-
- assert validTxState(false);
-
- id2InfoPrj.invokeAsync(parentId, new UpdateListingEntry(fileId, fileName, lenDelta, -1,
- modificationTime));
- }
- finally {
- busyLock.leaveBusy();
- }
- }
- else
- throw new IllegalStateException("Failed to update parent listing because Grid is stopping [parentId=" +
- parentId + ", fileId=" + fileId + ", fileName=" + fileName + ']');
- }
-
- /**
* Reserve space for file.
*
* @param path File path.
@@ -2980,10 +2932,8 @@ public class IgfsMetaManager extends IgfsManager {
throw fsException(new IgfsPathNotFoundException("Failed to update times " +
"(parent was not found): " + fileName));
- IgfsListingEntry entry = parentInfo.listing().get(fileName);
-
// Validate listing.
- if (entry == null || !entry.fileId().equals(fileId))
+ if (!parentInfo.hasChild(fileName, fileId))
throw fsException(new IgfsConcurrentModificationException("Failed to update times " +
"(file concurrently modified): " + fileName));
@@ -2994,9 +2944,6 @@ public class IgfsMetaManager extends IgfsManager {
modificationTime == -1 ? fileInfo.modificationTime() : modificationTime)
);
- id2InfoPrj.invoke(parentId, new UpdateListingEntry(fileId, fileName, 0, accessTime,
- modificationTime));
-
tx.commit();
}
finally {
@@ -3143,100 +3090,6 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * Updates file length information in parent listing.
- */
- private static final class UpdateListingEntry implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** File name. */
- private String fileName;
-
- /** File id. */
- private IgniteUuid fileId;
-
- /** Length delta. */
- private long lenDelta;
-
- /** Last access time. */
- private long accessTime;
-
- /** Last modification time. */
- private long modificationTime;
-
- /**
- * Empty constructor required by {@link Externalizable}.
- */
- public UpdateListingEntry() {
- // No-op.
- }
-
- /**
- * @param fileId Expected file id in parent directory listing.
- * @param fileName File name.
- * @param lenDelta Length delta.
- * @param accessTime Last access time.
- * @param modificationTime Last modification time.
- */
- private UpdateListingEntry(IgniteUuid fileId,
- String fileName,
- long lenDelta,
- long accessTime,
- long modificationTime) {
- this.fileId = fileId;
- this.fileName = fileName;
- this.lenDelta = lenDelta;
- this.accessTime = accessTime;
- this.modificationTime = modificationTime;
- }
-
- /** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> e, Object... args) {
- IgfsFileInfo fileInfo = e.getValue();
-
- Map<String, IgfsListingEntry> listing = fileInfo.listing();
-
- IgfsListingEntry entry = listing.get(fileName);
-
- if (entry == null || !entry.fileId().equals(fileId))
- return null;
-
- entry = new IgfsListingEntry(entry, entry.length() + lenDelta,
- accessTime == -1 ? entry.accessTime() : accessTime,
- modificationTime == -1 ? entry.modificationTime() : modificationTime);
-
- // Create new map to replace info.
- listing = new HashMap<>(listing);
-
- // Modify listing map in-place since map is serialization-safe.
- listing.put(fileName, entry);
-
- e.setValue(new IgfsFileInfo(listing, fileInfo));
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeGridUuid(out, fileId);
- out.writeUTF(fileName);
- out.writeLong(lenDelta);
- out.writeLong(accessTime);
- out.writeLong(modificationTime);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException {
- fileId = U.readGridUuid(in);
- fileName = in.readUTF();
- lenDelta = in.readLong();
- accessTime = in.readLong();
- modificationTime = in.readLong();
- }
- }
-
- /**
* Remove entry from directory listing.
*/
@GridInternal
@@ -3608,13 +3461,9 @@ public class IgfsMetaManager extends IgfsManager {
throw new IgfsParentNotDirectoryException("Failed to " + (append ? "open" : "create" )
+ " file (parent element is not a directory)");
- Map<String, IgfsListingEntry> parentListing = lowermostExistingInfo.listing();
-
final String uppermostFileToBeCreatedName = b.components.get(b.existingIdCnt - 1);
- final IgfsListingEntry entry = parentListing.get(uppermostFileToBeCreatedName);
-
- if (entry == null) {
+ if (!lowermostExistingInfo.hasChild(uppermostFileToBeCreatedName)) {
b.doBuild();
assert b.leafInfo != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ba30ddbc/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
index 8c11073..3bf1011 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
@@ -381,8 +381,6 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
throw new IOException("File to read file metadata: " + fileInfo.path(), e);
}
- meta.updateParentListingAsync(parentId, fileInfo.id(), fileName, bytes, modificationTime);
-
if (err != null)
throw err;
}
[47/50] [abbrv] ignite git commit: IGNITE-2951 - Stability fixes for
cluster with many clients
Posted by sb...@apache.org.
IGNITE-2951 - Stability fixes for cluster with many clients
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d92e617a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d92e617a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d92e617a
Branch: refs/heads/ignite-1837
Commit: d92e617a71c31ccaa3fd6e4954aa4ccaf494733c
Parents: e7ab8ee
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Apr 6 18:10:45 2016 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Apr 6 18:10:45 2016 -0700
----------------------------------------------------------------------
.../dht/preloader/GridDhtPartitionDemander.java | 11 ++---
.../GridDhtPartitionsExchangeFuture.java | 4 +-
.../continuous/GridContinuousProcessor.java | 13 +++++-
.../ignite/spi/discovery/tcp/ClientImpl.java | 2 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 44 +++++++++-----------
.../spi/discovery/tcp/TcpDiscoverySpi.java | 23 ++++------
.../IgniteClientReconnectAbstractTest.java | 7 ++--
.../tcp/TcpClientDiscoverySpiSelfTest.java | 8 ++--
.../spi/discovery/tcp/TcpDiscoverySelfTest.java | 39 +++++++++--------
.../TcpDiscoverySpiFailureTimeoutSelfTest.java | 23 ++++------
.../spi/discovery/tcp/TestTcpDiscoverySpi.java | 5 ++-
11 files changed, 87 insertions(+), 92 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d92e617a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 7e13f26..6181d9e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -859,7 +859,7 @@ public class GridDhtPartitionDemander {
log.debug("Rebalancing is not required [cache=" + cctx.name() +
", topology=" + topVer + "]");
- checkIsDone(cancelled);
+ checkIsDone(cancelled, true);
}
}
@@ -883,7 +883,7 @@ public class GridDhtPartitionDemander {
remaining.clear();
- checkIsDone(true /* cancelled */);
+ checkIsDone(true /* cancelled */, false);
}
return true;
@@ -1014,13 +1014,13 @@ public class GridDhtPartitionDemander {
*
*/
private void checkIsDone() {
- checkIsDone(false);
+ checkIsDone(false, false);
}
/**
* @param cancelled Is cancelled.
*/
- private void checkIsDone(boolean cancelled) {
+ private void checkIsDone(boolean cancelled, boolean wasEmpty) {
if (remaining.isEmpty()) {
if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_STOPPED) && (!cctx.isReplicated() || sndStoppedEvnt))
preloadEvent(EVT_CACHE_REBALANCE_STOPPED, exchFut.discoveryEvent());
@@ -1028,7 +1028,8 @@ public class GridDhtPartitionDemander {
if (log.isDebugEnabled())
log.debug("Completed rebalance future: " + this);
- cctx.shared().exchange().scheduleResendPartitions();
+ if (!wasEmpty)
+ cctx.shared().exchange().scheduleResendPartitions();
Collection<Integer> m = new HashSet<>();
http://git-wip-us.apache.org/repos/asf/ignite/blob/d92e617a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index 22fb59e..be346b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -929,7 +929,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
U.warn(log, "Failed to wait for partition release future [topVer=" + topologyVersion() +
", node=" + cctx.localNodeId() + "]. Dumping pending objects that might be the cause: ");
- cctx.exchange().dumpPendingObjects();
+ cctx.exchange().dumpDebugInfo();
}
/**
@@ -993,7 +993,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
locMap = new GridDhtPartitionMap(locMap.nodeId(), locMap.updateSequence(), locMap.map());
m.addLocalPartitionMap(cacheCtx.cacheId(), locMap);
-
+
m.partitionUpdateCounters(cacheCtx.cacheId(), cacheCtx.topology().updateCounters());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d92e617a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index 99e0bb5..c6503e0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -394,7 +394,18 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
/** {@inheritDoc} */
@Override @Nullable public Serializable collectDiscoveryData(UUID nodeId) {
if (!nodeId.equals(ctx.localNodeId()) || !locInfos.isEmpty()) {
- DiscoveryData data = new DiscoveryData(ctx.localNodeId(), clientInfos);
+ Map<UUID, Map<UUID, LocalRoutineInfo>> clientInfos0 = U.newHashMap(clientInfos.size());
+
+ for (Map.Entry<UUID, Map<UUID, LocalRoutineInfo>> e : clientInfos.entrySet()) {
+ Map<UUID, LocalRoutineInfo> copy = U.newHashMap(e.getValue().size());
+
+ for (Map.Entry<UUID, LocalRoutineInfo> e0 : e.getValue().entrySet())
+ copy.put(e0.getKey(), e0.getValue());
+
+ clientInfos0.put(e.getKey(), copy);
+ }
+
+ DiscoveryData data = new DiscoveryData(ctx.localNodeId(), clientInfos0);
// Collect listeners information (will be sent to joining node during discovery process).
for (Map.Entry<UUID, LocalRoutineInfo> e : locInfos.entrySet()) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/d92e617a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 65b94ca..834922c 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -1062,7 +1062,7 @@ class ClientImpl extends TcpDiscoveryImpl {
try {
if (ack) {
synchronized (mux) {
- assert unackedMsg == null : unackedMsg;
+ assert unackedMsg == null : "Unacked=" + unackedMsg + ", received=" + msg;
unackedMsg = msg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d92e617a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index f0de546..5c7ffbd 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -18,9 +18,11 @@
package org.apache.ignite.spi.discovery.tcp;
import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectStreamException;
+import java.io.OutputStream;
import java.io.Serializable;
import java.net.ConnectException;
import java.net.InetAddress;
@@ -73,7 +75,6 @@ import org.apache.ignite.internal.util.GridBoundedLinkedHashSet;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
-import org.apache.ignite.internal.util.io.GridByteArrayOutputStream;
import org.apache.ignite.internal.util.lang.GridTuple;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.C1;
@@ -2120,6 +2121,9 @@ class ServerImpl extends TcpDiscoveryImpl {
/** Socket. */
private Socket sock;
+ /** Output stream. */
+ private OutputStream out;
+
/** Last time status message has been sent. */
private long lastTimeStatusMsgSent;
@@ -2456,10 +2460,12 @@ class ServerImpl extends TcpDiscoveryImpl {
sock = spi.openSocket(addr, timeoutHelper);
+ out = new BufferedOutputStream(sock.getOutputStream(), sock.getSendBufferSize());
+
openSock = true;
// Handshake.
- writeToSocket(sock, new TcpDiscoveryHandshakeRequest(locNodeId),
+ spi.writeToSocket(sock, out, new TcpDiscoveryHandshakeRequest(locNodeId),
timeoutHelper.nextTimeoutChunk(spi.getSocketTimeout()));
TcpDiscoveryHandshakeResponse res = spi.readMessage(sock, null,
@@ -2613,7 +2619,7 @@ class ServerImpl extends TcpDiscoveryImpl {
timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi);
try {
- writeToSocket(sock, pendingMsg, timeoutHelper.nextTimeoutChunk(
+ spi.writeToSocket(sock, out, pendingMsg, timeoutHelper.nextTimeoutChunk(
spi.getSocketTimeout()));
}
finally {
@@ -2665,7 +2671,7 @@ class ServerImpl extends TcpDiscoveryImpl {
}
}
- writeToSocket(sock, msg, timeoutHelper.nextTimeoutChunk(spi.getSocketTimeout()));
+ spi.writeToSocket(sock, out, msg, timeoutHelper.nextTimeoutChunk(spi.getSocketTimeout()));
spi.stats.onMessageSent(msg, U.currentTimeMillis() - tstamp);
@@ -3956,7 +3962,7 @@ class ServerImpl extends TcpDiscoveryImpl {
}
else if (leftNode.equals(next) && sock != null) {
try {
- writeToSocket(sock, msg, spi.failureDetectionTimeoutEnabled() ?
+ spi.writeToSocket(sock, out, msg, spi.failureDetectionTimeoutEnabled() ?
spi.failureDetectionTimeout() : spi.getSocketTimeout());
if (log.isDebugEnabled())
@@ -5569,6 +5575,9 @@ class ServerImpl extends TcpDiscoveryImpl {
/** Socket. */
private final Socket sock;
+ /** Output stream. */
+ private final OutputStream out;
+
/** Current client metrics. */
private volatile ClusterMetrics metrics;
@@ -5582,11 +5591,13 @@ class ServerImpl extends TcpDiscoveryImpl {
* @param sock Socket.
* @param clientNodeId Node ID.
*/
- protected ClientMessageWorker(Socket sock, UUID clientNodeId) {
+ protected ClientMessageWorker(Socket sock, UUID clientNodeId) throws IOException {
super("tcp-disco-client-message-worker", 2000);
this.sock = sock;
this.clientNodeId = clientNodeId;
+
+ out = new BufferedOutputStream(sock.getOutputStream(), sock.getSendBufferSize());
}
/**
@@ -5633,7 +5644,7 @@ class ServerImpl extends TcpDiscoveryImpl {
log.debug("Sending message ack to client [sock=" + sock + ", locNodeId="
+ getLocalNodeId() + ", rmtNodeId=" + clientNodeId + ", msg=" + msg + ']');
- writeToSocket(sock, msg, spi.failureDetectionTimeoutEnabled() ?
+ spi.writeToSocket(sock, out, msg, spi.failureDetectionTimeoutEnabled() ?
spi.failureDetectionTimeout() : spi.getSocketTimeout());
}
}
@@ -5644,7 +5655,7 @@ class ServerImpl extends TcpDiscoveryImpl {
assert topologyInitialized(msg) : msg;
- writeToSocket(sock, msg, spi.failureDetectionTimeoutEnabled() ?
+ spi.writeToSocket(sock, out, msg, spi.failureDetectionTimeoutEnabled() ?
spi.failureDetectionTimeout() : spi.getSocketTimeout());
}
}
@@ -5751,9 +5762,6 @@ class ServerImpl extends TcpDiscoveryImpl {
* Base class for message workers.
*/
protected abstract class MessageWorkerAdapter extends IgniteSpiThread {
- /** Pre-allocated output stream (100K). */
- private final GridByteArrayOutputStream bout = new GridByteArrayOutputStream(100 * 1024);
-
/** Message queue. */
private final BlockingDeque<TcpDiscoveryAbstractMessage> queue = new LinkedBlockingDeque<>();
@@ -5835,20 +5843,6 @@ class ServerImpl extends TcpDiscoveryImpl {
protected void noMessageLoop() {
// No-op.
}
-
- /**
- * @param sock Socket.
- * @param msg Message.
- * @param timeout Socket timeout.
- * @throws IOException If IO failed.
- * @throws IgniteCheckedException If marshalling failed.
- */
- protected final void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg, long timeout)
- throws IOException, IgniteCheckedException {
- bout.reset();
-
- spi.writeToSocket(sock, msg, bout, timeout);
- }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/d92e617a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 277055a..abe380c 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -17,6 +17,7 @@
package org.apache.ignite.spi.discovery.tcp;
+import java.io.BufferedOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
@@ -51,7 +52,6 @@ import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.AddressResolver;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
-import org.apache.ignite.internal.util.io.GridByteArrayOutputStream;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
@@ -1346,45 +1346,38 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
*/
protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg, long timeout) throws IOException,
IgniteCheckedException {
- writeToSocket(sock, msg, new GridByteArrayOutputStream(8 * 1024), timeout); // 8K.
+ writeToSocket(sock, new BufferedOutputStream(sock.getOutputStream(), sock.getSendBufferSize()), msg, timeout);
}
/**
* Writes message to the socket.
*
* @param sock Socket.
+ * @param out Stream to write to.
* @param msg Message.
- * @param bout Byte array output stream.
* @param timeout Timeout.
* @throws IOException If IO failed or write timed out.
* @throws IgniteCheckedException If marshalling failed.
*/
@SuppressWarnings("ThrowFromFinallyBlock")
protected void writeToSocket(Socket sock,
+ OutputStream out,
TcpDiscoveryAbstractMessage msg,
- GridByteArrayOutputStream bout,
long timeout) throws IOException, IgniteCheckedException {
assert sock != null;
assert msg != null;
- assert bout != null;
-
- // Marshall message first to perform only write after.
- marsh.marshal(msg, bout);
+ assert out != null;
SocketTimeoutObject obj = new SocketTimeoutObject(sock, U.currentTimeMillis() + timeout);
addTimeoutObject(obj);
- IOException err = null;
+ IgniteCheckedException err = null;
try {
- OutputStream out = sock.getOutputStream();
-
- bout.writeTo(out);
-
- out.flush();
+ marsh.marshal(msg, out);
}
- catch (IOException e) {
+ catch (IgniteCheckedException e) {
err = e;
}
finally {
http://git-wip-us.apache.org/repos/asf/ignite/blob/d92e617a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAbstractTest.java
index 0c005e9..96ca0dd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAbstractTest.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.Socket;
import java.util.Collection;
import java.util.Collections;
@@ -384,7 +385,7 @@ public abstract class IgniteClientReconnectAbstractTest extends GridCommonAbstra
volatile CountDownLatch writeLatch;
/** {@inheritDoc} */
- @Override protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg, long timeout)
+ @Override protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg, long timeout)
throws IOException, IgniteCheckedException {
if (msg instanceof TcpDiscoveryJoinRequestMessage) {
CountDownLatch writeLatch0 = writeLatch;
@@ -396,7 +397,7 @@ public abstract class IgniteClientReconnectAbstractTest extends GridCommonAbstra
}
}
- super.writeToSocket(sock, msg, timeout);
+ super.writeToSocket(sock, out, msg, timeout);
}
}
@@ -464,4 +465,4 @@ public abstract class IgniteClientReconnectAbstractTest extends GridCommonAbstra
log.error(s);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d92e617a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
index 7debb41..e01094c 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
@@ -18,6 +18,7 @@
package org.apache.ignite.spi.discovery.tcp;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.ArrayList;
@@ -44,7 +45,6 @@ import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteNodeAttributes;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
-import org.apache.ignite.internal.util.io.GridByteArrayOutputStream;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.lang.IgniteInClosure2X;
import org.apache.ignite.internal.util.typedef.CIX2;
@@ -2158,8 +2158,8 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg,
- GridByteArrayOutputStream bout, long timeout) throws IOException, IgniteCheckedException {
+ @Override protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg,
+ long timeout) throws IOException, IgniteCheckedException {
waitFor(writeLock);
boolean fail = false;
@@ -2184,7 +2184,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
sock.close();
}
- super.writeToSocket(sock, msg, bout, timeout);
+ super.writeToSocket(sock, out, msg, timeout);
if (afterWrite != null)
afterWrite.apply(msg, sock);
http://git-wip-us.apache.org/repos/asf/ignite/blob/d92e617a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
index 0df7da6..b45fe12 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.spi.discovery.tcp;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
@@ -54,7 +55,6 @@ import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
import org.apache.ignite.internal.processors.continuous.StartRoutineAckDiscoveryMessage;
import org.apache.ignite.internal.processors.port.GridPortRecord;
-import org.apache.ignite.internal.util.io.GridByteArrayOutputStream;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
@@ -1849,9 +1849,8 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
private volatile boolean failed;
/** {@inheritDoc} */
- @Override protected void writeToSocket(Socket sock,
+ @Override protected void writeToSocket(Socket sock, OutputStream out,
TcpDiscoveryAbstractMessage msg,
- GridByteArrayOutputStream bout,
long timeout) throws IOException, IgniteCheckedException {
boolean add = msgIds.add(msg.id());
@@ -1861,7 +1860,7 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
failed = true;
}
- super.writeToSocket(sock, msg, bout, timeout);
+ super.writeToSocket(sock, out, msg, timeout);
}
}
@@ -1874,8 +1873,8 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
@Override protected void writeToSocket(Socket sock,
+ OutputStream out,
TcpDiscoveryAbstractMessage msg,
- GridByteArrayOutputStream bout,
long timeout) throws IOException, IgniteCheckedException {
if (stopBeforeSndAck) {
if (msg instanceof TcpDiscoveryCustomEventMessage) {
@@ -1905,7 +1904,7 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
}
}
- super.writeToSocket(sock, msg, bout, timeout);
+ super.writeToSocket(sock, out, msg, timeout);
}
}
@@ -1937,8 +1936,8 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
@Override protected void writeToSocket(Socket sock,
+ OutputStream out,
TcpDiscoveryAbstractMessage msg,
- GridByteArrayOutputStream bout,
long timeout) throws IOException, IgniteCheckedException {
if (stop)
return;
@@ -1983,7 +1982,7 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
return;
}
- super.writeToSocket(sock, msg, bout, timeout);
+ super.writeToSocket(sock, out, msg, timeout);
}
}
@@ -1998,8 +1997,8 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
private boolean stop;
/** {@inheritDoc} */
- @Override protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg,
- GridByteArrayOutputStream bout, long timeout) throws IOException, IgniteCheckedException {
+ @Override protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg,
+ long timeout) throws IOException, IgniteCheckedException {
if (msg instanceof TcpDiscoveryCustomEventMessage && latch != null) {
log.info("Stop node on custom event: " + msg);
@@ -2011,7 +2010,7 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
if (stop)
return;
- super.writeToSocket(sock, msg, bout, timeout);
+ super.writeToSocket(sock, out, msg, timeout);
}
}
@@ -2032,8 +2031,8 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
private boolean debug;
/** {@inheritDoc} */
- @Override protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg,
- GridByteArrayOutputStream bout, long timeout) throws IOException, IgniteCheckedException {
+ @Override protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg,
+ long timeout) throws IOException, IgniteCheckedException {
if (msg instanceof TcpDiscoveryNodeAddedMessage) {
if (nodeAdded1 != null) {
nodeAdded1.countDown();
@@ -2060,7 +2059,7 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
if (debug && msg instanceof TcpDiscoveryCustomEventMessage)
log.info("--- Send custom event: " + msg);
- super.writeToSocket(sock, msg, bout, timeout);
+ super.writeToSocket(sock, out, msg, timeout);
}
}
@@ -2072,13 +2071,13 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
private volatile boolean stop;
/** {@inheritDoc} */
- @Override protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg,
- GridByteArrayOutputStream bout, long timeout) throws IOException, IgniteCheckedException {
+ @Override protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg,
+ long timeout) throws IOException, IgniteCheckedException {
if (stop)
throw new RuntimeException("Failing ring message worker explicitly");
- super.writeToSocket(sock, msg, bout, timeout);
+ super.writeToSocket(sock, out, msg, timeout);
}
}
@@ -2090,12 +2089,12 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
private volatile boolean stop;
/** {@inheritDoc} */
- @Override protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg,
- GridByteArrayOutputStream bout, long timeout) throws IOException, IgniteCheckedException {
+ @Override protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg,
+ long timeout) throws IOException, IgniteCheckedException {
if (stop)
throw new RuntimeException("Failing ring message worker explicitly");
- super.writeToSocket(sock, msg, bout, timeout);
+ super.writeToSocket(sock, out, msg, timeout);
if (msg instanceof TcpDiscoveryNodeAddedMessage)
stop = true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/d92e617a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java
index 4cf9bd0..4ef984f 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java
@@ -18,12 +18,12 @@
package org.apache.ignite.spi.discovery.tcp;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.io.GridByteArrayOutputStream;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.spi.IgniteSpiOperationTimeoutException;
import org.apache.ignite.spi.IgniteSpiOperationTimeoutHelper;
@@ -348,10 +348,14 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
}
/** {@inheritDoc} */
- @Override protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg, long timeout)
+ @Override protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg, long timeout)
throws IOException, IgniteCheckedException {
if (!(msg instanceof TcpDiscoveryPingRequest)) {
- super.writeToSocket(sock, msg, timeout);
+ if (countConnCheckMsg && msg instanceof TcpDiscoveryConnectionCheckMessage)
+ connCheckStatusMsgCntSent++;
+
+ super.writeToSocket(sock, out, msg, timeout);
+
return;
}
@@ -370,16 +374,7 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
}
}
else
- super.writeToSocket(sock, msg, timeout);
- }
-
- /** {@inheritDoc} */
- @Override protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg,
- GridByteArrayOutputStream bout, long timeout) throws IOException, IgniteCheckedException {
- if (countConnCheckMsg && msg instanceof TcpDiscoveryConnectionCheckMessage)
- connCheckStatusMsgCntSent++;
-
- super.writeToSocket(sock, msg, bout, timeout);
+ super.writeToSocket(sock, out, msg, timeout);
}
/** {@inheritDoc} */
@@ -405,4 +400,4 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
countConnCheckMsg = false;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/d92e617a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestTcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestTcpDiscoverySpi.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestTcpDiscoverySpi.java
index dbc54bc..721192f 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestTcpDiscoverySpi.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestTcpDiscoverySpi.java
@@ -18,6 +18,7 @@
package org.apache.ignite.spi.discovery.tcp;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.Socket;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
@@ -31,12 +32,12 @@ public class TestTcpDiscoverySpi extends TcpDiscoverySpi {
public boolean ignorePingResponse;
/** {@inheritDoc} */
- protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg, long timeout) throws IOException,
+ protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg, long timeout) throws IOException,
IgniteCheckedException {
if (msg instanceof TcpDiscoveryPingResponse && ignorePingResponse)
return;
else
- super.writeToSocket(sock, msg, timeout);
+ super.writeToSocket(sock, out, msg, timeout);
}
/** {@inheritDoc} */
[30/50] [abbrv] ignite git commit: IGNITE-2871: IGFS: Removed "path"
from IgfsEntryInfo. Purge event is never fired now,
it will be fixed as a part of IGNITE-1679.
Posted by sb...@apache.org.
IGNITE-2871: IGFS: Removed "path" from IgfsEntryInfo. Purge event is never fired now, it will be fixed as a part of IGNITE-1679.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8d95ebac
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8d95ebac
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8d95ebac
Branch: refs/heads/ignite-1837
Commit: 8d95ebacaa01f3f9271a1ce0d1b991dfead1d0c1
Parents: e886ad0
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Mar 22 12:06:51 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:14:11 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/binary/BinaryContext.java | 2 -
.../processors/igfs/IgfsDeleteWorker.java | 8 +-
.../internal/processors/igfs/IgfsEntryInfo.java | 29 ------
.../internal/processors/igfs/IgfsImpl.java | 45 ++++----
.../processors/igfs/IgfsInputStreamImpl.java | 2 +-
.../processors/igfs/IgfsMetaManager.java | 73 ++++---------
.../processors/igfs/IgfsOutputStreamImpl.java | 19 +---
.../processors/igfs/IgfsPathsCreateResult.java | 15 +--
.../IgfsSecondaryOutputStreamDescriptor.java | 17 +---
.../internal/processors/igfs/IgfsUtils.java | 20 +++-
.../igfs/meta/IgfsMetaUpdatePathProcessor.java | 102 -------------------
.../ignite/igfs/IgfsEventsAbstractSelfTest.java | 32 +-----
.../igfs/IgfsMetaManagerSelfTest.java | 8 +-
13 files changed, 78 insertions(+), 294 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/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 c9ad1e9..b357345 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
@@ -80,7 +80,6 @@ import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileRangeDeletePr
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileRangeUpdateProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileReserveSpaceProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileUnlockProcessor;
-import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdatePathProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdatePropertiesProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdateTimesProcessor;
import org.apache.ignite.internal.util.IgniteUtils;
@@ -135,7 +134,6 @@ public class BinaryContext {
sysClss.add(IgfsMetaFileRangeUpdateProcessor.class.getName());
sysClss.add(IgfsMetaFileReserveSpaceProcessor.class.getName());
sysClss.add(IgfsMetaFileUnlockProcessor.class.getName());
- sysClss.add(IgfsMetaUpdatePathProcessor.class.getName());
sysClss.add(IgfsMetaUpdatePropertiesProcessor.class.getName());
sysClss.add(IgfsMetaUpdateTimesProcessor.class.getName());
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
index f6b26ab..7e4dac8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
@@ -38,7 +38,6 @@ import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_PURGED;
import static org.apache.ignite.internal.GridTopic.TOPIC_IGFS;
/**
@@ -246,12 +245,7 @@ public class IgfsDeleteWorker extends IgfsThread {
// In case this node crashes, other node will re-delete the file.
data.delete(lockedInfo).get();
- boolean ret = meta.delete(trashId, name, id);
-
- if (info.path() != null)
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), info.path(), EVT_IGFS_FILE_PURGED);
-
- return ret;
+ return meta.delete(trashId, name, id);
}
}
else
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
index 45cf828..9ff65da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.igfs;
import org.apache.ignite.binary.BinaryRawReader;
import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -52,9 +51,6 @@ public abstract class IgfsEntryInfo implements Externalizable {
/** Last modification time. */
protected long modificationTime;
- /** Original file path. This is a helper field used only during real file delete. */
- protected IgfsPath path;
-
/**
* Default constructor.
*/
@@ -113,13 +109,6 @@ public abstract class IgfsEntryInfo implements Externalizable {
}
/**
- * @return Original file path. This is a helper field used only in some operations like delete.
- */
- public IgfsPath path() {
- return path;
- }
-
- /**
* @return {@code True} if this is a file.
*/
public abstract boolean isFile();
@@ -155,20 +144,6 @@ public abstract class IgfsEntryInfo implements Externalizable {
}
/**
- * Update path.
- *
- * @param path Path.
- * @return Updated file info.
- */
- public IgfsEntryInfo path(IgfsPath path) {
- IgfsEntryInfo res = copy();
-
- res.path = path;
-
- return res;
- }
-
- /**
* Update access and modification time.
*
* @param accessTime Access time.
@@ -295,7 +270,6 @@ public abstract class IgfsEntryInfo implements Externalizable {
U.writeStringMap(out, props);
out.writeLong(accessTime);
out.writeLong(modificationTime);
- out.writeObject(path);
}
/** {@inheritDoc} */
@@ -304,7 +278,6 @@ public abstract class IgfsEntryInfo implements Externalizable {
props = U.readStringMap(in);
accessTime = in.readLong();
modificationTime = in.readLong();
- path = (IgfsPath)in.readObject();
}
/**
@@ -319,7 +292,6 @@ public abstract class IgfsEntryInfo implements Externalizable {
out.writeLong(accessTime);
out.writeLong(modificationTime);
- out.writeObject(path);
}
/**
@@ -334,7 +306,6 @@ public abstract class IgfsEntryInfo implements Externalizable {
accessTime = in.readLong();
modificationTime = in.readLong();
- path = in.readObject();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/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 e3a82a5..358aaf0 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
@@ -691,12 +691,7 @@ public final class IgfsImpl implements IgfsEx {
return null;
}
- IgfsEntryInfo info = meta.move(src, dest);
-
- int evtTyp = info.isFile() ? EVT_IGFS_FILE_RENAMED : EVT_IGFS_DIR_RENAMED;
-
- if (evts.isRecordable(evtTyp))
- evts.record(new IgfsEvent(src, info.path(), localNode(), evtTyp));
+ meta.move(src, dest);
return null;
}
@@ -1016,8 +1011,8 @@ public final class IgfsImpl implements IgfsEx {
batch = newBatch(path, desc.out());
- IgfsEventAwareOutputStream os = new IgfsEventAwareOutputStream(path, desc.info(), desc.parentId(),
- bufSize == 0 ? cfg.getStreamBufferSize() : bufSize, mode, batch);
+ IgfsEventAwareOutputStream os = new IgfsEventAwareOutputStream(path, desc.info(),
+ bufferSize(bufSize), mode, batch);
IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_FILE_OPENED_WRITE);
@@ -1034,7 +1029,7 @@ public final class IgfsImpl implements IgfsEx {
else
dirProps = fileProps = new HashMap<>(props);
- IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = meta.create(
+ IgfsEntryInfo res = meta.create(
path,
dirProps,
overwrite,
@@ -1044,10 +1039,9 @@ public final class IgfsImpl implements IgfsEx {
fileProps
);
- assert t2 != null;
+ assert res != null;
- return new IgfsEventAwareOutputStream(path, t2.get1(), t2.get2(),
- bufSize == 0 ? cfg.getStreamBufferSize() : bufSize, mode, null);
+ return new IgfsEventAwareOutputStream(path, res, bufferSize(bufSize), mode, null);
}
});
}
@@ -1082,8 +1076,7 @@ public final class IgfsImpl implements IgfsEx {
batch = newBatch(path, desc.out());
- return new IgfsEventAwareOutputStream(path, desc.info(), desc.parentId(),
- bufSize == 0 ? cfg.getStreamBufferSize() : bufSize, mode, batch);
+ return new IgfsEventAwareOutputStream(path, desc.info(), bufferSize(bufSize), mode, batch);
}
final List<IgniteUuid> ids = meta.fileIds(path);
@@ -1112,7 +1105,7 @@ public final class IgfsImpl implements IgfsEx {
else
dirProps = fileProps = new HashMap<>(props);
- IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = meta.append(
+ IgfsEntryInfo res = meta.append(
path,
dirProps,
create,
@@ -1122,10 +1115,9 @@ public final class IgfsImpl implements IgfsEx {
fileProps
);
- assert t2 != null;
+ assert res != null;
- return new IgfsEventAwareOutputStream(path, t2.get1(), t2.get2(),
- bufSize == 0 ? cfg.getStreamBufferSize() : bufSize, mode, null);
+ return new IgfsEventAwareOutputStream(path, res, bufferSize(bufSize), mode, null);
}
});
}
@@ -1693,14 +1685,13 @@ public final class IgfsImpl implements IgfsEx {
*
* @param path Path to stored file.
* @param fileInfo File info.
- * @param parentId Parent ID.
* @param bufSize The size of the buffer to be used.
* @param mode IGFS mode.
* @param batch Optional secondary file system batch.
*/
- IgfsEventAwareOutputStream(IgfsPath path, IgfsEntryInfo fileInfo,
- IgniteUuid parentId, int bufSize, IgfsMode mode, @Nullable IgfsFileWorkerBatch batch) {
- super(igfsCtx, path, fileInfo, parentId, bufSize, mode, batch, metrics);
+ IgfsEventAwareOutputStream(IgfsPath path, IgfsEntryInfo fileInfo, int bufSize, IgfsMode mode,
+ @Nullable IgfsFileWorkerBatch batch) {
+ super(igfsCtx, path, fileInfo, bufSize, mode, batch, metrics);
metrics.incrementFilesOpenedForWrite();
}
@@ -1964,6 +1955,16 @@ public final class IgfsImpl implements IgfsEx {
}
/**
+ * Get buffer size.
+ *
+ * @param bufSize Original buffer size.
+ * @return Real buffer size.
+ */
+ private int bufferSize(int bufSize) {
+ return bufSize == 0 ? cfg.getStreamBufferSize() : bufSize;
+ }
+
+ /**
* IGFS thread factory.
*/
@SuppressWarnings("NullableProblems")
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
index 5d41543..447be93 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
@@ -324,7 +324,7 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
}
}
catch (IgniteCheckedException e) {
- throw new IOException("File to close the file: " + fileInfo.path(), e);
+ throw new IOException("File to close the file: " + path, e);
}
finally {
closed = true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index 1aa49ed..d6c5995 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -52,7 +52,6 @@ import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileUnlockProcess
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingAddProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingRemoveProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingReplaceProcessor;
-import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdatePathProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdatePropertiesProcessor;
import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdateTimesProcessor;
import org.apache.ignite.internal.util.GridLeanMap;
@@ -61,9 +60,7 @@ import org.apache.ignite.internal.util.lang.GridClosureException;
import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;
@@ -89,13 +86,15 @@ import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.CountDownLatch;
+import static org.apache.ignite.events.EventType.EVT_IGFS_DIR_RENAMED;
+import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_RENAMED;
+
/**
* Cache based structure (meta data) manager.
*/
public class IgfsMetaManager extends IgfsManager {
/** Comparator for Id sorting. */
- private static final Comparator<IgniteUuid> PATH_ID_SORTING_COMPARATOR
- = new Comparator<IgniteUuid>() {
+ private static final Comparator<IgniteUuid> PATH_ID_SORTING_COMPARATOR = new Comparator<IgniteUuid>() {
@Override public int compare(IgniteUuid u1, IgniteUuid u2) {
if (u1 == u2)
return 0;
@@ -850,11 +849,10 @@ public class IgfsMetaManager extends IgfsManager {
* Move routine.
*
* @param srcPath Source path.
- * @param dstPath Destinatoin path.
- * @return File info of renamed entry.
+ * @param dstPath Destination path.
* @throws IgniteCheckedException In case of exception.
*/
- public IgfsEntryInfo move(IgfsPath srcPath, IgfsPath dstPath) throws IgniteCheckedException {
+ public void move(IgfsPath srcPath, IgfsPath dstPath) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
validTxState(false);
@@ -931,10 +929,11 @@ public class IgfsMetaManager extends IgfsManager {
tx.commit();
+ // Fire events.
IgfsPath newPath = new IgfsPath(dstPathIds.path(), dstName);
- // Set the new path to the info to simplify event creation:
- return srcInfo.path(newPath);
+ IgfsUtils.sendEvents(igfsCtx.kernalContext(), srcPath, newPath,
+ srcInfo.isFile() ? EVT_IGFS_FILE_RENAMED : EVT_IGFS_DIR_RENAMED);
}
}
finally {
@@ -1137,9 +1136,6 @@ public class IgfsMetaManager extends IgfsManager {
transferEntry(parentInfo.listing().get(victimName), parentId, victimName, trashId, trashName);
- if (victimInfo.isFile())
- invokeUpdatePath(victimId, path);
-
tx.commit();
delWorker.signal();
@@ -1739,19 +1735,6 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * Invoke path update processor.
- *
- * @param id File ID.
- * @param path Path to be updated.
- * @throws IgniteCheckedException If failed.
- */
- private void invokeUpdatePath(IgniteUuid id, IgfsPath path) throws IgniteCheckedException {
- validTxState(true);
-
- id2InfoPrj.invoke(id, new IgfsMetaUpdatePathProcessor(path));
- }
-
- /**
* Invoke some processor and return new value.
*
* @param id ID.
@@ -1923,10 +1906,10 @@ public class IgfsMetaManager extends IgfsManager {
}
// Record CREATE event if needed.
- if (evts.isRecordable(EventType.EVT_IGFS_FILE_CREATED))
+ if (oldId == null && evts.isRecordable(EventType.EVT_IGFS_FILE_CREATED))
pendingEvts.add(new IgfsEvent(path, locNode, EventType.EVT_IGFS_FILE_CREATED));
- return new IgfsSecondaryOutputStreamDescriptor(parentInfo.id(), newInfo, out);
+ return new IgfsSecondaryOutputStreamDescriptor(newInfo, out);
}
@Override public IgfsSecondaryOutputStreamDescriptor onFailure(Exception err)
@@ -2018,8 +2001,7 @@ public class IgfsMetaManager extends IgfsManager {
// Set lock and return.
IgfsEntryInfo lockedInfo = invokeLock(info.id(), false);
- return new IgfsSecondaryOutputStreamDescriptor(infos.get(path.parent()).id(),
- lockedInfo, out);
+ return new IgfsSecondaryOutputStreamDescriptor(lockedInfo, out);
}
@Override public IgfsSecondaryOutputStreamDescriptor onFailure(@Nullable Exception err)
@@ -2373,9 +2355,6 @@ public class IgfsMetaManager extends IgfsManager {
softDeleteNonTx(null, path.name(), info.id(), trashId);
}
- // Update the deleted file info with path information for delete worker.
- invokeUpdatePath(info.id(), path);
-
return true; // No additional handling is required.
}
@@ -2902,10 +2881,10 @@ public class IgfsMetaManager extends IgfsManager {
* @param affKey Affinity key.
* @param evictExclude Evict exclude flag.
* @param fileProps File properties.
- * @return Tuple containing the file info and its parent id.
+ * @return Resulting info.
* @throws IgniteCheckedException If failed.
*/
- IgniteBiTuple<IgfsEntryInfo, IgniteUuid> append(
+ IgfsEntryInfo append(
final IgfsPath path,
Map<String, String> dirProps,
final boolean create,
@@ -2954,13 +2933,11 @@ public class IgfsMetaManager extends IgfsManager {
// At this point we can open the stream safely.
info = invokeLock(info.id(), false);
- IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = new T2<>(info, pathIds.lastParentId());
-
tx.commit();
IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EventType.EVT_IGFS_FILE_OPENED_WRITE);
- return t2;
+ return info;
}
else {
// Create file and parent folders.
@@ -2976,7 +2953,7 @@ public class IgfsMetaManager extends IgfsManager {
// Generate events.
generateCreateEvents(res.createdPaths(), true);
- return new T2<>(res.info(), res.parentId());
+ return res.info();
}
}
}
@@ -2999,10 +2976,10 @@ public class IgfsMetaManager extends IgfsManager {
* @param affKey Affinity key.
* @param evictExclude Evict exclude flag.
* @param fileProps File properties.
- * @return @return Tuple containing the created file info and its parent id.
+ * @return @return Resulting info.
* @throws IgniteCheckedException If failed.
*/
- IgniteBiTuple<IgfsEntryInfo, IgniteUuid> create(
+ IgfsEntryInfo create(
final IgfsPath path,
Map<String, String> dirProps,
final boolean overwrite,
@@ -3080,17 +3057,12 @@ public class IgfsMetaManager extends IgfsManager {
IgfsEntryInfo newInfo = invokeAndGet(overwriteId, new IgfsMetaFileCreateProcessor(createTime,
fileProps, blockSize, affKey, createFileLockId(false), evictExclude));
- // Fourth step: update path of remove file.
- invokeUpdatePath(oldId, path);
-
// Prepare result and commit.
- IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = new T2<>(newInfo, parentId);
-
tx.commit();
IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EventType.EVT_IGFS_FILE_OPENED_WRITE);
- return t2;
+ return newInfo;
}
else {
// Create file and parent folders.
@@ -3106,7 +3078,7 @@ public class IgfsMetaManager extends IgfsManager {
// Generate events.
generateCreateEvents(res.createdPaths(), true);
- return new T2<>(res.info(), res.parentId());
+ return res.info();
}
}
}
@@ -3190,7 +3162,6 @@ public class IgfsMetaManager extends IgfsManager {
String curPart = pathIds.part(curIdx);
IgniteUuid curId = pathIds.surrogateId(curIdx);
- IgniteUuid curParentId = lastExistingInfo.id();
if (lastExistingInfo.hasChild(curPart))
return null;
@@ -3224,8 +3195,6 @@ public class IgfsMetaManager extends IgfsManager {
// Advance things further.
curIdx++;
- curParentId = curId;
-
curPart = nextPart;
curId = nextId;
}
@@ -3241,7 +3210,7 @@ public class IgfsMetaManager extends IgfsManager {
createdPaths.add(pathIds.path());
- return new IgfsPathsCreateResult(createdPaths, info, curParentId);
+ return new IgfsPathsCreateResult(createdPaths, info);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
index f7c85e8..21e5fb6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
@@ -58,12 +58,6 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
private IgfsEntryInfo fileInfo;
- /** Parent ID. */
- private final IgniteUuid parentId;
-
- /** File name. */
- private final String fileName;
-
/** Space in file to write data. */
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
private long space;
@@ -103,8 +97,8 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
* @param batch Optional secondary file system batch.
* @param metrics Local IGFS metrics.
*/
- IgfsOutputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsEntryInfo fileInfo, IgniteUuid parentId,
- int bufSize, IgfsMode mode, @Nullable IgfsFileWorkerBatch batch, IgfsLocalMetrics metrics) {
+ IgfsOutputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsEntryInfo fileInfo, int bufSize, IgfsMode mode,
+ @Nullable IgfsFileWorkerBatch batch, IgfsLocalMetrics metrics) {
super(path, optimizeBufferSize(bufSize, fileInfo));
assert fileInfo != null;
@@ -126,13 +120,10 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
this.fileInfo = fileInfo;
this.mode = mode;
this.batch = batch;
- this.parentId = parentId;
this.metrics = metrics;
streamRange = initialStreamRange(fileInfo);
- fileName = path.name();
-
writeCompletionFut = data.writeStart(fileInfo);
}
@@ -270,7 +261,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
exists = meta.exists(fileInfo.id());
}
catch (IgniteCheckedException e) {
- throw new IOException("File to read file metadata: " + fileInfo.path(), e);
+ throw new IOException("File to read file metadata: " + path, e);
}
if (!exists) {
@@ -339,7 +330,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
exists = !deleted && meta.exists(fileInfo.id());
}
catch (IgniteCheckedException e) {
- throw new IOException("File to read file metadata: " + fileInfo.path(), e);
+ throw new IOException("File to read file metadata: " + path, e);
}
if (exists) {
@@ -379,7 +370,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
throw new IOException("File was concurrently deleted: " + path);
}
catch (IgniteCheckedException e) {
- throw new IOException("File to read file metadata: " + fileInfo.path(), e);
+ throw new IOException("File to read file metadata: " + path, e);
}
if (err != null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
index 9462aa4..bd13555 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.igfs;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteUuid;
import java.util.List;
@@ -33,20 +32,15 @@ public class IgfsPathsCreateResult {
/** Info of the last created file. */
private final IgfsEntryInfo info;
- /** Parent ID. */
- private final IgniteUuid parentId;
-
/**
* Constructor.
*
* @param paths Created paths.
* @param info Info of the last created file.
- * @param parentId Parent ID.
*/
- public IgfsPathsCreateResult(List<IgfsPath> paths, IgfsEntryInfo info, IgniteUuid parentId) {
+ public IgfsPathsCreateResult(List<IgfsPath> paths, IgfsEntryInfo info) {
this.paths = paths;
this.info = info;
- this.parentId = parentId;
}
/**
@@ -63,13 +57,6 @@ public class IgfsPathsCreateResult {
return info;
}
- /**
- * @return Parent ID.
- */
- public IgniteUuid parentId() {
- return parentId;
- }
-
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsPathsCreateResult.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java
index 507ccfc..6bbc2c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java
@@ -17,17 +17,12 @@
package org.apache.ignite.internal.processors.igfs;
-import org.apache.ignite.lang.IgniteUuid;
-
import java.io.OutputStream;
/**
* Descriptor of an output stream opened to the secondary file system.
*/
public class IgfsSecondaryOutputStreamDescriptor {
- /** Parent ID in the primary file system. */
- private final IgniteUuid parentId;
-
/** File info in the primary file system. */
private final IgfsEntryInfo info;
@@ -37,28 +32,18 @@ public class IgfsSecondaryOutputStreamDescriptor {
/**
* Constructor.
*
- * @param parentId Parent ID in the primary file system.
* @param info File info in the primary file system.
* @param out Output stream to the secondary file system.
*/
- IgfsSecondaryOutputStreamDescriptor(IgniteUuid parentId, IgfsEntryInfo info, OutputStream out) {
- assert parentId != null;
+ IgfsSecondaryOutputStreamDescriptor(IgfsEntryInfo info, OutputStream out) {
assert info != null;
assert out != null;
- this.parentId = parentId;
this.info = info;
this.out = out;
}
/**
- * @return Parent ID in the primary file system.
- */
- IgniteUuid parentId() {
- return parentId;
- }
-
- /**
* @return File info in the primary file system.
*/
IgfsEntryInfo info() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index 9b813b8..c6b7ad3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -282,7 +282,6 @@ public class IgfsUtils {
"exceeded. [maxAttempts=" + MAX_CACHE_TX_RETRIES + ']');
}
-
/**
* Sends a series of event.
*
@@ -290,14 +289,29 @@ public class IgfsUtils {
* @param type The type of event to send.
*/
public static void sendEvents(GridKernalContext kernalCtx, IgfsPath path, int type) {
+ sendEvents(kernalCtx, path, null, type);
+ }
+
+ /**
+ * Sends a series of event.
+ *
+ * @param path The path of the created file.
+ * @param newPath New path.
+ * @param type The type of event to send.
+ */
+ public static void sendEvents(GridKernalContext kernalCtx, IgfsPath path, IgfsPath newPath, int type) {
assert kernalCtx != null;
assert path != null;
GridEventStorageManager evts = kernalCtx.event();
ClusterNode locNode = kernalCtx.discovery().localNode();
- if (evts.isRecordable(type))
- evts.record(new IgfsEvent(path, locNode, type));
+ if (evts.isRecordable(type)) {
+ if (newPath == null)
+ evts.record(new IgfsEvent(path, locNode, type));
+ else
+ evts.record(new IgfsEvent(path, newPath, locNode, type));
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
deleted file mode 100644
index 782b25b..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
+++ /dev/null
@@ -1,102 +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.internal.processors.igfs.meta;
-
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryRawReader;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.igfs.IgfsPath;
-import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteUuid;
-
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.MutableEntry;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-/**
- * Update path closure.
- */
-public final class IgfsMetaUpdatePathProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable, Binarylizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** New path. */
- private IgfsPath path;
-
- /**
- * @param path Path.
- */
- public IgfsMetaUpdatePathProcessor(IgfsPath path) {
- this.path = path;
- }
-
- /**
- * Default constructor (required by Externalizable).
- */
- public IgfsMetaUpdatePathProcessor() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) {
- IgfsEntryInfo info = e.getValue();
-
- IgfsEntryInfo newInfo = info.path(path);
-
- e.setValue(newInfo);
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(path);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- path = (IgfsPath)in.readObject();
- }
-
- /** {@inheritDoc} */
- @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
- BinaryRawWriter out = writer.rawWriter();
-
- out.writeObject(path);
- }
-
- /** {@inheritDoc} */
- @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
- BinaryRawReader in = reader.rawReader();
-
- path = in.readObject();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(IgfsMetaUpdatePathProcessor.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java
index 6ca75a1..de20a4f 100644
--- a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsEventsAbstractSelfTest.java
@@ -53,7 +53,6 @@ import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_CREATED;
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;
-import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_PURGED;
import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_RENAMED;
import static org.apache.ignite.events.EventType.EVT_JOB_MAPPED;
import static org.apache.ignite.events.EventType.EVT_TASK_FAILED;
@@ -425,7 +424,7 @@ public abstract class IgfsEventsAbstractSelfTest extends GridCommonAbstractTest
public void testTwoFiles() throws Exception {
final List<Event> evtList = new ArrayList<>();
- final int evtsCnt = 4 + 3 + 2 + 2;
+ final int evtsCnt = 4 + 3 + 1 + 1;
final CountDownLatch latch = new CountDownLatch(evtsCnt);
@@ -495,11 +494,9 @@ public abstract class IgfsEventsAbstractSelfTest extends GridCommonAbstractTest
assertEquals(0, evt.dataSize());
assertOneToOne(
- evtList.subList(7, 11),
+ evtList.subList(7, 9),
new EventPredicate(EVT_IGFS_FILE_DELETED, new IgfsPath("/dir1/file1")),
- new EventPredicate(EVT_IGFS_FILE_PURGED, new IgfsPath("/dir1/file1")),
- new EventPredicate(EVT_IGFS_FILE_DELETED, new IgfsPath("/dir1/file2")),
- new EventPredicate(EVT_IGFS_FILE_PURGED, new IgfsPath("/dir1/file2"))
+ new EventPredicate(EVT_IGFS_FILE_DELETED, new IgfsPath("/dir1/file2"))
);
}
@@ -683,7 +680,7 @@ public abstract class IgfsEventsAbstractSelfTest extends GridCommonAbstractTest
public void testSingleFileOverwrite() throws Exception {
final List<Event> evtList = new ArrayList<>();
- final int evtsCnt = 1 + 4 + 1;
+ final int evtsCnt = 1 + 3 + 1;
final CountDownLatch latch = new CountDownLatch(evtsCnt);
@@ -737,27 +734,6 @@ public abstract class IgfsEventsAbstractSelfTest extends GridCommonAbstractTest
@Override public boolean apply(Event e) {
IgfsEvent e0 = (IgfsEvent)e;
- return e0.type() == EVT_IGFS_FILE_DELETED && e0.path().equals(file1);
- }
- },
- new P1<Event>() {
- @Override public boolean apply(Event e) {
- IgfsEvent e0 = (IgfsEvent)e;
-
- return e0.type() == EVT_IGFS_FILE_PURGED && e0.path().equals(file1);
- }
- },
- new P1<Event>() {
- @Override public boolean apply(Event e) {
- IgfsEvent e0 = (IgfsEvent)e;
-
- return e0.type() == EVT_IGFS_FILE_CREATED && e0.path().equals(file1);
- }
- },
- new P1<Event>() {
- @Override public boolean apply(Event e) {
- IgfsEvent e0 = (IgfsEvent)e;
-
return e0.type() == EVT_IGFS_FILE_OPENED_WRITE && e0.path().equals(file1);
}
},
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d95ebac/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
index 3dc2791..039bf8d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
@@ -214,12 +214,12 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
private IgfsEntryInfo createFileAndGetInfo(String path) throws IgniteCheckedException {
IgfsPath p = path(path);
- IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = mgr.create(p, null, false, 400, null, false, null);
+ IgfsEntryInfo res = mgr.create(p, null, false, 400, null, false, null);
- assert t2 != null;
- assert !t2.get1().isDirectory();
+ assert res != null;
+ assert !res.isDirectory();
- return t2.get1();
+ return res;
}
/**
[19/50] [abbrv] ignite git commit: IGNITE-2813: IGFS: Optimized
metadata values splitting file and directory into separate classes.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
index 06ae40b..013bb18 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDataManagerSelfTest.java
@@ -17,12 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.nio.ByteBuffer;
-import java.security.SecureRandom;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.concurrent.Callable;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -44,6 +38,13 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.jetbrains.annotations.Nullable;
+import java.nio.ByteBuffer;
+import java.security.SecureRandom;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.Callable;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -168,8 +169,8 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
- IgfsFileInfo info = new IgfsFileInfo(200, 0L, null, IgfsUtils.DELETE_LOCK_ID,
- false, null, t, t);
+ IgfsEntryInfo info = IgfsUtils.createFile(IgniteUuid.randomUuid(), 200, 0L, null,
+ IgfsUtils.DELETE_LOCK_ID, false, null, t, t);
assertNull(mgr.dataBlock(info, path, 0, null).get());
@@ -181,11 +182,11 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
expectsStoreFail(info, data, "Not enough space reserved to store data");
- info = new IgfsFileInfo(info, info.length() + data.length - 3);
+ info = info.length(info.length() + data.length - 3);
expectsStoreFail(info, data, "Not enough space reserved to store data");
- info = new IgfsFileInfo(info, info.length() + 3);
+ info = info.length(info.length() + 3);
IgfsFileAffinityRange range = new IgfsFileAffinityRange();
@@ -253,8 +254,8 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 0L, null, IgfsUtils.DELETE_LOCK_ID,
- false, null, t, t);
+ IgfsEntryInfo info = IgfsUtils.createFile(IgniteUuid.randomUuid(), blockSize, 0L, null,
+ IgfsUtils.DELETE_LOCK_ID, false, null, t, t);
assertNull(mgr.dataBlock(info, path, 0, null).get());
@@ -266,7 +267,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
rnd.nextBytes(remainder);
- info = new IgfsFileInfo(info, info.length() + data.length + remainder.length);
+ info = info.length(info.length() + data.length + remainder.length);
IgniteInternalFuture<Boolean> fut = mgr.writeStart(info);
@@ -279,7 +280,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
byte[] remainder2 = new byte[blockSize / 2];
- info = new IgfsFileInfo(info, info.length() + remainder2.length);
+ info = info.length(info.length() + remainder2.length);
byte[] left2 = mgr.storeDataBlocks(info, info.length(), left, left.length, ByteBuffer.wrap(remainder2),
false, range, null);
@@ -344,9 +345,8 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
- IgfsFileInfo info =
- new IgfsFileInfo(blockSize, 0L, null, IgfsUtils.DELETE_LOCK_ID,
- false, null, t, t);
+ IgfsEntryInfo info = IgfsUtils.createFile(IgniteUuid.randomUuid(), blockSize, 0L, null,
+ IgfsUtils.DELETE_LOCK_ID, false, null, t, t);
IgfsFileAffinityRange range = new IgfsFileAffinityRange();
@@ -356,7 +356,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
byte[] data = new byte[chunkSize];
- info = new IgfsFileInfo(info, info.length() + data.length * writesCnt);
+ info = info.length(info.length() + data.length * writesCnt);
IgniteInternalFuture<Boolean> fut = mgr.writeStart(info);
@@ -416,7 +416,8 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
//IgfsFileInfo info = new IgfsFileInfo(blockSize, 0);
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 1024 * 1024, null, null, false, null, t, t);
+ IgfsEntryInfo info = IgfsUtils.createFile(IgniteUuid.randomUuid(), blockSize, 1024 * 1024, null, null, false,
+ null, t, t);
for (int pos = 0; pos < 5 * grpSize; pos++) {
assertEquals("Expects no affinity for zero length.", Collections.<IgfsBlockLocation>emptyList(),
@@ -466,7 +467,8 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 1024 * 1024, null, null, false, null, t, t);
+ IgfsEntryInfo info = IgfsUtils.createFile(IgniteUuid.randomUuid(), blockSize, 1024 * 1024, null, null, false,
+ null, t, t);
Collection<IgfsBlockLocation> affinity = mgr.affinity(info, 0, info.length());
@@ -499,7 +501,8 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
long t = System.currentTimeMillis();
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 1024 * 1024, null, null, false, null, t, t);
+ IgfsEntryInfo info = IgfsUtils.createFile(IgniteUuid.randomUuid(), blockSize, 1024 * 1024, null, null, false,
+ null, t, t);
IgniteUuid affKey = IgniteUuid.randomUuid();
@@ -508,7 +511,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
map.addRange(new IgfsFileAffinityRange(3 * BLOCK_SIZE, 5 * BLOCK_SIZE - 1, affKey));
map.addRange(new IgfsFileAffinityRange(13 * BLOCK_SIZE, 17 * BLOCK_SIZE - 1, affKey));
- info.fileMap(map);
+ info = info.fileMap(map);
Collection<IgfsBlockLocation> affinity = mgr.affinity(info, 0, info.length());
@@ -542,7 +545,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
* @param info File info.
* @param affinity Affinity block locations to check.
*/
- private void checkAffinity(int blockSize, IgfsFileInfo info, Iterable<IgfsBlockLocation> affinity) {
+ private void checkAffinity(int blockSize, IgfsEntryInfo info, Iterable<IgfsBlockLocation> affinity) {
for (IgfsBlockLocation loc : affinity) {
info("Going to check IGFS block location: " + loc);
@@ -574,7 +577,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
* @param data Data to store.
* @param msg Expected failure message.
*/
- private void expectsStoreFail(final IgfsFileInfo reserved, final byte[] data, @Nullable String msg) {
+ private void expectsStoreFail(final IgfsEntryInfo reserved, final byte[] data, @Nullable String msg) {
GridTestUtils.assertThrows(log, new Callable() {
@Override public Object call() throws Exception {
IgfsFileAffinityRange range = new IgfsFileAffinityRange();
@@ -592,7 +595,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
* @param fileInfo File to delete data for.
* @param msg Expected failure message.
*/
- private void expectsDeleteFail(final IgfsFileInfo fileInfo, @Nullable String msg) {
+ private void expectsDeleteFail(final IgfsEntryInfo fileInfo, @Nullable String msg) {
GridTestUtils.assertThrows(log, new Callable() {
@Override public Object call() throws Exception {
mgr.delete(fileInfo);
@@ -610,7 +613,7 @@ public class IgfsDataManagerSelfTest extends IgfsCommonAbstractTest {
* @param len File part length to get affinity for.
* @param msg Expected failure message.
*/
- private void expectsAffinityFail(final IgfsFileInfo info, final long start, final long len,
+ private void expectsAffinityFail(final IgfsEntryInfo info, final long start, final long len,
@Nullable String msg) {
GridTestUtils.assertThrows(log, new Callable() {
@Override public Object call() throws Exception {
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
index 0731436..6e13280 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
@@ -17,13 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CyclicBarrier;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
import org.apache.ignite.igfs.IgfsFile;
@@ -36,6 +29,14 @@ import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.testframework.GridTestUtils;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CyclicBarrier;
+
import static org.apache.ignite.igfs.IgfsMode.DUAL_ASYNC;
import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC;
import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PERMISSION;
@@ -1254,7 +1255,7 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
// Wait for a while for prefetch to finish.
IgfsMetaManager meta = igfs.context().meta();
- IgfsFileInfo info = meta.info(meta.fileId(FILE));
+ IgfsEntryInfo info = meta.info(meta.fileId(FILE));
assert info != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java
index feccdb5..486179c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfoSelfTest.java
@@ -17,18 +17,19 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.Externalizable;
-import java.util.Random;
-import java.util.concurrent.Callable;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
import org.jetbrains.annotations.Nullable;
+import java.io.Externalizable;
+import java.util.Random;
+import java.util.concurrent.Callable;
+
/**
- * {@link IgfsFileInfo} test case.
+ * {@link IgfsEntryInfo} test case.
*/
public class IgfsFileInfoSelfTest extends IgfsCommonAbstractTest {
/** Marshaller to test {@link Externalizable} interface. */
@@ -49,23 +50,7 @@ public class IgfsFileInfoSelfTest extends IgfsCommonAbstractTest {
@SuppressWarnings("deprecation") // Suppress due to default constructor should never be used directly.
@Nullable @Override public Object call() throws IgniteCheckedException {
- for (int i = 0; i < 10000; i++) {
- testSerialization(new IgfsFileInfo());
- testSerialization(new IgfsFileInfo());
-
- long a = System.currentTimeMillis();
- long m = a + 1;
-
- testSerialization(new IgfsFileInfo(true, null, a, m));
- testSerialization(new IgfsFileInfo(false, null, a, m));
-
- IgfsFileInfo rndInfo =
- new IgfsFileInfo(rnd.nextInt(max), 0, false, null, a, m);
-
- testSerialization(rndInfo);
- testSerialization(new IgfsFileInfo(rndInfo, rnd.nextInt(max)));
- testSerialization(new IgfsFileInfo(rndInfo, F.asMap("desc", String.valueOf(rnd.nextLong()))));
- }
+ testSerialization(IgfsUtils.createDirectory(IgniteUuid.randomUuid()));
return null;
}
@@ -78,7 +63,7 @@ public class IgfsFileInfoSelfTest extends IgfsCommonAbstractTest {
* @param info Node info to test serialization for.
* @throws IgniteCheckedException If failed.
*/
- public void testSerialization(IgfsFileInfo info) throws IgniteCheckedException {
+ public void testSerialization(IgfsEntryInfo info) throws IgniteCheckedException {
assertEquals(info, mu(info));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
index 26424f0..3dc2791 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
@@ -147,12 +147,12 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
IgfsListingEntry dirEntry = mgr.directoryListing(ROOT_ID).get("dir");
assertNotNull(dirEntry);
assertTrue(dirEntry.isDirectory());
- IgfsFileInfo dir = mgr.info(dirEntry.fileId());
+ IgfsEntryInfo dir = mgr.info(dirEntry.fileId());
IgfsListingEntry fileEntry = mgr.directoryListing(ROOT_ID).get("file");
assertNotNull(fileEntry);
assertTrue(!fileEntry.isDirectory());
- IgfsFileInfo file = mgr.info(fileEntry.fileId());
+ IgfsEntryInfo file = mgr.info(fileEntry.fileId());
assertEquals(2, mgr.directoryListing(ROOT_ID).size());
@@ -166,7 +166,7 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
String key1 = UUID.randomUUID().toString();
String key2 = UUID.randomUUID().toString();
- IgfsFileInfo info = mgr.info(fileId);
+ IgfsEntryInfo info = mgr.info(fileId);
assertNull("Unexpected stored properties: " + info, info.properties().get(key1));
assertNull("Unexpected stored properties: " + info, info.properties().get(key2));
@@ -197,24 +197,24 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
assertNull(mgr.updateProperties(dir.id(), F.asMap("p", "7")));
}
- private IgfsFileInfo mkdirsAndGetInfo(String path) throws IgniteCheckedException {
+ private IgfsEntryInfo mkdirsAndGetInfo(String path) throws IgniteCheckedException {
IgfsPath p = path(path);
mgr.mkdirs(p, IgfsImpl.DFLT_DIR_META);
IgniteUuid id = mgr.fileId(p);
- IgfsFileInfo info = mgr.info(id);
+ IgfsEntryInfo info = mgr.info(id);
assert info.isDirectory();
return info;
}
- private IgfsFileInfo createFileAndGetInfo(String path) throws IgniteCheckedException {
+ private IgfsEntryInfo createFileAndGetInfo(String path) throws IgniteCheckedException {
IgfsPath p = path(path);
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = mgr.create(p, null, false, 400, null, false, null);
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = mgr.create(p, null, false, 400, null, false, null);
assert t2 != null;
assert !t2.get1().isDirectory();
@@ -228,7 +228,7 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
public void testStructure() throws Exception {
- IgfsFileInfo rootInfo = new IgfsFileInfo();
+ IgfsEntryInfo rootInfo = IgfsUtils.createDirectory(ROOT_ID);
// Test empty structure.
assertEmpty(mgr.directoryListing(ROOT_ID));
@@ -236,15 +236,15 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
assertEquals(F.asMap(ROOT_ID, rootInfo), mgr.infos(Arrays.asList(ROOT_ID)));
// Directories:
- IgfsFileInfo a = mkdirsAndGetInfo("/a");
- IgfsFileInfo b = mkdirsAndGetInfo("/a/b");
- IgfsFileInfo k = mkdirsAndGetInfo("/a/b/k");
- IgfsFileInfo z = mkdirsAndGetInfo("/a/k");
+ IgfsEntryInfo a = mkdirsAndGetInfo("/a");
+ IgfsEntryInfo b = mkdirsAndGetInfo("/a/b");
+ IgfsEntryInfo k = mkdirsAndGetInfo("/a/b/k");
+ IgfsEntryInfo z = mkdirsAndGetInfo("/a/k");
// Files:
- IgfsFileInfo f1 = createFileAndGetInfo("/f1");
- IgfsFileInfo f2 = createFileAndGetInfo("/a/f2");
- IgfsFileInfo f3 = createFileAndGetInfo("/a/b/f3");
+ IgfsEntryInfo f1 = createFileAndGetInfo("/f1");
+ IgfsEntryInfo f2 = createFileAndGetInfo("/a/f2");
+ IgfsEntryInfo f3 = createFileAndGetInfo("/a/b/f3");
assertEquals(F.asMap("a", new IgfsListingEntry(a), "f1", new IgfsListingEntry(f1)),
mgr.directoryListing(ROOT_ID));
@@ -256,11 +256,11 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
"k", new IgfsListingEntry(k)), mgr.directoryListing(b.id()));
// Validate empty files listings.
- for (IgfsFileInfo info : Arrays.asList(f1, f2, f3))
+ for (IgfsEntryInfo info : Arrays.asList(f1, f2, f3))
assertEmpty(mgr.directoryListing(info.id()));
// Validate 'file info' operations.
- for (IgfsFileInfo info : Arrays.asList(rootInfo, a, b, f1, f2, f3)) {
+ for (IgfsEntryInfo info : Arrays.asList(rootInfo, a, b, f1, f2, f3)) {
assertEquals(info, mgr.info(info.id()));
assertEquals(F.asMap(info.id(), info), mgr.infos(Arrays.asList(info.id())));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
index 4112846..bcc2314 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
@@ -17,17 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.security.SecureRandom;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.cache.Cache;
import org.apache.commons.io.IOUtils;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
@@ -56,6 +45,18 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.jetbrains.annotations.Nullable;
+import javax.cache.Cache;
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicInteger;
+
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -227,8 +228,8 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
IgfsFileImpl info = (IgfsFileImpl)igfs.info(path);
for (int i = 0; i < nodesCount(); i++) {
- IgfsFileInfo fileInfo =
- (IgfsFileInfo)grid(i).cachex(metaCacheName).localPeek(info.fileId(), ONHEAP_PEEK_MODES, null);
+ IgfsEntryInfo fileInfo =
+ (IgfsEntryInfo)grid(i).cachex(metaCacheName).localPeek(info.fileId(), ONHEAP_PEEK_MODES, null);
assertNotNull(fileInfo);
assertNotNull(fileInfo.listing());
@@ -693,10 +694,10 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
IgniteUuid fileId = U.field(igfs.info(path), "fileId");
- GridCacheAdapter<IgniteUuid, IgfsFileInfo> metaCache = ((IgniteKernal)grid(0)).internalCache(META_CACHE_NAME);
+ GridCacheAdapter<IgniteUuid, IgfsEntryInfo> metaCache = ((IgniteKernal)grid(0)).internalCache(META_CACHE_NAME);
GridCacheAdapter<IgfsBlockKey, byte[]> dataCache = ((IgniteKernal)grid(0)).internalCache(DATA_CACHE_NAME);
- IgfsFileInfo info = metaCache.get(fileId);
+ IgfsEntryInfo info = metaCache.get(fileId);
assertNotNull(info);
assertTrue(info.isFile());
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
index fcf4b3b..3933e86 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
@@ -17,17 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheMode;
@@ -55,6 +44,18 @@ import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.transactions.Transaction;
import org.jsr166.ThreadLocalRandom8;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -505,12 +506,12 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
os.write(chunk((int)igfsMaxData));
os.close();
- final IgniteCache<IgniteUuid, IgfsFileInfo> metaCache = igfs.context().kernalContext().cache().jcache(
+ final IgniteCache<IgniteUuid, IgfsEntryInfo> metaCache = igfs.context().kernalContext().cache().jcache(
igfs.configuration().getMetaCacheName());
// Start a transaction in a separate thread which will lock file ID.
final IgniteUuid id = igfs.context().meta().fileId(path);
- final IgfsFileInfo info = igfs.context().meta().info(id);
+ final IgfsEntryInfo info = igfs.context().meta().info(id);
final AtomicReference<Throwable> err = new AtomicReference<>();
@@ -543,15 +544,15 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
new IgfsListingEntry(info));
// Clear root listing.
- metaCache.put(IgfsUtils.ROOT_ID, new IgfsFileInfo(IgfsUtils.ROOT_ID));
+ metaCache.put(IgfsUtils.ROOT_ID, IgfsUtils.createDirectory(IgfsUtils.ROOT_ID));
// Add file to trash listing.
- IgfsFileInfo trashInfo = metaCache.get(trashId);
+ IgfsEntryInfo trashInfo = metaCache.get(trashId);
if (trashInfo == null)
- metaCache.put(trashId, new IgfsFileInfo(listing, new IgfsFileInfo(trashId)));
+ metaCache.put(trashId, IgfsUtils.createDirectory(trashId).listing(listing));
else
- metaCache.put(trashId, new IgfsFileInfo(listing, trashInfo));
+ metaCache.put(trashId, trashInfo.listing(listing));
tx.commit();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
index 2f40c8b..10208ed 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
@@ -17,17 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.atomic.AtomicInteger;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
@@ -53,6 +42,18 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.jetbrains.annotations.Nullable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.atomic.AtomicInteger;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -276,7 +277,7 @@ public class IgfsStreamsSelfTest extends IgfsCommonAbstractTest {
GridCacheAdapter<Object, Object> metaCache = ((IgniteKernal)grid(0)).internalCache(META_CACHE_NAME);
- IgfsFileInfo fileInfo = (IgfsFileInfo)metaCache.get(fileImpl.fileId());
+ IgfsEntryInfo fileInfo = (IgfsEntryInfo)metaCache.get(fileImpl.fileId());
IgfsFileMap map = fileInfo.fileMap();
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
index 672b912..7a4648a 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
@@ -41,11 +41,12 @@ import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadabl
import org.apache.ignite.internal.processors.hadoop.HadoopPayloadAware;
import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsProperties;
import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsSecondaryFileSystemPositionedReadable;
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsFileImpl;
-import org.apache.ignite.internal.processors.igfs.IgfsFileInfo;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.lang.IgniteOutClosure;
+import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.lifecycle.LifecycleAware;
import org.jetbrains.annotations.Nullable;
@@ -350,13 +351,28 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
Collection<IgfsFile> res = new ArrayList<>(statuses.length);
- for (FileStatus status : statuses) {
- IgfsFileInfo fsInfo = status.isDirectory() ?
- new IgfsFileInfo(true, properties(status), status.getAccessTime(), status.getModificationTime()) :
- new IgfsFileInfo((int)status.getBlockSize(), status.getLen(), null, null, false, properties(status),
- status.getAccessTime(), status.getModificationTime());
-
- res.add(new IgfsFileImpl(new IgfsPath(path, status.getPath().getName()), fsInfo, 1));
+ for (FileStatus s : statuses) {
+ IgfsEntryInfo fsInfo = s.isDirectory() ?
+ IgfsUtils.createDirectory(
+ IgniteUuid.randomUuid(),
+ null,
+ properties(s),
+ s.getAccessTime(),
+ s.getModificationTime()
+ ) :
+ IgfsUtils.createFile(
+ IgniteUuid.randomUuid(),
+ (int)s.getBlockSize(),
+ s.getLen(),
+ null,
+ null,
+ false,
+ properties(s),
+ s.getAccessTime(),
+ s.getModificationTime()
+ );
+
+ res.add(new IgfsFileImpl(new IgfsPath(path, s.getPath().getName()), fsInfo, 1));
}
return res;
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
index 0ec8a78..40cf493 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopIgfsDualAbstractSelfTest.java
@@ -17,9 +17,6 @@
package org.apache.ignite.igfs;
-import java.io.IOException;
-import java.net.URI;
-import java.util.concurrent.Callable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
@@ -34,7 +31,7 @@ import org.apache.ignite.hadoop.fs.IgniteHadoopIgfsSecondaryFileSystem;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
import org.apache.ignite.internal.processors.igfs.IgfsBlockKey;
import org.apache.ignite.internal.processors.igfs.IgfsCommonAbstractTest;
-import org.apache.ignite.internal.processors.igfs.IgfsFileInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsImpl;
import org.apache.ignite.internal.processors.igfs.IgfsMetaManager;
import org.apache.ignite.internal.util.typedef.G;
@@ -44,6 +41,10 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.jetbrains.annotations.Nullable;
+import java.io.IOException;
+import java.net.URI;
+import java.util.concurrent.Callable;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -279,7 +280,7 @@ public abstract class HadoopIgfsDualAbstractSelfTest extends IgfsCommonAbstractT
// Wait for a while for prefetch to finish (if any).
IgfsMetaManager meta = igfs.context().meta();
- IgfsFileInfo info = meta.info(meta.fileId(FILE));
+ IgfsEntryInfo info = meta.info(meta.fileId(FILE));
IgfsBlockKey key = new IgfsBlockKey(info.id(), info.affinityKey(), info.evictExclude(), 2);
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemLoggerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemLoggerSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemLoggerSelfTest.java
index e89d651..3013311 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemLoggerSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgniteHadoopFileSystemLoggerSelfTest.java
@@ -17,6 +17,11 @@
package org.apache.ignite.igfs;
+import org.apache.ignite.internal.igfs.common.IgfsLogger;
+import org.apache.ignite.internal.processors.igfs.IgfsCommonAbstractTest;
+import org.apache.ignite.internal.util.typedef.internal.SB;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
@@ -24,12 +29,6 @@ import java.io.FilenameFilter;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
-import org.apache.ignite.internal.igfs.common.IgfsLogger;
-import org.apache.ignite.internal.processors.igfs.IgfsCommonAbstractTest;
-import org.apache.ignite.internal.processors.igfs.IgfsFileImpl;
-import org.apache.ignite.internal.processors.igfs.IgfsFileInfo;
-import org.apache.ignite.internal.util.typedef.internal.SB;
-import org.apache.ignite.internal.util.typedef.internal.U;
import static org.apache.ignite.igfs.IgfsMode.PRIMARY;
import static org.apache.ignite.internal.igfs.common.IgfsLogger.DELIM_FIELD;
@@ -244,16 +243,6 @@ public class IgniteHadoopFileSystemLoggerSelfTest extends IgfsCommonAbstractTest
}
/**
- * Create IGFS file with the given path.
- *
- * @param path File path.
- * @return IGFS file instance.
- */
- private IgfsFile file(String path) {
- return new IgfsFileImpl(new IgfsPath(path), new IgfsFileInfo(), 64 * 1024 * 1024);
- }
-
- /**
* Ensure that log file has only the following lines.
*
* @param lines Expected lines.
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
index e03e4e1..ebc0c23 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
@@ -17,17 +17,6 @@
package org.apache.ignite.testsuites;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
import junit.framework.TestSuite;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
@@ -68,6 +57,7 @@ import org.apache.ignite.internal.processors.hadoop.HadoopJobTrackerSelfTest;
import org.apache.ignite.internal.processors.hadoop.HadoopMapReduceEmbeddedSelfTest;
import org.apache.ignite.internal.processors.hadoop.HadoopMapReduceTest;
import org.apache.ignite.internal.processors.hadoop.HadoopSerializationWrapperSelfTest;
+import org.apache.ignite.internal.processors.hadoop.HadoopSnappyFullMapReduceTest;
import org.apache.ignite.internal.processors.hadoop.HadoopSnappyTest;
import org.apache.ignite.internal.processors.hadoop.HadoopSortingTest;
import org.apache.ignite.internal.processors.hadoop.HadoopSplitWrapperSelfTest;
@@ -76,7 +66,6 @@ import org.apache.ignite.internal.processors.hadoop.HadoopTasksV1Test;
import org.apache.ignite.internal.processors.hadoop.HadoopTasksV2Test;
import org.apache.ignite.internal.processors.hadoop.HadoopV2JobSelfTest;
import org.apache.ignite.internal.processors.hadoop.HadoopValidationSelfTest;
-import org.apache.ignite.internal.processors.hadoop.HadoopSnappyFullMapReduceTest;
import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopConcurrentHashMultimapSelftest;
import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopHashMapSelfTest;
import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopSkipListSelfTest;
@@ -85,6 +74,18 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
import static org.apache.ignite.testframework.GridTestUtils.modeToPermissionSet;
/**
@@ -184,6 +185,7 @@ public class IgniteHadoopTestSuite extends TestSuite {
suite.addTest(new TestSuite(ldr.loadClass(HadoopSecondaryFileSystemConfigurationTest.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(HadoopTxConfigCacheTest.class.getName())));
+
return suite;
}
[07/50] [abbrv] ignite git commit: IGNITE-2781: IGFS: Force
"copyOnRead=false" for meta and data caches.
Posted by sb...@apache.org.
IGNITE-2781: IGFS: Force "copyOnRead=false" for meta and data caches.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ff5b68ca
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ff5b68ca
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ff5b68ca
Branch: refs/heads/ignite-1837
Commit: ff5b68ca69050817794ef4b142c955a186e03de9
Parents: 219238f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Mar 14 10:19:23 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:12:48 2016 +0300
----------------------------------------------------------------------
.../main/java/org/apache/ignite/internal/IgnitionEx.java | 9 +++++++++
1 file changed, 9 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ff5b68ca/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 5153fb3..905a625 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -1950,6 +1950,15 @@ public class IgnitionEx {
}
cfg.setCacheConfiguration(cacheCfgs.toArray(new CacheConfiguration[cacheCfgs.size()]));
+
+ // Iterate over IGFS caches and set "copyOnRead" flag to "false". Note that we do this after cloning
+ // to leave user object unchanged.
+ assert cfg.getCacheConfiguration() != null;
+
+ for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) {
+ if (CU.isIgfsCache(cfg, ccfg.getName()))
+ ccfg.setCopyOnRead(false);
+ }
}
/**
[45/50] [abbrv] ignite git commit: IGNITE-2963 Fixed special case
with Date for Oracle JDBC driver.
Posted by sb...@apache.org.
IGNITE-2963 Fixed special case with Date for Oracle JDBC driver.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b2c934d7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b2c934d7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b2c934d7
Branch: refs/heads/ignite-1837
Commit: b2c934d7abe6dfe86e1d09ec592875df987f2120
Parents: 8634727
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Wed Apr 6 17:31:21 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Wed Apr 6 17:31:21 2016 +0700
----------------------------------------------------------------------
.../store/jdbc/CacheAbstractJdbcStore.java | 4 +++
.../CacheJdbcPojoStoreAbstractSelfTest.java | 28 +++++++++++++++-----
...eJdbcStoreAbstractMultithreadedSelfTest.java | 25 +++++++++++------
.../ignite/cache/store/jdbc/model/Person.java | 25 +++++++++++++++++
4 files changed, 67 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b2c934d7/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
index c5c55e1..c16f2c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
@@ -481,6 +481,10 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
return UUID.fromString((String)val);
}
+ // Workaround for known issue with Oracle JDBC driver https://community.oracle.com/thread/2355464?tstart=0
+ if (type == java.sql.Date.class && val instanceof java.util.Date)
+ return new java.sql.Date(((java.util.Date)val).getTime());
+
return val;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b2c934d7/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
index 0f40bd9..a526b8c 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStoreAbstractSelfTest.java
@@ -18,12 +18,14 @@
package org.apache.ignite.cache.store.jdbc;
import java.sql.Connection;
+import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
+import java.util.Random;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.store.jdbc.dialect.H2Dialect;
import org.apache.ignite.cache.store.jdbc.model.Person;
@@ -96,6 +98,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
stmt.executeUpdate("CREATE TABLE Person (" +
" id INTEGER PRIMARY KEY," +
" org_id INTEGER," +
+ " birthday DATE," +
" name VARCHAR(50))");
conn.commit();
@@ -179,6 +182,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
storeTypes[1].setValueFields(
new JdbcTypeField(Types.INTEGER, "ID", Integer.class, "id"),
new JdbcTypeField(Types.INTEGER, "ORG_ID", Integer.class, "orgId"),
+ new JdbcTypeField(Types.DATE, "BIRTHDAY", Date.class, "birthday"),
new JdbcTypeField(Types.VARCHAR, "NAME", String.class, "name"));
return storeTypes;
@@ -218,6 +222,8 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
protected void fillSampleDatabase(Connection conn) throws SQLException {
info("Start to fill sample database...");
+ Random rnd = new Random();
+
PreparedStatement orgStmt = conn.prepareStatement("INSERT INTO Organization(id, name, city) VALUES (?, ?, ?)");
for (int i = 0; i < ORGANIZATION_CNT; i++) {
@@ -234,12 +240,14 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
conn.commit();
- PreparedStatement prnStmt = conn.prepareStatement("INSERT INTO Person(id, org_id, name) VALUES (?, ?, ?)");
+ PreparedStatement prnStmt = conn.prepareStatement(
+ "INSERT INTO Person(id, org_id, birthday, name) VALUES (?, ?, ?, ?)");
for (int i = 0; i < PERSON_CNT; i++) {
prnStmt.setInt(1, i);
prnStmt.setInt(2, i % 100);
- prnStmt.setString(3, "name" + i);
+ prnStmt.setDate(3, Date.valueOf(String.format("%d-%d-%d", 1970 + rnd.nextInt(50), 1 + rnd.nextInt(11), 1 + rnd.nextInt(27))));
+ prnStmt.setString(4, "name" + i);
prnStmt.addBatch();
}
@@ -328,7 +336,7 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
Connection conn = getConnection();
try {
- PreparedStatement stmt = conn.prepareStatement("SELECT ID, ORG_ID, NAME FROM PERSON WHERE ID = ?");
+ PreparedStatement stmt = conn.prepareStatement("SELECT ID, ORG_ID, BIRTHDAY, NAME FROM PERSON WHERE ID = ?");
stmt.setInt(1, -1);
@@ -341,7 +349,9 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
// Test put-insert.
PersonKey key = new PersonKey(-1);
- c1.put(key, new Person(-1, -2, "Person-to-test-put-insert", 999));
+ Date testDate = Date.valueOf("2001-05-05");
+
+ c1.put(key, new Person(-1, -2, testDate, "Person-to-test-put-insert", 999));
rs = stmt.executeQuery();
@@ -349,14 +359,17 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
assertEquals(-1, rs.getInt(1));
assertEquals(-2, rs.getInt(2));
- assertEquals("Person-to-test-put-insert", rs.getString(3));
+ assertEquals(testDate, rs.getDate(3));
+ assertEquals("Person-to-test-put-insert", rs.getString(4));
assertFalse("Unexpected more data in result set", rs.next());
U.closeQuiet(rs);
// Test put-update.
- c1.put(key, new Person(-1, -3, "Person-to-test-put-update", 999));
+ testDate = Date.valueOf("2016-04-04");
+
+ c1.put(key, new Person(-1, -3, testDate, "Person-to-test-put-update", 999));
rs = stmt.executeQuery();
@@ -364,7 +377,8 @@ public abstract class CacheJdbcPojoStoreAbstractSelfTest extends GridCommonAbstr
assertEquals(-1, rs.getInt(1));
assertEquals(-3, rs.getInt(2));
- assertEquals("Person-to-test-put-update", rs.getString(3));
+ assertEquals(testDate, rs.getDate(3));
+ assertEquals("Person-to-test-put-update", rs.getString(4));
assertFalse("Unexpected more data in result set", rs.next());
http://git-wip-us.apache.org/repos/asf/ignite/blob/b2c934d7/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
index 592d1cb..e831445 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.cache.store.jdbc;
import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Connection;
+import java.sql.Date;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.ArrayList;
@@ -206,7 +207,8 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach
if (rnd.nextBoolean())
cache.put(new OrganizationKey(id), new Organization(id, "Name" + id, "City" + id));
else
- cache.put(new PersonKey(id), new Person(id, rnd.nextInt(), "Name" + id, 1));
+ cache.put(new PersonKey(id), new Person(id, rnd.nextInt(),
+ new Date(System.currentTimeMillis()), "Name" + id, 1));
}
return null;
@@ -225,7 +227,8 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach
if (rnd.nextBoolean())
cache.putIfAbsent(new OrganizationKey(id), new Organization(id, "Name" + id, "City" + id));
else
- cache.putIfAbsent(new PersonKey(id), new Person(id, rnd.nextInt(), "Name" + id, i));
+ cache.putIfAbsent(new PersonKey(id), new Person(id, rnd.nextInt(),
+ new Date(System.currentTimeMillis()), "Name" + id, i));
}
return null;
@@ -264,7 +267,8 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach
if (rnd.nextBoolean())
map.put(new OrganizationKey(id), new Organization(id, "Name" + id, "City" + id));
else
- map.put(new PersonKey(id), new Person(id, rnd.nextInt(), "Name" + id, 1));
+ map.put(new PersonKey(id), new Person(id, rnd.nextInt(),
+ new Date(System.currentTimeMillis()), "Name" + id, 1));
}
IgniteCache<Object, Object> cache = jcache();
@@ -289,17 +293,22 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach
IgniteCache<PersonKey, Person> cache = jcache();
try (Transaction tx = grid().transactions().txStart()) {
- cache.put(new PersonKey(1), new Person(1, rnd.nextInt(), "Name" + 1, 1));
- cache.put(new PersonKey(2), new Person(2, rnd.nextInt(), "Name" + 2, 2));
- cache.put(new PersonKey(3), new Person(3, rnd.nextInt(), "Name" + 3, 3));
+ cache.put(new PersonKey(1), new Person(1, rnd.nextInt(),
+ new Date(System.currentTimeMillis()), "Name" + 1, 1));
+ cache.put(new PersonKey(2), new Person(2, rnd.nextInt(),
+ new Date(System.currentTimeMillis()), "Name" + 2, 2));
+ cache.put(new PersonKey(3), new Person(3, rnd.nextInt(),
+ new Date(System.currentTimeMillis()), "Name" + 3, 3));
cache.get(new PersonKey(1));
cache.get(new PersonKey(4));
Map<PersonKey, Person> map = U.newHashMap(2);
- map.put(new PersonKey(5), new Person(5, rnd.nextInt(), "Name" + 5, 5));
- map.put(new PersonKey(6), new Person(6, rnd.nextInt(), "Name" + 6, 6));
+ map.put(new PersonKey(5), new Person(5, rnd.nextInt(),
+ new Date(System.currentTimeMillis()), "Name" + 5, 5));
+ map.put(new PersonKey(6), new Person(6, rnd.nextInt(),
+ new Date(System.currentTimeMillis()), "Name" + 6, 6));
cache.putAll(map);
http://git-wip-us.apache.org/repos/asf/ignite/blob/b2c934d7/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/Person.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/Person.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/Person.java
index 4d3714e..ddf309b 100644
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/Person.java
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/model/Person.java
@@ -18,6 +18,7 @@
package org.apache.ignite.cache.store.jdbc.model;
import java.io.Serializable;
+import java.sql.Date;
/**
* Person definition.
@@ -34,6 +35,9 @@ public class Person implements Serializable {
/** Value for orgId. */
private Integer orgId;
+ /** Value for birthday. */
+ private Date birthday;
+
/** Value for name. */
private String name;
@@ -53,11 +57,13 @@ public class Person implements Serializable {
public Person(
Integer id,
Integer orgId,
+ Date birthday,
String name,
Integer salary
) {
this.id = id;
this.orgId = orgId;
+ this.birthday = birthday;
this.name = name;
this.salary = salary;
}
@@ -99,6 +105,24 @@ public class Person implements Serializable {
}
/**
+ * Gets birthday.
+ *
+ * @return Value for birthday.
+ */
+ public Date getBirthday() {
+ return birthday;
+ }
+
+ /**
+ * Sets birthday.
+ *
+ * @param birthday New value for birthday.
+ */
+ public void setBirthday(Date birthday) {
+ this.birthday = birthday;
+ }
+
+ /**
* Gets name.
*
* @return Value for name.
@@ -172,6 +196,7 @@ public class Person implements Serializable {
@Override public String toString() {
return "Person [id=" + id +
", orgId=" + orgId +
+ ", birthday=" + birthday.getTime() +
", name=" + name +
"]";
}
[38/50] [abbrv] ignite git commit: Minor fix for Visor query metrics.
Posted by sb...@apache.org.
Minor fix for Visor query metrics.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a70d2dc4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a70d2dc4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a70d2dc4
Branch: refs/heads/ignite-1837
Commit: a70d2dc48c42f23b1ea64c2a219560efa44fb99f
Parents: 28d2a7b
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Apr 4 14:14:42 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Apr 4 14:14:42 2016 +0700
----------------------------------------------------------------------
.../internal/visor/cache/VisorCacheMetrics.java | 9 ---
.../resources/META-INF/classnames.properties | 82 +++++++++++++-------
2 files changed, 55 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a70d2dc4/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java
index 0397fe0..5b17965 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java
@@ -415,15 +415,6 @@ public class VisorCacheMetrics implements Serializable {
}
/**
- * Sets cache query metrics.
- *
- * @param qryMetrics New value for query metrics.
- */
- public void queryMetrics(VisorCacheQueryMetrics qryMetrics) {
- this.qryMetrics = qryMetrics;
- }
-
- /**
* @return Current size of evict queue used to batch up evictions.
*/
public int dhtEvictQueueCurrentSize() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/a70d2dc4/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index 9728d9c..0dd6a59 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -71,6 +71,7 @@ org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy
org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy$DefaultHolderComparator
org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy$GridConcurrentSkipListSetEx
org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy$HolderComparator
+org.apache.ignite.cache.query.CacheQueryEntryEvent
org.apache.ignite.cache.query.ContinuousQuery
org.apache.ignite.cache.query.Query
org.apache.ignite.cache.query.ScanQuery
@@ -346,26 +347,30 @@ org.apache.ignite.internal.processors.cache.GridCacheAdapter
org.apache.ignite.internal.processors.cache.GridCacheAdapter$10
org.apache.ignite.internal.processors.cache.GridCacheAdapter$11
org.apache.ignite.internal.processors.cache.GridCacheAdapter$12
-org.apache.ignite.internal.processors.cache.GridCacheAdapter$13$1
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$13
org.apache.ignite.internal.processors.cache.GridCacheAdapter$14
-org.apache.ignite.internal.processors.cache.GridCacheAdapter$15
+`org.apache.ignite.internal.processors.cache.GridCacheAdapter$15$1
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$16
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$17
org.apache.ignite.internal.processors.cache.GridCacheAdapter$2
-org.apache.ignite.internal.processors.cache.GridCacheAdapter$23$1
-org.apache.ignite.internal.processors.cache.GridCacheAdapter$25
-org.apache.ignite.internal.processors.cache.GridCacheAdapter$26$1
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$25$1
org.apache.ignite.internal.processors.cache.GridCacheAdapter$27
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$28$1
org.apache.ignite.internal.processors.cache.GridCacheAdapter$29
org.apache.ignite.internal.processors.cache.GridCacheAdapter$3
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$31
org.apache.ignite.internal.processors.cache.GridCacheAdapter$4
org.apache.ignite.internal.processors.cache.GridCacheAdapter$6
-org.apache.ignite.internal.processors.cache.GridCacheAdapter$62
-org.apache.ignite.internal.processors.cache.GridCacheAdapter$63
org.apache.ignite.internal.processors.cache.GridCacheAdapter$64
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$65
org.apache.ignite.internal.processors.cache.GridCacheAdapter$66
org.apache.ignite.internal.processors.cache.GridCacheAdapter$67
-org.apache.ignite.internal.processors.cache.GridCacheAdapter$67$1
org.apache.ignite.internal.processors.cache.GridCacheAdapter$68
-org.apache.ignite.internal.processors.cache.GridCacheAdapter$69
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$70
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$71
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$71$1
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$72
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$73
org.apache.ignite.internal.processors.cache.GridCacheAdapter$8
org.apache.ignite.internal.processors.cache.GridCacheAdapter$9
org.apache.ignite.internal.processors.cache.GridCacheAdapter$AsyncOpRetryFuture$1
@@ -376,6 +381,7 @@ org.apache.ignite.internal.processors.cache.GridCacheAdapter$GlobalClearAllNearJ
org.apache.ignite.internal.processors.cache.GridCacheAdapter$GlobalClearKeySetJob
org.apache.ignite.internal.processors.cache.GridCacheAdapter$GlobalClearKeySetNearJob
org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheClosure
+org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadCacheJob
org.apache.ignite.internal.processors.cache.GridCacheAdapter$LoadKeysCallable
org.apache.ignite.internal.processors.cache.GridCacheAdapter$SizeJob
org.apache.ignite.internal.processors.cache.GridCacheAdapter$SizeLongJob
@@ -437,9 +443,9 @@ org.apache.ignite.internal.processors.cache.GridCacheMessage
org.apache.ignite.internal.processors.cache.GridCacheMultiTxFuture$1
org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate
org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate$Mask
-org.apache.ignite.internal.processors.cache.GridCacheMvccManager$4
org.apache.ignite.internal.processors.cache.GridCacheMvccManager$5
org.apache.ignite.internal.processors.cache.GridCacheMvccManager$6
+org.apache.ignite.internal.processors.cache.GridCacheMvccManager$7
org.apache.ignite.internal.processors.cache.GridCacheMvccManager$FinishLockFuture$1
org.apache.ignite.internal.processors.cache.GridCacheOperation
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$1$1
@@ -631,6 +637,10 @@ org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomic
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$22
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$23
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$24
+org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$25
+org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$26
+org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$27
+org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$28
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$3
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$4
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache$5
@@ -782,15 +792,15 @@ org.apache.ignite.internal.processors.cache.query.GridCacheQueryFutureAdapter$2
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$1$1
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$1$2
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$10
-org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$11$1
+org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$11
+org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$12
+org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$13$1
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$2
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$3
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$4
-org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$5
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$6
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$7
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$8
-org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$9
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$CacheSqlIndexMetadata
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$CacheSqlMetadata
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$CachedResult$QueueIterator
@@ -800,6 +810,7 @@ org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$Metadata
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$MetadataJob$2
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$MetadataJob$3
org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$OffheapIteratorClosure
+org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager$PeekValueExpiryAwareIterator
org.apache.ignite.internal.processors.cache.query.GridCacheQueryMetricsAdapter
org.apache.ignite.internal.processors.cache.query.GridCacheQueryMetricsKey
org.apache.ignite.internal.processors.cache.query.GridCacheQueryRequest
@@ -818,7 +829,12 @@ org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQuer
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler$2
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler$3
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler$DeployableObject
+org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandlerV2
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager$1
+org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager$2
+org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager$3
+org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager$4
+org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager$JCacheQuery$1
org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryManager$JCacheQueryRemoteFilter
org.apache.ignite.internal.processors.cache.query.jdbc.GridCacheQueryJdbcMetadataTask
org.apache.ignite.internal.processors.cache.query.jdbc.GridCacheQueryJdbcMetadataTask$JdbcDriverMetadataJob
@@ -862,7 +878,7 @@ org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$15
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$2
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$4
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$5
-org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$8
+org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$6
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$9
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$FinishClosure
org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter$PLC1
@@ -900,17 +916,17 @@ org.apache.ignite.internal.processors.clock.GridClockDeltaSnapshotMessage
org.apache.ignite.internal.processors.clock.GridClockDeltaVersion
org.apache.ignite.internal.processors.closure.GridClosurePolicy
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C1
-org.apache.ignite.internal.processors.closure.GridClosureProcessor$C1V2
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C1MLA
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C1MLAV2
+org.apache.ignite.internal.processors.closure.GridClosureProcessor$C1V2
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2
-org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2V2
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2MLA
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2MLAV2
+org.apache.ignite.internal.processors.closure.GridClosureProcessor$C2V2
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4
-org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4V2
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4MLA
org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4MLAV2
+org.apache.ignite.internal.processors.closure.GridClosureProcessor$C4V2
org.apache.ignite.internal.processors.closure.GridClosureProcessor$T1
org.apache.ignite.internal.processors.closure.GridClosureProcessor$T10
org.apache.ignite.internal.processors.closure.GridClosureProcessor$T11
@@ -952,6 +968,7 @@ org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl$6
org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl$Buffer$1
org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl$Buffer$2
org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl$DataStreamerPda
+org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl$DefaultIoPolicyResolver
org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl$IsolatedUpdater
org.apache.ignite.internal.processors.datastreamer.DataStreamerRequest
org.apache.ignite.internal.processors.datastreamer.DataStreamerResponse
@@ -1039,19 +1056,21 @@ org.apache.ignite.internal.processors.igfs.IgfsAttributes
org.apache.ignite.internal.processors.igfs.IgfsBlockKey
org.apache.ignite.internal.processors.igfs.IgfsBlockLocationImpl
org.apache.ignite.internal.processors.igfs.IgfsBlocksMessage
+org.apache.ignite.internal.processors.igfs.IgfsColocatedMetadataAffinityKeyMapper
org.apache.ignite.internal.processors.igfs.IgfsCommunicationMessage
org.apache.ignite.internal.processors.igfs.IgfsDataManager$3
org.apache.ignite.internal.processors.igfs.IgfsDataManager$4
-org.apache.ignite.internal.processors.igfs.IgfsDataManager$6$1
-org.apache.ignite.internal.processors.igfs.IgfsDataManager$8
+org.apache.ignite.internal.processors.igfs.IgfsDataManager$5$1
+org.apache.ignite.internal.processors.igfs.IgfsDataManager$7
org.apache.ignite.internal.processors.igfs.IgfsDataManager$UpdateProcessor
org.apache.ignite.internal.processors.igfs.IgfsDeleteMessage
+org.apache.ignite.internal.processors.igfs.IgfsDirectoryInfo
+org.apache.ignite.internal.processors.igfs.IgfsEntryInfo
org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange
org.apache.ignite.internal.processors.igfs.IgfsFileImpl
org.apache.ignite.internal.processors.igfs.IgfsFileInfo
org.apache.ignite.internal.processors.igfs.IgfsFileMap
-org.apache.ignite.internal.processors.igfs.IgfsFragmentizerManager$2
-org.apache.ignite.internal.processors.igfs.IgfsFragmentizerManager$3
+org.apache.ignite.internal.processors.igfs.IgfsFileWorkerBatchCancelledException
org.apache.ignite.internal.processors.igfs.IgfsFragmentizerManager$FragmentizerCoordinator$1
org.apache.ignite.internal.processors.igfs.IgfsFragmentizerManager$IdentityHashSet
org.apache.ignite.internal.processors.igfs.IgfsFragmentizerRequest
@@ -1068,13 +1087,7 @@ org.apache.ignite.internal.processors.igfs.IgfsJobImpl
org.apache.ignite.internal.processors.igfs.IgfsListingEntry
org.apache.ignite.internal.processors.igfs.IgfsMetaManager$2
org.apache.ignite.internal.processors.igfs.IgfsMetaManager$3
-org.apache.ignite.internal.processors.igfs.IgfsMetaManager$4
-org.apache.ignite.internal.processors.igfs.IgfsMetaManager$LockFileProcessor
-org.apache.ignite.internal.processors.igfs.IgfsMetaManager$UpdateListing
-org.apache.ignite.internal.processors.igfs.IgfsMetaManager$UpdateListingEntry
-org.apache.ignite.internal.processors.igfs.IgfsMetaManager$UpdatePath
org.apache.ignite.internal.processors.igfs.IgfsMetricsAdapter
-org.apache.ignite.internal.processors.igfs.IgfsOutputStreamImpl$ReserveSpaceClosure
org.apache.ignite.internal.processors.igfs.IgfsPaths
org.apache.ignite.internal.processors.igfs.IgfsProcessor$1
org.apache.ignite.internal.processors.igfs.IgfsProcessor$2
@@ -1084,6 +1097,18 @@ org.apache.ignite.internal.processors.igfs.IgfsServerManager$1
org.apache.ignite.internal.processors.igfs.IgfsStatus
org.apache.ignite.internal.processors.igfs.IgfsSyncMessage
org.apache.ignite.internal.processors.igfs.IgfsTaskArgsImpl
+org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryCreateProcessor
+org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingAddProcessor
+org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingRemoveProcessor
+org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingReplaceProcessor
+org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileCreateProcessor
+org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileLockProcessor
+org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileRangeDeleteProcessor
+org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileRangeUpdateProcessor
+org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileReserveSpaceProcessor
+org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileUnlockProcessor
+org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdatePropertiesProcessor
+org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdateTimesProcessor
org.apache.ignite.internal.processors.job.GridJobProcessor$5
org.apache.ignite.internal.processors.job.GridJobProcessor$6
org.apache.ignite.internal.processors.job.GridJobProcessor$7
@@ -1241,6 +1266,7 @@ org.apache.ignite.internal.processors.service.GridServiceMethodNotFoundException
org.apache.ignite.internal.processors.service.GridServiceNotFoundException
org.apache.ignite.internal.processors.service.GridServiceProcessor$ServiceAssignmentsPredicate
org.apache.ignite.internal.processors.service.GridServiceProcessor$ServiceDeploymentPredicate
+org.apache.ignite.internal.processors.service.GridServiceProcessor$ServiceTopologyCallable
org.apache.ignite.internal.processors.service.GridServiceProxy
org.apache.ignite.internal.processors.service.GridServiceProxy$ServiceProxyCallable
org.apache.ignite.internal.processors.service.ServiceContextImpl
@@ -1550,6 +1576,7 @@ org.apache.ignite.internal.visor.cache.VisorCacheMetadataTask$VisorCacheMetadata
org.apache.ignite.internal.visor.cache.VisorCacheMetrics
org.apache.ignite.internal.visor.cache.VisorCacheMetricsCollectorTask
org.apache.ignite.internal.visor.cache.VisorCacheMetricsCollectorTask$VisorCacheMetricsCollectorJob
+org.apache.ignite.internal.visor.cache.VisorCacheMetricsV2
org.apache.ignite.internal.visor.cache.VisorCacheNearConfiguration
org.apache.ignite.internal.visor.cache.VisorCacheNodesTask
org.apache.ignite.internal.visor.cache.VisorCacheNodesTask$VisorCacheNodesJob
@@ -1573,6 +1600,7 @@ org.apache.ignite.internal.visor.cache.VisorCacheSwapBackupsTask$VisorCachesSwap
org.apache.ignite.internal.visor.cache.VisorCacheTypeFieldMetadata
org.apache.ignite.internal.visor.cache.VisorCacheTypeMetadata
org.apache.ignite.internal.visor.cache.VisorCacheV2
+org.apache.ignite.internal.visor.cache.VisorCacheV3
org.apache.ignite.internal.visor.compute.VisorComputeCancelSessionsTask
org.apache.ignite.internal.visor.compute.VisorComputeCancelSessionsTask$VisorComputeCancelSessionsJob
org.apache.ignite.internal.visor.compute.VisorComputeResetMetricsTask
[05/50] [abbrv] ignite git commit: IGFS: Minor refactoring.
Posted by sb...@apache.org.
IGFS: Minor refactoring.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/99028b50
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/99028b50
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/99028b50
Branch: refs/heads/ignite-1837
Commit: 99028b509c736b79faac7fb8104b1bc3cfe30720
Parents: 0e753c3
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Mar 3 12:56:55 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:12:11 2016 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsMetaManager.java | 55 +++++++++++---------
1 file changed, 29 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/99028b50/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index a149b31..0ba78c5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -480,7 +480,7 @@ public class IgfsMetaManager extends IgfsManager {
assert validTxState(false);
assert fileId != null;
- IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ IgniteInternalTx tx = startTx();
try {
// Lock file ID for this transaction.
@@ -494,7 +494,7 @@ public class IgfsMetaManager extends IgfsManager {
IgfsFileInfo newInfo = lockInfo(oldInfo, isDeleteLock);
- boolean put = metaCache.replace(fileId, oldInfo, newInfo);
+ boolean put = id2InfoPrj.replace(fileId, oldInfo, newInfo);
assert put : "Value was not stored in cache [fileId=" + fileId + ", newInfo=" + newInfo + ']';
@@ -571,7 +571,7 @@ public class IgfsMetaManager extends IgfsManager {
final boolean interrupted = Thread.interrupted();
try {
- IgfsUtils.doInTransactionWithRetries(metaCache, new IgniteOutClosureX<Void>() {
+ IgfsUtils.doInTransactionWithRetries(id2InfoPrj, new IgniteOutClosureX<Void>() {
@Override public Void applyx() throws IgniteCheckedException {
assert validTxState(true);
@@ -591,7 +591,7 @@ public class IgfsMetaManager extends IgfsManager {
IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, null, modificationTime);
- boolean put = metaCache.put(fileId, newInfo);
+ boolean put = id2InfoPrj.put(fileId, newInfo);
assert put : "Value was not stored in cache [fileId=" + fileId + ", newInfo=" + newInfo
+ ']';
@@ -847,8 +847,6 @@ public class IgfsMetaManager extends IgfsManager {
if (!id2InfoPrj.putIfAbsent(fileId, newFileInfo))
throw fsException("Failed to add file details into cache: " + newFileInfo);
- assert metaCache.get(parentId) != null;
-
id2InfoPrj.invoke(parentId, new UpdateListing(fileName, new IgfsListingEntry(newFileInfo), false));
return null;
@@ -890,7 +888,7 @@ public class IgfsMetaManager extends IgfsManager {
}
// 2. Start transaction.
- IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ IgniteInternalTx tx = startTx();
try {
// 3. Obtain the locks.
@@ -1094,9 +1092,6 @@ public class IgfsMetaManager extends IgfsManager {
" directory (file already exists) [fileId=" + fileId + ", destFileName=" + destFileName +
", destParentId=" + destParentId + ", destEntry=" + destEntry + ']'));
- assert metaCache.get(srcParentId) != null;
- assert metaCache.get(destParentId) != null;
-
// Remove listing entry from the source parent listing.
id2InfoPrj.invoke(srcParentId, new UpdateListing(srcFileName, srcEntry, true));
@@ -1116,7 +1111,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
assert validTxState(false);
- final IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ final IgniteInternalTx tx = startTx();
try {
// NB: We may lock root because its id is less than any other id:
@@ -1197,7 +1192,7 @@ public class IgfsMetaManager extends IgfsManager {
boolean added = allIds.add(TRASH_ID);
assert added;
- final IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ final IgniteInternalTx tx = startTx();
try {
final Map<IgniteUuid, IgfsFileInfo> infoMap = lockIds(allIds);
@@ -1360,7 +1355,7 @@ public class IgfsMetaManager extends IgfsManager {
assert listing != null;
assert validTxState(false);
- IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ IgniteInternalTx tx = startTx();
try {
Collection<IgniteUuid> res = new HashSet<>();
@@ -1449,7 +1444,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
assert validTxState(false);
- IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ IgniteInternalTx tx = startTx();
try {
boolean res = false;
@@ -1630,7 +1625,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
assert validTxState(false);
- IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ IgniteInternalTx tx = startTx();
try {
IgfsFileInfo info = updatePropertiesNonTx(parentId, fileId, fileName, props);
@@ -1700,8 +1695,7 @@ public class IgfsMetaManager extends IgfsManager {
if (log.isDebugEnabled())
log.debug("Update file info [fileId=" + fileId + ", c=" + c + ']');
- IgniteInternalTx tx = metaCache.isLockedByThread(fileId) ? null : metaCache.txStartEx(PESSIMISTIC,
- REPEATABLE_READ);
+ IgniteInternalTx tx = id2InfoPrj.isLockedByThread(fileId) ? null : startTx();
try {
// Lock file ID for this transaction.
@@ -1724,7 +1718,7 @@ public class IgfsMetaManager extends IgfsManager {
throw fsException("Failed to update file info (file types differ)" +
" [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", c=" + c + ']');
- boolean b = metaCache.replace(fileId, oldInfo, newInfo);
+ boolean b = id2InfoPrj.replace(fileId, oldInfo, newInfo);
assert b : "Inconsistent transaction state [oldInfo=" + oldInfo + ", newInfo=" + newInfo +
", c=" + c + ']';
@@ -1771,7 +1765,7 @@ public class IgfsMetaManager extends IgfsManager {
b = new DirectoryChainBuilder(path, props, props);
// Start TX.
- IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ IgniteInternalTx tx = startTx();
try {
final Map<IgniteUuid, IgfsFileInfo> lockedInfos = lockIds(b.idSet);
@@ -1856,7 +1850,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
validTxState(false);
- IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ IgniteInternalTx tx = startTx();
try {
Object prev = val != null ? metaCache.getAndPut(sampling, val) : metaCache.getAndRemove(sampling);
@@ -2120,7 +2114,7 @@ public class IgfsMetaManager extends IgfsManager {
assert lockedInfo != null; // We checked the lock above.
- boolean put = metaCache.put(info.id(), lockedInfo);
+ boolean put = id2InfoPrj.put(info.id(), lockedInfo);
assert put;
@@ -2707,7 +2701,7 @@ public class IgfsMetaManager extends IgfsManager {
pathIds.add(fileIds(path));
// Start pessimistic.
- IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ IgniteInternalTx tx = startTx();
try {
// Lock the very first existing parents and possibly the leaf as well.
@@ -2909,16 +2903,25 @@ public class IgfsMetaManager extends IgfsManager {
* @return Transaction state is correct.
*/
private boolean validTxState(boolean inTx) {
- boolean txState = inTx == (metaCache.tx() != null);
+ boolean txState = inTx == (id2InfoPrj.tx() != null);
assert txState : (inTx ? "Method cannot be called outside transaction " :
- "Method cannot be called in transaction ") + "[tx=" + metaCache.tx() + ", threadId=" +
+ "Method cannot be called in transaction ") + "[tx=" + id2InfoPrj.tx() + ", threadId=" +
Thread.currentThread().getId() + ']';
return txState;
}
/**
+ * Start transaction on meta cache.
+ *
+ * @return Transaction.
+ */
+ private IgniteInternalTx startTx() {
+ return metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ }
+
+ /**
* Updates last access and last modification times.
*
* @param parentId File parent ID.
@@ -2935,7 +2938,7 @@ public class IgfsMetaManager extends IgfsManager {
assert validTxState(false);
// Start pessimistic transaction.
- IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ IgniteInternalTx tx = startTx();
try {
Map<IgniteUuid, IgfsFileInfo> infoMap = lockIds(fileId, parentId);
@@ -3401,7 +3404,7 @@ public class IgfsMetaManager extends IgfsManager {
};
// Start Tx:
- IgniteInternalTx tx = metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ IgniteInternalTx tx = startTx();
try {
if (overwrite)
[29/50] [abbrv] ignite git commit: IGNITE-2811: IGFS: Optimized
properties handling.
Posted by sb...@apache.org.
IGNITE-2811: IGFS: Optimized properties handling.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e886ad0a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e886ad0a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e886ad0a
Branch: refs/heads/ignite-1837
Commit: e886ad0aa800cddb3308fa5f8400902e5879ee3c
Parents: 218132d
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Mar 22 10:28:13 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:14:07 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsEntryInfo.java | 8 +-
.../ignite/internal/processors/igfs/IgfsEx.java | 12 --
.../internal/processors/igfs/IgfsImpl.java | 2 +-
.../processors/igfs/IgfsOutputStreamImpl.java | 2 +-
.../internal/processors/igfs/IgfsUtils.java | 113 +++++++++++++++++++
.../meta/IgfsMetaDirectoryCreateProcessor.java | 8 +-
.../igfs/meta/IgfsMetaFileCreateProcessor.java | 8 +-
.../meta/IgfsMetaUpdatePropertiesProcessor.java | 5 +-
.../processors/igfs/IgfsAbstractSelfTest.java | 20 ++--
.../igfs/IgfsDualAbstractSelfTest.java | 13 ++-
.../processors/igfs/IgfsStreamsSelfTest.java | 2 +-
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 8 +-
.../hadoop/fs/v1/IgniteHadoopFileSystem.java | 19 ++--
.../hadoop/fs/v2/IgniteHadoopFileSystem.java | 21 ++--
.../hadoop/igfs/HadoopIgfsProperties.java | 11 +-
...oopFileSystemUniversalFileSystemAdapter.java | 8 +-
.../processors/hadoop/HadoopMapReduceTest.java | 5 +-
17 files changed, 187 insertions(+), 78 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
index d31ef72..45cf828 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
@@ -314,7 +314,9 @@ public abstract class IgfsEntryInfo implements Externalizable {
*/
protected void writeBinary(BinaryRawWriter out) {
BinaryUtils.writeIgniteUuid(out, id);
- out.writeMap(props);
+
+ IgfsUtils.writeProperties(out, props);
+
out.writeLong(accessTime);
out.writeLong(modificationTime);
out.writeObject(path);
@@ -327,7 +329,9 @@ public abstract class IgfsEntryInfo implements Externalizable {
*/
protected void readBinary(BinaryRawReader in) {
id = BinaryUtils.readIgniteUuid(in);
- props = in.readMap();
+
+ props = IgfsUtils.readProperties(in);
+
accessTime = in.readLong();
modificationTime = in.readLong();
path = in.readObject();
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
index cf268e0..fb67e20 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEx.java
@@ -31,18 +31,6 @@ import org.jetbrains.annotations.Nullable;
* Internal API extension for {@link org.apache.ignite.IgniteFileSystem}.
*/
public interface IgfsEx extends IgniteFileSystem {
- /** File property: user name. */
- public static final String PROP_USER_NAME = "usrName";
-
- /** File property: group name. */
- public static final String PROP_GROUP_NAME = "grpName";
-
- /** File property: permission. */
- public static final String PROP_PERMISSION = "permission";
-
- /** File property: prefer writes to local node. */
- public static final String PROP_PREFER_LOCAL_WRITES = "locWrite";
-
/**
* Stops IGFS cleaning all used resources.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/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 398428a..e3a82a5 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
@@ -121,7 +121,7 @@ public final class IgfsImpl implements IgfsEx {
private static final String PERMISSION_DFLT_VAL = "0777";
/** Default directory metadata. */
- static final Map<String, String> DFLT_DIR_META = F.asMap(PROP_PERMISSION, PERMISSION_DFLT_VAL);
+ static final Map<String, String> DFLT_DIR_META = F.asMap(IgfsUtils.PROP_PERMISSION, PERMISSION_DFLT_VAL);
/** Handshake message. */
private final IgfsPaths secondaryPaths;
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
index ef2826b..f7c85e8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
@@ -412,7 +412,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
if (!igfsCtx.configuration().isFragmentizerEnabled())
return null;
- if (!Boolean.parseBoolean(fileInfo.properties().get(IgfsEx.PROP_PREFER_LOCAL_WRITES)))
+ if (!Boolean.parseBoolean(fileInfo.properties().get(IgfsUtils.PROP_PREFER_LOCAL_WRITES)))
return null;
int blockSize = fileInfo.blockSize();
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index 94e1cef..9b813b8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -46,6 +46,7 @@ import org.apache.ignite.transactions.Transaction;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
+import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
@@ -67,6 +68,33 @@ public class IgfsUtils {
/** Constant trash concurrency level. */
public static final int TRASH_CONCURRENCY = 64;
+ /** File property: user name. */
+ public static final String PROP_USER_NAME = "usrName";
+
+ /** File property: group name. */
+ public static final String PROP_GROUP_NAME = "grpName";
+
+ /** File property: permission. */
+ public static final String PROP_PERMISSION = "permission";
+
+ /** File property: prefer writes to local node. */
+ public static final String PROP_PREFER_LOCAL_WRITES = "locWrite";
+
+ /** Generic property index. */
+ private static final byte PROP_IDX = 0;
+
+ /** User name property index. */
+ private static final byte PROP_USER_NAME_IDX = 1;
+
+ /** Group name property index. */
+ private static final byte PROP_GROUP_NAME_IDX = 2;
+
+ /** Permission property index. */
+ private static final byte PROP_PERMISSION_IDX = 3;
+
+ /** Prefer local writes property index. */
+ private static final byte PROP_PREFER_LOCAL_WRITES_IDX = 4;
+
/** Trash directory IDs. */
private static final IgniteUuid[] TRASH_IDS;
@@ -427,4 +455,89 @@ public class IgfsUtils {
else
return null;
}
+
+ /**
+ * Write entry properties. Rely on reference equality for well-known properties.
+ *
+ * @param out Writer.
+ * @param props Properties.
+ */
+ @SuppressWarnings("StringEquality")
+ public static void writeProperties(BinaryRawWriter out, @Nullable Map<String, String> props) {
+ if (props != null) {
+ out.writeInt(props.size());
+
+ for (Map.Entry<String, String> entry : props.entrySet()) {
+ String key = entry.getKey();
+
+ if (key == PROP_PERMISSION)
+ out.writeByte(PROP_PERMISSION_IDX);
+ else if (key == PROP_PREFER_LOCAL_WRITES)
+ out.writeByte(PROP_PREFER_LOCAL_WRITES_IDX);
+ else if (key == PROP_USER_NAME)
+ out.writeByte(PROP_USER_NAME_IDX);
+ else if (key == PROP_GROUP_NAME)
+ out.writeByte(PROP_GROUP_NAME_IDX);
+ else {
+ out.writeByte(PROP_IDX);
+ out.writeString(key);
+ }
+
+ out.writeString(entry.getValue());
+ }
+ }
+ else
+ out.writeInt(-1);
+ }
+
+ /**
+ * Read entry properties.
+ *
+ * @param in Reader.
+ * @return Properties.
+ */
+ @Nullable public static Map<String, String> readProperties(BinaryRawReader in) {
+ int size = in.readInt();
+
+ if (size >= 0) {
+ Map<String, String> props = new HashMap<>(size);
+
+ for (int i = 0; i < size; i++) {
+ byte idx = in.readByte();
+
+ String key;
+
+ switch (idx) {
+ case PROP_PERMISSION_IDX:
+ key = PROP_PERMISSION;
+
+ break;
+
+ case PROP_PREFER_LOCAL_WRITES_IDX:
+ key = PROP_PREFER_LOCAL_WRITES;
+
+ break;
+
+ case PROP_USER_NAME_IDX:
+ key = PROP_USER_NAME;
+
+ break;
+
+ case PROP_GROUP_NAME_IDX:
+ key = PROP_GROUP_NAME;
+
+ break;
+
+ default:
+ key = in.readString();
+ }
+
+ props.put(key, in.readString());
+ }
+
+ return props;
+ }
+ else
+ return null;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
index 907019c..5f4fe73 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
@@ -144,7 +144,9 @@ public class IgfsMetaDirectoryCreateProcessor implements EntryProcessor<IgniteUu
BinaryRawWriter out = writer.rawWriter();
out.writeLong(createTime);
- out.writeMap(props);
+
+ IgfsUtils.writeProperties(out, props);
+
out.writeString(childName);
if (childName != null)
@@ -156,7 +158,9 @@ public class IgfsMetaDirectoryCreateProcessor implements EntryProcessor<IgniteUu
BinaryRawReader in = reader.rawReader();
createTime = in.readLong();
- props = in.readMap();
+
+ props = IgfsUtils.readProperties(in);
+
childName = in.readString();
if (childName != null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
index 41745f1..9fd16aa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
@@ -138,7 +138,9 @@ public class IgfsMetaFileCreateProcessor implements EntryProcessor<IgniteUuid, I
BinaryRawWriter out = writer.rawWriter();
out.writeLong(createTime);
- out.writeMap(props);
+
+ IgfsUtils.writeProperties(out, props);
+
out.writeInt(blockSize);
BinaryUtils.writeIgniteUuid(out, affKey);
BinaryUtils.writeIgniteUuid(out, lockId);
@@ -150,7 +152,9 @@ public class IgfsMetaFileCreateProcessor implements EntryProcessor<IgniteUuid, I
BinaryRawReader in = reader.rawReader();
createTime = in.readLong();
- props = in.readMap();
+
+ props = IgfsUtils.readProperties(in);
+
blockSize = in.readInt();
affKey = BinaryUtils.readIgniteUuid(in);
lockId = BinaryUtils.readIgniteUuid(in);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
index fb4466b..e0d5b8b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
@@ -24,6 +24,7 @@ import org.apache.ignite.binary.BinaryReader;
import org.apache.ignite.binary.BinaryWriter;
import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.GridLeanMap;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -104,14 +105,14 @@ public class IgfsMetaUpdatePropertiesProcessor implements EntryProcessor<IgniteU
@Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
BinaryRawWriter out = writer.rawWriter();
- out.writeMap(props);
+ IgfsUtils.writeProperties(out, props);
}
/** {@inheritDoc} */
@Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
BinaryRawReader in = reader.rawReader();
- props = in.readMap();
+ props = IgfsUtils.readProperties(in);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
index edec572..5894fa2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
@@ -86,9 +86,6 @@ import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.igfs.IgfsMode.PRIMARY;
import static org.apache.ignite.igfs.IgfsMode.PROXY;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_GROUP_NAME;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PERMISSION;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_USER_NAME;
/**
* Test fo regular igfs operations.
@@ -803,10 +800,12 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
if (dual)
// Check only permissions because user and group will always be present in Hadoop Fs.
- assertEquals(props.get(PROP_PERMISSION), igfsSecondary.properties(SUBSUBDIR.toString()).get(PROP_PERMISSION));
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
+ igfsSecondary.properties(SUBSUBDIR.toString()).get(IgfsUtils.PROP_PERMISSION));
// We check only permission because IGFS client adds username and group name explicitly.
- assertEquals(props.get(PROP_PERMISSION), igfs.info(SUBSUBDIR).properties().get(PROP_PERMISSION));
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
+ igfs.info(SUBSUBDIR).properties().get(IgfsUtils.PROP_PERMISSION));
}
/**
@@ -824,10 +823,11 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
if (dual)
// check permission only since Hadoop Fs will always have user and group:
- assertEquals(props.get(PROP_PERMISSION), igfsSecondary.properties(DIR.toString()).get(PROP_PERMISSION));
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
+ igfsSecondary.properties(DIR.toString()).get(IgfsUtils.PROP_PERMISSION));
// We check only permission because IGFS client adds username and group name explicitly.
- assertEquals(props.get(PROP_PERMISSION), igfs.info(DIR).properties().get(PROP_PERMISSION));
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION), igfs.info(DIR).properties().get(IgfsUtils.PROP_PERMISSION));
}
/**
@@ -3026,13 +3026,13 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
Map<String, String> props = new HashMap<>();
if (username != null)
- props.put(PROP_USER_NAME, username);
+ props.put(IgfsUtils.PROP_USER_NAME, username);
if (grpName != null)
- props.put(PROP_GROUP_NAME, grpName);
+ props.put(IgfsUtils.PROP_GROUP_NAME, grpName);
if (perm != null)
- props.put(PROP_PERMISSION, perm);
+ props.put(IgfsUtils.PROP_PERMISSION, perm);
return props;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
index 6e13280..b8c8978 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsDualAbstractSelfTest.java
@@ -39,7 +39,6 @@ import java.util.concurrent.CyclicBarrier;
import static org.apache.ignite.igfs.IgfsMode.DUAL_ASYNC;
import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PERMISSION;
/**
* Tests for IGFS working in mode when remote file system exists: DUAL_SYNC, DUAL_ASYNC.
@@ -973,10 +972,12 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
checkExist(igfs, igfsSecondary, SUBSUBDIR);
// Check only permissions because user and group will always be present in Hadoop secondary filesystem.
- assertEquals(props.get(PROP_PERMISSION), igfsSecondary.properties(SUBSUBDIR.toString()).get(PROP_PERMISSION));
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
+ igfsSecondary.properties(SUBSUBDIR.toString()).get(IgfsUtils.PROP_PERMISSION));
// We check only permission because IGFS client adds username and group name explicitly.
- assertEquals(props.get(PROP_PERMISSION), igfs.info(SUBSUBDIR).properties().get(PROP_PERMISSION));
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
+ igfs.info(SUBSUBDIR).properties().get(IgfsUtils.PROP_PERMISSION));
}
/**
@@ -998,10 +999,12 @@ public abstract class IgfsDualAbstractSelfTest extends IgfsAbstractSelfTest {
checkExist(igfs, igfsSecondary, SUBSUBDIR);
// Check only permission because in case of Hadoop secondary Fs user and group will always be present:
- assertEquals(props.get(PROP_PERMISSION), igfsSecondary.properties(SUBSUBDIR.toString()).get(PROP_PERMISSION));
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
+ igfsSecondary.properties(SUBSUBDIR.toString()).get(IgfsUtils.PROP_PERMISSION));
// We check only permission because IGFS client adds username and group name explicitly.
- assertEquals(props.get(PROP_PERMISSION), igfs.info(SUBSUBDIR).properties().get(PROP_PERMISSION));
+ assertEquals(props.get(IgfsUtils.PROP_PERMISSION),
+ igfs.info(SUBSUBDIR).properties().get(IgfsUtils.PROP_PERMISSION));
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
index 10208ed..812d48b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStreamsSelfTest.java
@@ -254,7 +254,7 @@ public class IgfsStreamsSelfTest extends IgfsCommonAbstractTest {
IgniteFileSystem fs2 = grid(2).fileSystem("igfs");
try (IgfsOutputStream out = fs0.create(path, 128, false, 1, CFG_GRP_SIZE,
- F.asMap(IgfsEx.PROP_PREFER_LOCAL_WRITES, "true"))) {
+ F.asMap(IgfsUtils.PROP_PREFER_LOCAL_WRITES, "true"))) {
// 1.5 blocks
byte[] data = new byte[CFG_BLOCK_SIZE * 3 / 2];
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
index 7a4648a..dfd4611 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/IgniteHadoopIgfsSecondaryFileSystem.java
@@ -60,10 +60,6 @@ import java.util.Collections;
import java.util.Map;
import java.util.concurrent.Callable;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_GROUP_NAME;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PERMISSION;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_USER_NAME;
-
/**
* Secondary file system which delegates calls to an instance of Hadoop {@link FileSystem}.
* <p>
@@ -238,8 +234,8 @@ public class IgniteHadoopIgfsSecondaryFileSystem implements IgfsSecondaryFileSys
if (perm == null)
perm = FsPermission.getDefault();
- return F.asMap(PROP_PERMISSION, String.format("%04o", perm.toShort()), PROP_USER_NAME, status.getOwner(),
- PROP_GROUP_NAME, status.getGroup());
+ return F.asMap(IgfsUtils.PROP_PERMISSION, String.format("%04o", perm.toShort()), IgfsUtils.PROP_USER_NAME,
+ status.getOwner(), IgfsUtils.PROP_GROUP_NAME, status.getGroup());
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
index 45b968c..83991aa 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v1/IgniteHadoopFileSystem.java
@@ -86,10 +86,6 @@ import static org.apache.ignite.internal.processors.hadoop.fs.HadoopParameters.P
import static org.apache.ignite.internal.processors.hadoop.fs.HadoopParameters.PARAM_IGFS_SEQ_READS_BEFORE_PREFETCH;
import static org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsUtils.parameter;
import static org.apache.ignite.internal.processors.igfs.IgfsEx.IGFS_SCHEME;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_GROUP_NAME;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PERMISSION;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PREFER_LOCAL_WRITES;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_USER_NAME;
/**
* {@code IGFS} Hadoop 1.x file system driver over file system API. To use
@@ -509,9 +505,12 @@ public class IgniteHadoopFileSystem extends FileSystem {
}
secondaryFs.setOwner(toSecondary(p), username, grpName);
- } else if (rmtClient.update(convert(p), F.asMap(PROP_USER_NAME, username, PROP_GROUP_NAME, grpName)) == null)
+ }
+ else if (rmtClient.update(convert(p), F.asMap(IgfsUtils.PROP_USER_NAME, username,
+ IgfsUtils.PROP_GROUP_NAME, grpName)) == null) {
throw new IOException("Failed to set file permission (file not found?)" +
" [path=" + p + ", userName=" + username + ", groupName=" + grpName + ']');
+ }
}
finally {
leaveBusy();
@@ -627,7 +626,7 @@ public class IgniteHadoopFileSystem extends FileSystem {
else {
Map<String,String> propMap = permission(perm);
- propMap.put(PROP_PREFER_LOCAL_WRITES, Boolean.toString(preferLocFileWrites));
+ propMap.put(IgfsUtils.PROP_PREFER_LOCAL_WRITES, Boolean.toString(preferLocFileWrites));
// Create stream and close it in the 'finally' section if any sequential operation failed.
HadoopIgfsStreamDelegate stream = rmtClient.create(path, overwrite, colocateFileWrites,
@@ -1282,8 +1281,8 @@ public class IgniteHadoopFileSystem extends FileSystem {
file.modificationTime(),
file.accessTime(),
permission(file),
- file.property(PROP_USER_NAME, user),
- file.property(PROP_GROUP_NAME, "users"),
+ file.property(IgfsUtils.PROP_USER_NAME, user),
+ file.property(IgfsUtils.PROP_GROUP_NAME, "users"),
convert(file.path())) {
@Override public String toString() {
return "FileStatus [path=" + getPath() + ", isDir=" + isDir() + ", len=" + getLen() +
@@ -1302,7 +1301,7 @@ public class IgniteHadoopFileSystem extends FileSystem {
if (perm == null)
perm = FsPermission.getDefault();
- return F.asMap(PROP_PERMISSION, toString(perm));
+ return F.asMap(IgfsUtils.PROP_PERMISSION, toString(perm));
}
/**
@@ -1320,7 +1319,7 @@ public class IgniteHadoopFileSystem extends FileSystem {
* @return Hadoop permission.
*/
private FsPermission permission(IgfsFile file) {
- String perm = file.property(PROP_PERMISSION, null);
+ String perm = file.property(IgfsUtils.PROP_PERMISSION, null);
if (perm == null)
return FsPermission.getDefault();
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
index ac457a4..66255c9 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/v2/IgniteHadoopFileSystem.java
@@ -57,6 +57,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsHandshakeResponse;
import org.apache.ignite.internal.processors.igfs.IgfsModeResolver;
import org.apache.ignite.internal.processors.igfs.IgfsPaths;
import org.apache.ignite.internal.processors.igfs.IgfsStatus;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.A;
@@ -94,10 +95,6 @@ import static org.apache.ignite.internal.processors.hadoop.fs.HadoopParameters.P
import static org.apache.ignite.internal.processors.hadoop.fs.HadoopParameters.PARAM_IGFS_SEQ_READS_BEFORE_PREFETCH;
import static org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsUtils.parameter;
import static org.apache.ignite.internal.processors.igfs.IgfsEx.IGFS_SCHEME;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_GROUP_NAME;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PERMISSION;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PREFER_LOCAL_WRITES;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_USER_NAME;
/**
* {@code IGFS} Hadoop 2.x file system driver over file system API. To use
@@ -463,9 +460,11 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
try {
if (mode(p) == PROXY)
secondaryFileSystem().setOwner(toSecondary(p), usr, grp);
- else if (rmtClient.update(convert(p), F.asMap(PROP_USER_NAME, usr, PROP_GROUP_NAME, grp)) == null)
+ else if (rmtClient.update(convert(p), F.asMap(IgfsUtils.PROP_USER_NAME, usr,
+ IgfsUtils.PROP_GROUP_NAME, grp)) == null) {
throw new IOException("Failed to set file permission (file not found?)" +
" [path=" + p + ", username=" + usr + ", grpName=" + grp + ']');
+ }
}
finally {
leaveBusy();
@@ -579,8 +578,8 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
return os;
}
else {
- Map<String, String> permMap = F.asMap(PROP_PERMISSION, toString(perm),
- PROP_PREFER_LOCAL_WRITES, Boolean.toString(preferLocFileWrites));
+ Map<String, String> permMap = F.asMap(IgfsUtils.PROP_PERMISSION, toString(perm),
+ IgfsUtils.PROP_PREFER_LOCAL_WRITES, Boolean.toString(preferLocFileWrites));
// Create stream and close it in the 'finally' section if any sequential operation failed.
HadoopIgfsStreamDelegate stream;
@@ -1002,8 +1001,8 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
file.modificationTime(),
file.accessTime(),
permission(file),
- file.property(PROP_USER_NAME, user),
- file.property(PROP_GROUP_NAME, "users"),
+ file.property(IgfsUtils.PROP_USER_NAME, user),
+ file.property(IgfsUtils.PROP_GROUP_NAME, "users"),
convert(file.path())) {
@Override public String toString() {
return "FileStatus [path=" + getPath() + ", isDir=" + isDirectory() + ", len=" + getLen() + "]";
@@ -1021,7 +1020,7 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
if (perm == null)
perm = FsPermission.getDefault();
- return F.asMap(PROP_PERMISSION, toString(perm));
+ return F.asMap(IgfsUtils.PROP_PERMISSION, toString(perm));
}
/**
@@ -1039,7 +1038,7 @@ public class IgniteHadoopFileSystem extends AbstractFileSystem implements Closea
* @return Hadoop permission.
*/
private FsPermission permission(IgfsFile file) {
- String perm = file.property(PROP_PERMISSION, null);
+ String perm = file.property(IgfsUtils.PROP_PERMISSION, null);
if (perm == null)
return FsPermission.getDefault();
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsProperties.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsProperties.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsProperties.java
index c8929a3..90f6bca 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsProperties.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/igfs/HadoopIgfsProperties.java
@@ -20,10 +20,7 @@ package org.apache.ignite.internal.processors.hadoop.igfs;
import java.util.Map;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.ignite.IgniteException;
-
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_GROUP_NAME;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_PERMISSION;
-import static org.apache.ignite.internal.processors.igfs.IgfsEx.PROP_USER_NAME;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
/**
* Hadoop file system properties.
@@ -45,10 +42,10 @@ public class HadoopIgfsProperties {
* @throws IgniteException In case of error.
*/
public HadoopIgfsProperties(Map<String, String> props) throws IgniteException {
- usrName = props.get(PROP_USER_NAME);
- grpName = props.get(PROP_GROUP_NAME);
+ usrName = props.get(IgfsUtils.PROP_USER_NAME);
+ grpName = props.get(IgfsUtils.PROP_GROUP_NAME);
- String permStr = props.get(PROP_PERMISSION);
+ String permStr = props.get(IgfsUtils.PROP_PERMISSION);
if (permStr != null) {
try {
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
index 5b6fd81..44b8f40 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/HadoopFileSystemUniversalFileSystemAdapter.java
@@ -29,7 +29,7 @@ import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.hadoop.fs.HadoopFileSystemFactory;
import org.apache.ignite.internal.processors.hadoop.igfs.HadoopIgfsUtils;
-import org.apache.ignite.internal.processors.igfs.IgfsEx;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.processors.igfs.UniversalFileSystemAdapter;
/**
@@ -84,12 +84,12 @@ public class HadoopFileSystemUniversalFileSystemAdapter implements UniversalFile
Map<String,String> m = new HashMap<>(3); // max size == 4
- m.put(IgfsEx.PROP_USER_NAME, status.getOwner());
- m.put(IgfsEx.PROP_GROUP_NAME, status.getGroup());
+ m.put(IgfsUtils.PROP_USER_NAME, status.getOwner());
+ m.put(IgfsUtils.PROP_GROUP_NAME, status.getGroup());
FsPermission perm = status.getPermission();
- m.put(IgfsEx.PROP_PERMISSION, "0" + perm.getUserAction().ordinal() + perm.getGroupAction().ordinal() +
+ m.put(IgfsUtils.PROP_PERMISSION, "0" + perm.getUserAction().ordinal() + perm.getGroupAction().ordinal() +
perm.getOtherAction().ordinal());
return m;
http://git-wip-us.apache.org/repos/asf/ignite/blob/e886ad0a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java
index 7fd8272..4426847 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/HadoopMapReduceTest.java
@@ -52,6 +52,7 @@ import org.apache.ignite.internal.processors.hadoop.counter.HadoopPerformanceCou
import org.apache.ignite.internal.processors.hadoop.examples.HadoopWordCount1;
import org.apache.ignite.internal.processors.hadoop.examples.HadoopWordCount2;
import org.apache.ignite.internal.processors.igfs.IgfsEx;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.T2;
@@ -110,7 +111,7 @@ public class HadoopMapReduceTest extends HadoopAbstractWordCountTest {
* @return The owner.
*/
private static String getOwner(IgfsEx i, IgfsPath p) {
- return i.info(p).property(IgfsEx.PROP_USER_NAME);
+ return i.info(p).property(IgfsUtils.PROP_USER_NAME);
}
/**
@@ -122,7 +123,7 @@ public class HadoopMapReduceTest extends HadoopAbstractWordCountTest {
private static String getOwnerSecondary(final IgfsSecondaryFileSystem secFs, final IgfsPath p) {
return IgfsUserContext.doAs(USER, new IgniteOutClosure<String>() {
@Override public String apply() {
- return secFs.info(p).property(IgfsEx.PROP_USER_NAME);
+ return secFs.info(p).property(IgfsUtils.PROP_USER_NAME);
}
});
}
[04/50] [abbrv] ignite git commit: IGNITE-2575: Added validation of
IGFS endpoint port value. This closes #469.
Posted by sb...@apache.org.
IGNITE-2575: Added validation of IGFS endpoint port value. This closes #469.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0e753c38
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0e753c38
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0e753c38
Branch: refs/heads/ignite-1837
Commit: 0e753c38a986cbd46eb24845808ec1d0fc7d1dea
Parents: 85a675b
Author: dkarachentsev <dk...@gridgain.com>
Authored: Wed Feb 10 12:38:43 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:12:05 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsProcessor.java | 14 ++++++++++
.../igfs/IgfsProcessorValidationSelfTest.java | 27 ++++++++++++++++++++
2 files changed, 41 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0e753c38/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
index 21446e1..1b60252 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
@@ -67,6 +67,12 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
/** Null IGFS name. */
private static final String NULL_NAME = UUID.randomUUID().toString();
+ /** Min available TCP port. */
+ private static final int MIN_TCP_PORT = 1;
+
+ /** Max available TCP port. */
+ private static final int MAX_TCP_PORT = 0xFFFF;
+
/** Converts context to IGFS. */
private static final IgniteClosure<IgfsContext,IgniteFileSystem> CTX_TO_IGFS = new C1<IgfsContext, IgniteFileSystem>() {
@Override public IgniteFileSystem apply(IgfsContext igfsCtx) {
@@ -307,6 +313,14 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
throw new IgniteCheckedException("Invalid IGFS data cache configuration (key affinity mapper class should be " +
IgfsGroupDataBlocksKeyMapper.class.getSimpleName() + "): " + cfg);
+ if (cfg.getIpcEndpointConfiguration() != null) {
+ final int tcpPort = cfg.getIpcEndpointConfiguration().getPort();
+
+ if (!(tcpPort >= MIN_TCP_PORT && tcpPort <= MAX_TCP_PORT))
+ throw new IgniteCheckedException("IGFS endpoint TCP port is out of range [" + MIN_TCP_PORT +
+ ".." + MAX_TCP_PORT + "]: " + tcpPort);
+ }
+
long maxSpaceSize = cfg.getMaxSpaceSize();
if (maxSpaceSize > 0) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/0e753c38/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java
index 11a80af..27f47e8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java
@@ -23,6 +23,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
+import org.apache.ignite.igfs.IgfsIpcEndpointConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
@@ -442,6 +443,32 @@ public class IgfsProcessorValidationSelfTest extends IgfsCommonAbstractTest {
}
/**
+ * @throws Exception If failed.
+ */
+ public void testInvalidEndpointTcpPort() throws Exception {
+ final String failMsg = "IGFS endpoint TCP port is out of range";
+ g1Cfg.setCacheConfiguration(concat(dataCaches(1024), metaCaches(), CacheConfiguration.class));
+
+ final String igfsCfgName = "igfs-cfg";
+ final IgfsIpcEndpointConfiguration igfsEndpointCfg = new IgfsIpcEndpointConfiguration();
+ igfsEndpointCfg.setPort(0);
+ g1IgfsCfg1.setName(igfsCfgName);
+ g1IgfsCfg1.setIpcEndpointConfiguration(igfsEndpointCfg);
+
+ checkGridStartFails(g1Cfg, failMsg, true);
+
+ igfsEndpointCfg.setPort(-1);
+ g1IgfsCfg1.setIpcEndpointConfiguration(igfsEndpointCfg);
+
+ checkGridStartFails(g1Cfg, failMsg, true);
+
+ igfsEndpointCfg.setPort(65536);
+ g1IgfsCfg1.setIpcEndpointConfiguration(igfsEndpointCfg);
+
+ checkGridStartFails(g1Cfg, failMsg, true);
+ }
+
+ /**
* Checks that the given grid configuration will lead to {@link IgniteCheckedException} upon grid startup.
*
* @param cfg Grid configuration to check.
[16/50] [abbrv] ignite git commit: IGNITE-2860: IGFS: Reworked base
meta operations.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a93c3bf/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
index 19a91ad..26424f0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
@@ -17,11 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.Callable;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.FileSystemConfiguration;
@@ -29,7 +24,6 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.igfs.IgfsException;
import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
import org.apache.ignite.igfs.IgfsPath;
-import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteUuid;
@@ -38,6 +32,12 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.jetbrains.annotations.Nullable;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -142,7 +142,7 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
assertEmpty(mgr.directoryListing(ROOT_ID));
assertTrue(mgr.mkdirs(new IgfsPath("/dir"), IgfsImpl.DFLT_DIR_META));
- assertNotNull(mgr.create(new IgfsPath("/file"), false, false, null, 400, null, false, null));
+ assertNotNull(mgr.create(new IgfsPath("/file"), null, false, 400, null, false, null));
IgfsListingEntry dirEntry = mgr.directoryListing(ROOT_ID).get("dir");
assertNotNull(dirEntry);
@@ -214,7 +214,7 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
private IgfsFileInfo createFileAndGetInfo(String path) throws IgniteCheckedException {
IgfsPath p = path(path);
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = mgr.create(p, false, false, null, 400, null, false, null);
+ IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = mgr.create(p, null, false, 400, null, false, null);
assert t2 != null;
assert !t2.get1().isDirectory();
@@ -297,14 +297,13 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
assertEquals(Arrays.asList(ROOT_ID, null, null, null, null), mgr.fileIds(new IgfsPath("/f7/a/b/f6")));
// One of participated files does not exist in cache.
- expectsRenameFail("/b8", "/b2", "Failed to perform move because some path component was not found.");
+ expectsRenameFail("/b8", "/b2");
- expectsRenameFail("/a", "/b/b8", "Failed to perform move because some path component was not found.");
+ expectsRenameFail("/a", "/b/b8");
- expectsRenameFail("/a/f2", "/a/b/f3", "Failed to perform move because destination points to existing file");
+ expectsRenameFail("/a/f2", "/a/b/f3");
- expectsRenameFail("/a/k", "/a/b/", "Failed to perform move because destination already " +
- "contains entry with the same name existing file");
+ expectsRenameFail("/a/k", "/a/b/");
mgr.delete(a.id(), "k", z.id());
mgr.delete(b.id(), "k", k.id());
@@ -414,17 +413,15 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
/**
* Test expected failures for 'move file' operation.
- *
- * @param msg Failure message if expected exception was not thrown.
*/
- private void expectsRenameFail(final String src, final String dst, @Nullable String msg) {
+ private void expectsRenameFail(final String src, final String dst) {
Throwable err = assertThrowsInherited(log, new Callable() {
@Override public Object call() throws Exception {
mgr.move(new IgfsPath(src), new IgfsPath(dst));
return null;
}
- }, IgfsException.class, msg);
+ }, IgfsException.class, null);
assertTrue("Unexpected cause: " + err, err instanceof IgfsException);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a93c3bf/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
index f567099..4112846 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
@@ -626,17 +626,17 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
/** @throws Exception If failed. */
public void testCreateOpenAppend() throws Exception {
// Error - path points to root directory.
- assertCreateFails("/", false, "Failed to create file (path points to an existing directory)");
+ assertCreateFails("/", false);
// Create directories.
igfs.mkdirs(path("/A/B1/C1"));
// Error - path points to directory.
for (String path : Arrays.asList("/A", "/A/B1", "/A/B1/C1")) {
- assertCreateFails(path, false, "Failed to create file (path points to an existing directory)");
- assertCreateFails(path, true, "Failed to create file (path points to an existing directory)");
- assertAppendFails(path, false, "Failed to open file (path points to an existing directory)");
- assertAppendFails(path, true, "Failed to open file (path points to an existing directory)");
+ assertCreateFails(path, false);
+ assertCreateFails(path, true);
+ assertAppendFails(path, false);
+ assertAppendFails(path, true);
assertOpenFails(path, "Failed to open file (not a file)");
}
@@ -647,13 +647,13 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
for (String path : Arrays.asList("/A/a", "/A/B1/a", "/A/B1/C1/a")) {
// Error - file doesn't exist.
assertOpenFails(path, "File not found");
- assertAppendFails(path, false, "File not found");
+ assertAppendFails(path, false);
// Create new and write.
assertEquals(text1, create(path, false, text1));
// Error - file already exists.
- assertCreateFails(path, false, "Failed to create file (file already exists and overwrite flag is false)");
+ assertCreateFails(path, false);
// Overwrite existent.
assertEquals(text2, create(path, true, text2));
@@ -669,7 +669,7 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
// Error - file doesn't exist.
assertOpenFails(path, "File not found");
- assertAppendFails(path, false, "File not found");
+ assertAppendFails(path, false);
// Create with append.
assertEquals(text1, append(path, true, text1));
@@ -927,16 +927,15 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
*
* @param path File path to create.
* @param overwrite Overwrite file if it already exists. Note: you cannot overwrite an existent directory.
- * @param msg Failure message if expected exception was not thrown.
*/
- private void assertCreateFails(final String path, final boolean overwrite, @Nullable String msg) {
+ private void assertCreateFails(final String path, final boolean overwrite) {
GridTestUtils.assertThrowsInherited(log, new Callable<Object>() {
@Override public Object call() throws Exception {
igfs.create(path(path), overwrite);
return false;
}
- }, IgfsException.class, msg);
+ }, IgfsException.class, null);
}
/**
@@ -944,16 +943,15 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
*
* @param path File path to append.
* @param create Create file if it doesn't exist yet.
- * @param msg Failure message if expected exception was not thrown.
*/
- private void assertAppendFails(final String path, final boolean create, @Nullable String msg) {
+ private void assertAppendFails(final String path, final boolean create) {
GridTestUtils.assertThrowsInherited(log, new Callable<Object>() {
@Override public Object call() throws Exception {
igfs.append(path(path), create);
return false;
}
- }, IgfsException.class, msg);
+ }, IgfsException.class, null);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a93c3bf/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
index 56559cb..eff44f2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
@@ -17,9 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.BufferedWriter;
-import java.io.OutputStreamWriter;
-import java.util.concurrent.Callable;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -35,6 +32,10 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
+import java.io.BufferedWriter;
+import java.io.OutputStreamWriter;
+import java.util.concurrent.Callable;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -85,7 +86,7 @@ public class IgfsStartCacheTest extends IgfsCommonAbstractTest {
metaCacheCfg.setName("metaCache");
metaCacheCfg.setCacheMode(REPLICATED);
metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
- dataCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
+ metaCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
cfg.setFileSystemConfiguration(igfsCfg);
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a93c3bf/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgfsEventsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgfsEventsTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgfsEventsTestSuite.java
index c013cae..1dd665a 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgfsEventsTestSuite.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/igfs/IgfsEventsTestSuite.java
@@ -46,11 +46,11 @@ public class IgfsEventsTestSuite extends TestSuite {
TestSuite suite = new TestSuite("Ignite FS Events Test Suite");
- suite.addTest(new TestSuite(ldr.loadClass(ShmemPrivate.class.getName())));
+ suite.addTest(new TestSuite(ldr.loadClass(ShmemPrimary.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(ShmemDualSync.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(ShmemDualAsync.class.getName())));
- suite.addTest(new TestSuite(ldr.loadClass(LoopbackPrivate.class.getName())));
+ suite.addTest(new TestSuite(ldr.loadClass(LoopbackPrimary.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(LoopbackDualSync.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(LoopbackDualAsync.class.getName())));
@@ -66,7 +66,7 @@ public class IgfsEventsTestSuite extends TestSuite {
TestSuite suite = new TestSuite("Ignite IGFS Events Test Suite Noarch Only");
- suite.addTest(new TestSuite(ldr.loadClass(LoopbackPrivate.class.getName())));
+ suite.addTest(new TestSuite(ldr.loadClass(LoopbackPrimary.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(LoopbackDualSync.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(LoopbackDualAsync.class.getName())));
@@ -76,7 +76,7 @@ public class IgfsEventsTestSuite extends TestSuite {
/**
* Shared memory IPC in PRIVATE mode.
*/
- public static class ShmemPrivate extends IgfsEventsAbstractSelfTest {
+ public static class ShmemPrimary extends IgfsEventsAbstractSelfTest {
/** {@inheritDoc} */
@Override protected FileSystemConfiguration getIgfsConfiguration() throws IgniteCheckedException {
FileSystemConfiguration igfsCfg = super.getIgfsConfiguration();
@@ -95,7 +95,7 @@ public class IgfsEventsTestSuite extends TestSuite {
/**
* Loopback socket IPS in PRIVATE mode.
*/
- public static class LoopbackPrivate extends IgfsEventsAbstractSelfTest {
+ public static class LoopbackPrimary extends IgfsEventsAbstractSelfTest {
/** {@inheritDoc} */
@Override protected FileSystemConfiguration getIgfsConfiguration() throws IgniteCheckedException {
FileSystemConfiguration igfsCfg = super.getIgfsConfiguration();
[32/50] [abbrv] ignite git commit: IGFS: Added misssing "final"
modifiers to FileSystemConfiguration defaults.
Posted by sb...@apache.org.
IGFS: Added misssing "final" modifiers to FileSystemConfiguration defaults.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/26f11573
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/26f11573
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/26f11573
Branch: refs/heads/ignite-1837
Commit: 26f115734e7262d4b4b60f1c6016783f67c66986
Parents: b286fac
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Mar 22 12:46:23 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:14:20 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/configuration/FileSystemConfiguration.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/26f11573/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
index 0d7f3cc..518bbf6 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
@@ -86,10 +86,10 @@ public class FileSystemConfiguration {
public static final boolean DFLT_INIT_DFLT_PATH_MODES = true;
/** Default value of metadata co-location flag. */
- public static boolean DFLT_COLOCATE_META = true;
+ public static final boolean DFLT_COLOCATE_META = true;
/** Default value of relaxed consistency flag. */
- public static boolean DFLT_RELAXED_CONSISTENCY = true;
+ public static final boolean DFLT_RELAXED_CONSISTENCY = true;
/** IGFS instance name. */
private String name;
[18/50] [abbrv] ignite git commit: IGNITE-2834: IGFS: Implemented
optional metadata co-location.
Posted by sb...@apache.org.
IGNITE-2834: IGFS: Implemented optional metadata co-location.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8e9e790e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8e9e790e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8e9e790e
Branch: refs/heads/ignite-1837
Commit: 8e9e790e482b8911142bf8b21fa3ad7267a62db6
Parents: 8a93c3b
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Mar 18 17:07:58 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:35 2016 +0300
----------------------------------------------------------------------
.../configuration/FileSystemConfiguration.java | 47 ++++++++++++++++
.../org/apache/ignite/internal/IgnitionEx.java | 10 ++--
.../processors/cache/GridCacheUtils.java | 14 +----
.../IgfsColocatedMetadataAffinityKeyMapper.java | 47 ++++++++++++++++
.../internal/processors/igfs/IgfsUtils.java | 57 ++++++++++++++++++++
5 files changed, 157 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e9e790e/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
index 1a9c0fe..99d364e 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
@@ -19,6 +19,7 @@ package org.apache.ignite.configuration;
import java.util.Map;
import java.util.concurrent.ExecutorService;
+import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.igfs.IgfsIpcEndpointConfiguration;
import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystem;
@@ -83,6 +84,9 @@ public class FileSystemConfiguration {
/** Default value of whether to initialize default path modes. */
public static final boolean DFLT_INIT_DFLT_PATH_MODES = true;
+ /** Default value of metadata co-location flag. */
+ public static boolean DFLT_COLOCATE_META = true;
+
/** IGFS instance name. */
private String name;
@@ -164,6 +168,9 @@ public class FileSystemConfiguration {
/** Whether to initialize default path modes. */
private boolean initDfltPathModes = DFLT_INIT_DFLT_PATH_MODES;
+ /** Metadata co-location flag. */
+ private boolean colocateMeta = DFLT_COLOCATE_META;
+
/**
* Constructs default configuration.
*/
@@ -184,6 +191,7 @@ public class FileSystemConfiguration {
*/
blockSize = cfg.getBlockSize();
bufSize = cfg.getStreamBufferSize();
+ colocateMeta = cfg.isColocateMetadata();
dataCacheName = cfg.getDataCacheName();
dfltMode = cfg.getDefaultMode();
dualModeMaxPendingPutsSize = cfg.getDualModeMaxPendingPutsSize();
@@ -830,6 +838,45 @@ public class FileSystemConfiguration {
this.initDfltPathModes = initDfltPathModes;
}
+ /**
+ * Get whether to co-locate metadata on a single node.
+ * <p>
+ * Normally Ignite spread ownership of particular keys among all cache nodes. Transaction with keys owned by
+ * different nodes will produce more network traffic and will require more time to complete comparing to
+ * transaction with keys owned only by a single node.
+ * <p>
+ * IGFS stores information about file system structure (metadata) inside a transactional cache configured through
+ * {@link #getMetaCacheName()} property. Metadata updates caused by operations on IGFS usually require several
+ * intearnal keys to be updated. As IGFS metadata cache usually operates in {@link CacheMode#REPLICATED} mode,
+ * meaning that all nodes have all metadata locally, it makes sense to give a hint to Ignite to co-locate
+ * ownership of all metadata keys on a single node. This will decrease amount of network trips required to update
+ * metadata and hence could improve performance.
+ * <p>
+ * This property should be disabled if you see excessive CPU and network load on a single node, which
+ * degrades performance and cannot be explained by business logic of your application.
+ * <p>
+ * This settings is only used if metadata cache is configured in {@code CacheMode#REPLICATED} mode. Otherwise it
+ * is ignored.
+ * <p>
+ * Defaults to {@link #DFLT_COLOCATE_META}.
+ *
+ * @return {@code True} if metadata co-location is enabled.
+ */
+ public boolean isColocateMetadata() {
+ return colocateMeta;
+ }
+
+ /**
+ * Set metadata co-location flag.
+ * <p>
+ * See {@link #isColocateMetadata()} for more information.
+ *
+ * @param colocateMeta Whether metadata co-location is enabled.
+ */
+ public void setColocateMetadata(boolean colocateMeta) {
+ this.colocateMeta = colocateMeta;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(FileSystemConfiguration.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e9e790e/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 905a625..68ad8b6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -62,6 +62,7 @@ import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.TransactionConfiguration;
import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.processors.resource.GridSpringResourceContext;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.IgniteUtils;
@@ -1951,14 +1952,11 @@ public class IgnitionEx {
cfg.setCacheConfiguration(cacheCfgs.toArray(new CacheConfiguration[cacheCfgs.size()]));
- // Iterate over IGFS caches and set "copyOnRead" flag to "false". Note that we do this after cloning
- // to leave user object unchanged.
+ // Iterate over IGFS caches and prepare their configurations if needed.
assert cfg.getCacheConfiguration() != null;
- for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) {
- if (CU.isIgfsCache(cfg, ccfg.getName()))
- ccfg.setCopyOnRead(false);
- }
+ for (CacheConfiguration ccfg : cfg.getCacheConfiguration())
+ IgfsUtils.prepareCacheConfiguration(cfg, ccfg);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e9e790e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 66fa8dd..6ce5735 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -73,6 +73,7 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionEx;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.util.lang.IgniteInClosureX;
import org.apache.ignite.internal.util.typedef.C1;
@@ -1403,18 +1404,7 @@ public class GridCacheUtils {
* @return {@code True} in this is IGFS data or meta cache.
*/
public static boolean isIgfsCache(IgniteConfiguration cfg, @Nullable String cacheName) {
- FileSystemConfiguration[] igfsCfgs = cfg.getFileSystemConfiguration();
-
- if (igfsCfgs != null) {
- for (FileSystemConfiguration igfsCfg : igfsCfgs) {
- // IGFS config probably has not been validated yet => possible NPE, so we check for null.
- if (igfsCfg != null &&
- (F.eq(cacheName, igfsCfg.getDataCacheName()) || F.eq(cacheName, igfsCfg.getMetaCacheName())))
- return true;
- }
- }
-
- return false;
+ return IgfsUtils.isIgfsCache(cfg, cacheName);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e9e790e/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsColocatedMetadataAffinityKeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsColocatedMetadataAffinityKeyMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsColocatedMetadataAffinityKeyMapper.java
new file mode 100644
index 0000000..d8c10b0
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsColocatedMetadataAffinityKeyMapper.java
@@ -0,0 +1,47 @@
+/*
+ * 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.cache.affinity.AffinityKeyMapper;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Special implementation of affinity mapper which maps all metadata to the same primary.
+ */
+public class IgfsColocatedMetadataAffinityKeyMapper implements AffinityKeyMapper {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Affinity. */
+ private static final Integer AFF = 1;
+
+ /** {@inheritDoc} */
+ @Override public Object affinityKey(Object key) {
+ return AFF;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void reset() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsColocatedMetadataAffinityKeyMapper.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e9e790e/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index b176e21..ef7d5c7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -20,9 +20,12 @@ package org.apache.ignite.internal.processors.igfs;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.FileSystemConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.IgfsEvent;
import org.apache.ignite.igfs.IgfsException;
import org.apache.ignite.igfs.IgfsPath;
@@ -264,4 +267,58 @@ public class IgfsUtils {
if (evts.isRecordable(type))
evts.record(new IgfsEvent(path, locNode, type));
}
+
+ /**
+ * @param cfg Grid configuration.
+ * @param cacheName Cache name.
+ * @return {@code True} in this is IGFS data or meta cache.
+ */
+ public static boolean isIgfsCache(IgniteConfiguration cfg, @Nullable String cacheName) {
+ FileSystemConfiguration[] igfsCfgs = cfg.getFileSystemConfiguration();
+
+ if (igfsCfgs != null) {
+ for (FileSystemConfiguration igfsCfg : igfsCfgs) {
+ // IGFS config probably has not been validated yet => possible NPE, so we check for null.
+ if (igfsCfg != null) {
+ if (F.eq(cacheName, igfsCfg.getDataCacheName()) || F.eq(cacheName, igfsCfg.getMetaCacheName()))
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Prepare cache configuration if this is IGFS meta or data cache.
+ *
+ * @param cfg Configuration.
+ * @param ccfg Cache configuration.
+ */
+ public static void prepareCacheConfiguration(IgniteConfiguration cfg, CacheConfiguration ccfg) {
+ FileSystemConfiguration[] igfsCfgs = cfg.getFileSystemConfiguration();
+
+ if (igfsCfgs != null) {
+ for (FileSystemConfiguration igfsCfg : igfsCfgs) {
+ if (igfsCfg != null) {
+ if (F.eq(ccfg.getName(), igfsCfg.getMetaCacheName())) {
+ ccfg.setCopyOnRead(false);
+
+ // Set co-located affinity mapper if needed.
+ if (igfsCfg.isColocateMetadata() && ccfg.getCacheMode() == CacheMode.REPLICATED &&
+ ccfg.getAffinityMapper() == null)
+ ccfg.setAffinityMapper(new IgfsColocatedMetadataAffinityKeyMapper());
+
+ return;
+ }
+
+ if (F.eq(ccfg.getName(), igfsCfg.getDataCacheName())) {
+ ccfg.setCopyOnRead(false);
+
+ return;
+ }
+ }
+ }
+ }
+ }
}
\ No newline at end of file
[24/50] [abbrv] ignite git commit: IGNITE-2861: IGFS: Moved metadata
processors into separate top-level classes to simplify code. Also cleaned up
IgfsMetaManager from unused code.
Posted by sb...@apache.org.
IGNITE-2861: IGFS: Moved metadata processors into separate top-level classes to simplify code. Also cleaned up IgfsMetaManager from unused code.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9a4b5bd7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9a4b5bd7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9a4b5bd7
Branch: refs/heads/ignite-1837
Commit: 9a4b5bd720c5ed1f96b82a457fa3eaed1bdbb132
Parents: 8de40f2
Author: thatcoach <pp...@list.ru>
Authored: Sat Mar 19 21:13:35 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:45 2016 +0300
----------------------------------------------------------------------
.../igfs/IgfsFragmentizerManager.java | 141 +--
.../processors/igfs/IgfsMetaManager.java | 1142 ++----------------
.../internal/processors/igfs/IgfsPathIds.java | 2 +-
.../meta/IgfsMetaDirectoryCreateProcessor.java | 117 ++
.../IgfsMetaDirectoryListingAddProcessor.java | 92 ++
...IgfsMetaDirectoryListingRemoveProcessor.java | 89 ++
...gfsMetaDirectoryListingReplaceProcessor.java | 84 ++
.../igfs/meta/IgfsMetaFileCreateProcessor.java | 110 ++
.../igfs/meta/IgfsMetaFileLockProcessor.java | 63 +
.../meta/IgfsMetaFileRangeDeleteProcessor.java | 74 ++
.../meta/IgfsMetaFileRangeUpdateProcessor.java | 81 ++
.../meta/IgfsMetaFileReserveSpaceProcessor.java | 75 ++
.../igfs/meta/IgfsMetaFileUnlockProcessor.java | 60 +
.../igfs/meta/IgfsMetaUpdatePathProcessor.java | 66 +
.../meta/IgfsMetaUpdatePropertiesProcessor.java | 78 ++
.../igfs/meta/IgfsMetaUpdateTimesProcessor.java | 68 ++
16 files changed, 1155 insertions(+), 1187 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
index 194a8ac..99e7cd6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
@@ -26,13 +26,14 @@ import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.managers.communication.GridMessageListener;
import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileRangeDeleteProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileRangeUpdateProcessor;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.GridSpinReadWriteLock;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.P1;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.LT;
-import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.util.worker.GridWorker;
import org.apache.ignite.lang.IgniteBiTuple;
@@ -40,13 +41,6 @@ import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.thread.IgniteThread;
import org.jetbrains.annotations.Nullable;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.EntryProcessorException;
-import javax.cache.processor.MutableEntry;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
@@ -294,7 +288,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
case RANGE_STATUS_INITIAL: {
// Mark range as moving.
updated = igfsCtx.meta().updateInfo(
- fileId, new RangeUpdateProcessor(range, RANGE_STATUS_MOVING));
+ fileId, new IgfsMetaFileRangeUpdateProcessor(range, RANGE_STATUS_MOVING));
if (updated == null) {
igfsCtx.data().cleanBlocks(fileInfo, range, true);
@@ -311,7 +305,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
// Mark range as moved.
updated = igfsCtx.meta().updateInfo(
- fileId, new RangeUpdateProcessor(range, RANGE_STATUS_MOVED));
+ fileId, new IgfsMetaFileRangeUpdateProcessor(range, RANGE_STATUS_MOVED));
if (updated == null) {
igfsCtx.data().cleanBlocks(fileInfo, range, true);
@@ -327,7 +321,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
igfsCtx.data().cleanBlocks(fileInfo, range, false);
// Remove range from map.
- updated = igfsCtx.meta().updateInfo(fileId, new RangeDeleteProcessor(range));
+ updated = igfsCtx.meta().updateInfo(fileId, new IgfsMetaFileRangeDeleteProcessor(range));
if (updated == null)
igfsCtx.data().cleanBlocks(fileInfo, range, true);
@@ -343,131 +337,6 @@ public class IgfsFragmentizerManager extends IgfsManager {
}
/**
- * Update range processor.
- */
- private static class RangeUpdateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Range. */
- private IgfsFileAffinityRange range;
-
- /** Status. */
- private int status;
-
- /**
- * Constructor.
- */
- public RangeUpdateProcessor() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param range Range.
- * @param status Status.
- */
- public RangeUpdateProcessor(IgfsFileAffinityRange range, int status) {
- this.range = range;
- this.status = status;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
- throws EntryProcessorException {
- IgfsEntryInfo oldInfo = entry.getValue();
-
- IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
-
- newMap.updateRangeStatus(range, status);
-
- IgfsEntryInfo newInfo = oldInfo.fileMap(newMap);
-
- entry.setValue(newInfo);
-
- return newInfo;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(range);
- out.writeInt(status);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- range = (IgfsFileAffinityRange)in.readObject();
- status = in.readInt();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(RangeUpdateProcessor.class, this);
- }
- }
-
- /**
- * Delete range processor.
- */
- private static class RangeDeleteProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Range. */
- private IgfsFileAffinityRange range;
-
- /**
- * Constructor.
- */
- public RangeDeleteProcessor() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param range Range.
- */
- public RangeDeleteProcessor(IgfsFileAffinityRange range) {
- this.range = range;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
- throws EntryProcessorException {
- IgfsEntryInfo oldInfo = entry.getValue();
-
- IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
-
- newMap.deleteRange(range);
-
- IgfsEntryInfo newInfo = oldInfo.fileMap(newMap);
-
- entry.setValue(newInfo);
-
- return newInfo;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(range);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- range = (IgfsFileAffinityRange)in.readObject();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(RangeDeleteProcessor.class, this);
- }
- }
-
- /**
* Fragmentizer coordinator thread.
*/
private class FragmentizerCoordinator extends GridWorker implements GridLocalEventListener, GridMessageListener {
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index d66d9be..1aa49ed 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -44,7 +44,17 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheInternal;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
-import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryCreateProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileCreateProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileLockProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileReserveSpaceProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileUnlockProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingAddProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingRemoveProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingReplaceProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdatePathProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdatePropertiesProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdateTimesProcessor;
import org.apache.ignite.internal.util.GridLeanMap;
import org.apache.ignite.internal.util.GridSpinBusyLock;
import org.apache.ignite.internal.util.lang.GridClosureException;
@@ -52,22 +62,15 @@ import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
-import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionIsolation;
import org.jetbrains.annotations.Nullable;
import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.EntryProcessorException;
-import javax.cache.processor.MutableEntry;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import javax.cache.processor.EntryProcessorResult;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
@@ -89,7 +92,6 @@ import java.util.concurrent.CountDownLatch;
/**
* Cache based structure (meta data) manager.
*/
-@SuppressWarnings("all")
public class IgfsMetaManager extends IgfsManager {
/** Comparator for Id sorting. */
private static final Comparator<IgniteUuid> PATH_ID_SORTING_COMPARATOR
@@ -161,6 +163,7 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
+ @SuppressWarnings("RedundantCast")
@Override protected void onKernalStart0() throws IgniteCheckedException {
metaCache = igfsCtx.kernalContext().cache().getOrStartCache(cfg.getMetaCacheName());
@@ -511,9 +514,7 @@ public class IgfsMetaManager extends IgfsManager {
assert fileId != null;
- IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
// Lock file ID for this transaction.
IgfsEntryInfo oldInfo = info(fileId);
@@ -532,9 +533,6 @@ public class IgfsMetaManager extends IgfsManager {
catch (GridClosureException e) {
throw U.cast(e);
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -593,12 +591,12 @@ public class IgfsMetaManager extends IgfsManager {
throw fsException(new IgfsPathNotFoundException("Failed to unlock file (file not " +
"found): " + fileId));
- if (!info.lockId().equals(oldInfo.lockId()))
+ if (!F.eq(info.lockId(), oldInfo.lockId()))
throw new IgniteCheckedException("Failed to unlock file (inconsistent file lock ID) " +
"[fileId=" + fileId + ", lockId=" + info.lockId() + ", actualLockId=" +
oldInfo.lockId() + ']');
- id2InfoPrj.invoke(fileId, new FileUnlockProcessor(modificationTime));
+ id2InfoPrj.invoke(fileId, new IgfsMetaFileUnlockProcessor(modificationTime));
return null;
}
@@ -701,8 +699,6 @@ public class IgfsMetaManager extends IgfsManager {
throws IgniteCheckedException {
assert IgfsUtils.isRootOrTrashId(id);
- long time = System.currentTimeMillis();
-
IgfsEntryInfo info = IgfsUtils.createDirectory(id);
IgfsEntryInfo oldInfo = id2InfoPrj.getAndPutIfAbsent(id, info);
@@ -898,9 +894,7 @@ public class IgfsMetaManager extends IgfsManager {
srcPathIds.addExistingIds(lockIds);
dstPathIds.addExistingIds(lockIds);
- IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
// Obtain the locks.
final Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
@@ -942,9 +936,6 @@ public class IgfsMetaManager extends IgfsManager {
// Set the new path to the info to simplify event creation:
return srcInfo.path(newPath);
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -956,41 +947,6 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * Verify path integrity.
- *
- * @param path Path to verify.
- * @param expIds Expected IDs for this path. Might contain additional elements, e.g. because they were created
- * on a child path.
- * @param infos Locked infos.
- * @return verification result.
- */
- private static boolean verifyPathIntegrity(IgfsPath path, List<IgniteUuid> expIds,
- Map<IgniteUuid, IgfsEntryInfo> infos) {
- List<String> pathParts = path.components();
-
- assert pathParts.size() < expIds.size();
-
- for (int i = 0; i < pathParts.size(); i++) {
- IgniteUuid parentId = expIds.get(i);
-
- // If parent ID is null, it doesn't exist.
- if (parentId != null) {
- IgfsEntryInfo parentInfo = infos.get(parentId);
-
- // If parent info is null, it doesn't exist.
- if (parentInfo != null) {
- if (parentInfo.hasChild(pathParts.get(i), expIds.get(i + 1)))
- continue;
- }
- }
-
- return false;
- }
-
- return true;
- }
-
- /**
* Move or rename file in existing transaction.
*
* @param fileId File ID to move or rename.
@@ -1069,6 +1025,7 @@ public class IgfsMetaManager extends IgfsManager {
* elements moved to TRASH folder.
* @throws IgniteCheckedException On error.
*/
+ @SuppressWarnings("RedundantCast")
IgniteUuid format() throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
@@ -1076,9 +1033,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteUuid trashId = IgfsUtils.randomTrashId();
- final IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
// NB: We may lock root because its id is less than any other id:
final IgfsEntryInfo rootInfo = lockIds(IgfsUtils.ROOT_ID, trashId).get(IgfsUtils.ROOT_ID);
@@ -1097,7 +1052,7 @@ public class IgfsMetaManager extends IgfsManager {
IgfsEntryInfo newInfo = IgfsUtils.createDirectory(
IgniteUuid.randomUuid(),
transferListing,
- (Map<String,String>)null
+ (Map<String, String>) null
);
createNewEntry(newInfo, trashId, newInfo.id().toString());
@@ -1112,9 +1067,6 @@ public class IgfsMetaManager extends IgfsManager {
return newInfo.id();
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -1127,9 +1079,8 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Move path to the trash directory.
*
- * @param parentId Parent ID.
- * @param pathName Path name.
- * @param pathId Path ID.
+ * @param path Path.
+ * @param recursive Recursive flag.
* @return ID of an entry located directly under the trash directory.
* @throws IgniteCheckedException If failed.
*/
@@ -1159,9 +1110,7 @@ public class IgfsMetaManager extends IgfsManager {
allIds.add(trashId);
- IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
// Lock participants.
Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(allIds);
@@ -1197,9 +1146,6 @@ public class IgfsMetaManager extends IgfsManager {
return victimId;
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -1220,9 +1166,9 @@ public class IgfsMetaManager extends IgfsManager {
* @return ID of an entry located directly under the trash directory.
* @throws IgniteCheckedException If failed.
*/
+ @SuppressWarnings("RedundantCast")
@Nullable private IgniteUuid softDeleteNonTx(@Nullable IgniteUuid parentId, @Nullable String name, IgniteUuid id,
- IgniteUuid trashId)
- throws IgniteCheckedException {
+ IgniteUuid trashId) throws IgniteCheckedException {
validTxState(true);
IgniteUuid resId;
@@ -1268,7 +1214,7 @@ public class IgfsMetaManager extends IgfsManager {
// Remove listing entries from root.
for (Map.Entry<String, IgfsListingEntry> entry : transferListing.entrySet())
id2InfoPrj.invoke(IgfsUtils.ROOT_ID,
- new ListingRemoveProcessor(entry.getKey(), entry.getValue().fileId()));
+ new IgfsMetaDirectoryListingRemoveProcessor(entry.getKey(), entry.getValue().fileId()));
resId = newInfo.id();
}
@@ -1304,9 +1250,7 @@ public class IgfsMetaManager extends IgfsManager {
assert listing != null;
validTxState(false);
- IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
Collection<IgniteUuid> res = new HashSet<>();
// Obtain all necessary locks in one hop.
@@ -1367,9 +1311,6 @@ public class IgfsMetaManager extends IgfsManager {
return res;
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -1395,17 +1336,13 @@ public class IgfsMetaManager extends IgfsManager {
try {
validTxState(false);
- IgniteInternalTx tx = startTx();
-
- try {
- boolean res = false;
-
+ try (IgniteInternalTx tx = startTx()) {
Map<IgniteUuid, IgfsEntryInfo> infos = lockIds(parentId, id);
IgfsEntryInfo victim = infos.get(id);
if (victim == null)
- return res;
+ return false;
assert victim.isDirectory() || IgfsUtils.DELETE_LOCK_ID.equals(victim.lockId()) :
" isDir: " + victim.isDirectory() + ", lockId: " + victim.lockId();
@@ -1419,19 +1356,16 @@ public class IgfsMetaManager extends IgfsManager {
IgfsListingEntry childEntry = parentInfo.listing().get(name);
if (childEntry != null)
- id2InfoPrj.invoke(parentId, new ListingRemoveProcessor(name, id));
+ id2InfoPrj.invoke(parentId, new IgfsMetaDirectoryListingRemoveProcessor(name, id));
id2InfoPrj.remove(id);
- res = true;
- }
+ tx.commit();
- tx.commit();
+ return true;
+ }
- return res;
- }
- finally {
- tx.close();
+ return false;
}
}
finally {
@@ -1499,7 +1433,7 @@ public class IgfsMetaManager extends IgfsManager {
if (oldInfo == null)
return null;
- return invokeAndGet(fileId, new UpdatePropertiesProcessor(props));
+ return invokeAndGet(fileId, new IgfsMetaUpdatePropertiesProcessor(props));
}
catch (GridClosureException e) {
throw U.cast(e);
@@ -1520,18 +1454,13 @@ public class IgfsMetaManager extends IgfsManager {
try {
validTxState(false);
- IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
IgfsEntryInfo info = updatePropertiesNonTx(fileId, props);
tx.commit();
return info;
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -1560,16 +1489,15 @@ public class IgfsMetaManager extends IgfsManager {
if (log.isDebugEnabled())
log.debug("Reserve file space [path=" + path + ", id=" + fileId + ']');
- IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
// Lock file ID for this transaction.
IgfsEntryInfo oldInfo = info(fileId);
if (oldInfo == null)
throw fsException("File has been deleted concurrently [path=" + path + ", id=" + fileId + ']');
- IgfsEntryInfo newInfo = invokeAndGet(fileId, new FileReserveSpaceProcessor(space, affRange));
+ IgfsEntryInfo newInfo =
+ invokeAndGet(fileId, new IgfsMetaFileReserveSpaceProcessor(space, affRange));
tx.commit();
@@ -1578,9 +1506,6 @@ public class IgfsMetaManager extends IgfsManager {
catch (GridClosureException e) {
throw U.cast(e);
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -1610,9 +1535,7 @@ public class IgfsMetaManager extends IgfsManager {
if (log.isDebugEnabled())
log.debug("Update file info [fileId=" + fileId + ", proc=" + proc + ']');
- IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
// Lock file ID for this transaction.
IgfsEntryInfo oldInfo = info(fileId);
@@ -1623,7 +1546,7 @@ public class IgfsMetaManager extends IgfsManager {
if (newInfo == null)
throw fsException("Failed to update file info with null value" +
- " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", proc=" + proc + ']');
+ " [oldInfo=" + oldInfo + ", newInfo=null, proc=" + proc + ']');
if (!oldInfo.id().equals(newInfo.id()))
throw fsException("Failed to update file info (file IDs differ)" +
@@ -1640,9 +1563,6 @@ public class IgfsMetaManager extends IgfsManager {
catch (GridClosureException e) {
throw U.cast(e);
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -1679,9 +1599,7 @@ public class IgfsMetaManager extends IgfsManager {
assert lockIds.size() == pathIds.count();
// Start TX.
- IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
final Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (!pathIds.verifyIntegrity(lockInfos))
@@ -1710,9 +1628,6 @@ public class IgfsMetaManager extends IgfsManager {
// We are done.
return true;
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -1735,18 +1650,13 @@ public class IgfsMetaManager extends IgfsManager {
try {
validTxState(false);
- IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
Object prev = val != null ? metaCache.getAndPut(sampling, val) : metaCache.getAndRemove(sampling);
tx.commit();
return !F.eq(prev, val);
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -1795,7 +1705,7 @@ public class IgfsMetaManager extends IgfsManager {
throw fsException("Failed to create new metadata entry due to ID conflict: " + info.id());
if (parentId != null)
- id2InfoPrj.invoke(parentId, new ListingAddProcessor(name, new IgfsListingEntry(info)));
+ id2InfoPrj.invoke(parentId, new IgfsMetaDirectoryListingAddProcessor(name, new IgfsListingEntry(info)));
}
/**
@@ -1812,8 +1722,8 @@ public class IgfsMetaManager extends IgfsManager {
IgniteUuid destId, String destName) throws IgniteCheckedException {
validTxState(true);
- id2InfoPrj.invoke(srcId, new ListingRemoveProcessor(srcName, entry.fileId()));
- id2InfoPrj.invoke(destId, new ListingAddProcessor(destName, entry));
+ id2InfoPrj.invoke(srcId, new IgfsMetaDirectoryListingRemoveProcessor(srcName, entry.fileId()));
+ id2InfoPrj.invoke(destId, new IgfsMetaDirectoryListingAddProcessor(destName, entry));
}
/**
@@ -1825,7 +1735,7 @@ public class IgfsMetaManager extends IgfsManager {
* @throws IgniteCheckedException If failed.
*/
private IgfsEntryInfo invokeLock(IgniteUuid id, boolean delete) throws IgniteCheckedException {
- return invokeAndGet(id, new FileLockProcessor(createFileLockId(delete)));
+ return invokeAndGet(id, new IgfsMetaFileLockProcessor(createFileLockId(delete)));
}
/**
@@ -1838,7 +1748,7 @@ public class IgfsMetaManager extends IgfsManager {
private void invokeUpdatePath(IgniteUuid id, IgfsPath path) throws IgniteCheckedException {
validTxState(true);
- id2InfoPrj.invoke(id, new UpdatePathProcessor(path));
+ id2InfoPrj.invoke(id, new IgfsMetaUpdatePathProcessor(path));
}
/**
@@ -1853,7 +1763,11 @@ public class IgfsMetaManager extends IgfsManager {
throws IgniteCheckedException {
validTxState(true);
- return id2InfoPrj.invoke(id, proc).get();
+ EntryProcessorResult<IgfsEntryInfo> res = id2InfoPrj.invoke(id, proc);
+
+ assert res != null;
+
+ return res.get();
}
/**
@@ -1985,6 +1899,8 @@ public class IgfsMetaManager extends IgfsManager {
);
// Add new file info to the listing optionally removing the previous one.
+ assert parentInfo != null;
+
IgniteUuid oldId = putIfAbsentNonTx(parentInfo.id(), path.name(), newInfo);
if (oldId != null) {
@@ -1998,12 +1914,12 @@ public class IgfsMetaManager extends IgfsManager {
path + ", fileId=" + oldId + ", lockId=" + oldInfo.lockId() + ']');
id2InfoPrj.remove(oldId); // Remove the old one.
- id2InfoPrj.invoke(parentInfo.id(),
- new ListingRemoveProcessor(path.name(), parentInfo.listing().get(path.name()).fileId()));
+ id2InfoPrj.invoke(parentInfo.id(), new IgfsMetaDirectoryListingRemoveProcessor(
+ path.name(), parentInfo.listing().get(path.name()).fileId()));
createNewEntry(newInfo, parentInfo.id(), path.name()); // Put new one.
- IgniteInternalFuture<?> delFut = igfsCtx.data().delete(oldInfo);
+ igfsCtx.data().delete(oldInfo);
}
// Record CREATE event if needed.
@@ -2084,13 +2000,13 @@ public class IgfsMetaManager extends IgfsManager {
if (remainder > 0) {
int blockIdx = (int)(len / blockSize);
- IgfsSecondaryFileSystemPositionedReadable reader = fs.open(path, bufSize);
+ try (IgfsSecondaryFileSystemPositionedReadable reader = fs.open(path, bufSize)) {
+ IgniteInternalFuture<byte[]> fut =
+ igfsCtx.data().dataBlock(info, path, blockIdx, reader);
- try {
- igfsCtx.data().dataBlock(info, path, blockIdx, reader).get();
- }
- finally {
- reader.close();
+ assert fut != null;
+
+ fut.get();
}
}
@@ -2366,12 +2282,8 @@ public class IgfsMetaManager extends IgfsManager {
fs.rename(src, dest);
// Rename was successful, perform compensation in the local file system.
- if (destInfo == null) {
- // Move and rename.
- assert destParentInfo != null;
-
+ if (destInfo == null)
moveNonTx(srcInfo.id(), src.name(), srcParentInfo.id(), dest.name(), destParentInfo.id());
- }
else {
// Move.
if (destInfo.isFile())
@@ -2622,6 +2534,8 @@ public class IgfsMetaManager extends IgfsManager {
status.modificationTime()
);
+ assert parentInfo != null;
+
IgniteUuid oldId = putIfAbsentNonTx(parentInfo.id(), components.get(i), curInfo);
if (oldId != null)
@@ -2669,13 +2583,9 @@ public class IgfsMetaManager extends IgfsManager {
* @return Result of task execution.
* @throws IgniteCheckedException If failed.
*/
- private <T> T synchronizeAndExecute(SynchronizationTask<T> task,
- IgfsSecondaryFileSystem fs,
- boolean strict,
- @Nullable Collection<IgniteUuid> extraLockIds,
- IgfsPath... paths)
- throws IgniteCheckedException
- {
+ @SuppressWarnings({"Contract", "ConstantConditions"})
+ private <T> T synchronizeAndExecute(SynchronizationTask<T> task, IgfsSecondaryFileSystem fs, boolean strict,
+ @Nullable Collection<IgniteUuid> extraLockIds, IgfsPath... paths) throws IgniteCheckedException {
assert task != null;
assert fs != null;
assert paths != null && paths.length > 0;
@@ -2696,9 +2606,8 @@ public class IgfsMetaManager extends IgfsManager {
pathIds.add(fileIds(path));
// Start pessimistic.
- IgniteInternalTx tx = startTx();
- try {
+ try (IgniteInternalTx tx = startTx()) {
// Lock the very first existing parents and possibly the leaf as well.
Map<IgfsPath, IgfsPath> pathToParent = new HashMap<>();
@@ -2864,34 +2773,12 @@ public class IgfsMetaManager extends IgfsManager {
else
throw e;
}
- finally {
- tx.close();
- }
}
return res;
}
/**
- * Update cached value with closure.
- *
- * @param cache Cache projection to work with.
- * @param key Key to retrieve/update the value for.
- * @param c Closure to apply to cached value.
- * @return {@code True} if value was stored in cache, {@code false} otherwise.
- * @throws IgniteCheckedException If operation failed.
- */
- private <K, V> boolean putx(IgniteInternalCache<K, V> cache, K key, IgniteClosure<V, V> c)
- throws IgniteCheckedException {
- validTxState(true);
-
- V oldVal = cache.get(key);
- V newVal = c.apply(oldVal);
-
- return newVal == null ? cache.remove(key) : cache.put(key, newVal);
- }
-
- /**
* Check transaction is (not) started.
*
* @param inTx Expected transaction state.
@@ -2927,16 +2814,14 @@ public class IgfsMetaManager extends IgfsManager {
validTxState(false);
// Start pessimistic transaction.
- IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
Map<IgniteUuid, IgfsEntryInfo> infoMap = lockIds(fileId, parentId);
IgfsEntryInfo fileInfo = infoMap.get(fileId);
if (fileInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to update times " +
- "(path was not found): " + fileName));
+ "(path was not found): " + fileName));
IgfsEntryInfo parentInfo = infoMap.get(parentId);
@@ -2947,20 +2832,17 @@ public class IgfsMetaManager extends IgfsManager {
// Validate listing.
if (!parentInfo.hasChild(fileName, fileId))
throw fsException(new IgfsConcurrentModificationException("Failed to update times " +
- "(file concurrently modified): " + fileName));
+ "(file concurrently modified): " + fileName));
assert parentInfo.isDirectory();
- id2InfoPrj.invoke(fileId, new UpdateTimesProcessor(
+ id2InfoPrj.invoke(fileId, new IgfsMetaUpdateTimesProcessor(
accessTime == -1 ? fileInfo.accessTime() : accessTime,
modificationTime == -1 ? fileInfo.modificationTime() : modificationTime)
);
tx.commit();
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -2980,7 +2862,7 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * @param msg Error message.
+ * @param err Unchecked exception.
* @return Checked exception.
*/
private static IgniteCheckedException fsException(IgfsException err) {
@@ -3011,365 +2893,6 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * Path descriptor.
- */
- private static class PathDescriptor {
- /** Path. */
- private final IgfsPath path;
-
- /** Resolved IDs. */
- private final List<IgniteUuid> ids;
-
- /** Parent path. */
- private IgfsPath parentPath;
-
- /** Parent path info. */
- private IgfsEntryInfo parentInfo;
-
- /**
- * Constructor.
- *
- * @param path Path.
- * @param ids Resolved path IDs.
- * @param parentPath Parent path.
- * @param parentInfo Parent info.
- */
- PathDescriptor(IgfsPath path, List<IgniteUuid> ids, IgfsPath parentPath, IgfsEntryInfo parentInfo) {
- assert path != null;
- assert ids != null && !ids.isEmpty();
- assert parentPath == null && parentInfo == null || parentPath != null && parentInfo != null;
- assert parentPath == null || parentPath != null && path.isSubDirectoryOf(parentPath);
-
- this.path = path;
- this.ids = ids;
- this.parentPath = parentPath;
- this.parentInfo = parentInfo;
- }
-
- /**
- * Get resolved path ids.
- *
- * @return Path ids.
- */
- private Collection<IgniteUuid> ids() {
- return ids;
- }
-
- /**
- * Get path ID from the end. E.g. endId(1) will return the last element.
- * @param i Element index from the end.
- *
- * @return Path ID from the end.
- */
- private IgniteUuid endId(int i) {
- return ids.get(ids.size() - i);
- }
-
- /**
- * Update ID with the given index.
- *
- * @param newParentPath New parent path.
- * @param newParentInfo New parent info.
- */
- private void updateParent(IgfsPath newParentPath, IgfsEntryInfo newParentInfo) {
- assert newParentPath != null;
- assert newParentInfo != null;
- assert path.isSubDirectoryOf(newParentPath);
-
- parentPath = newParentPath;
- parentInfo = newParentInfo;
-
- ids.set(newParentPath.components().size(), newParentInfo.id());
- }
-
- /**
- * Get parent path.
- *
- * @return Parent path.
- */
- private IgfsPath parentPath() {
- return parentPath;
- }
-
- /**
- * Get parent path info.
- *
- * @return Parent path info.
- */
- private IgfsEntryInfo parentInfo() {
- return parentInfo;
- }
- }
-
- /**
- * Remove entry from directory listing.
- */
- @GridInternal
- private static final class ListingRemoveProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** File name. */
- private String fileName;
-
- /** Expected ID. */
- private IgniteUuid fileId;
-
- /**
- * Default constructor.
- */
- public ListingRemoveProcessor() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param fileName File name.
- * @param fileId File ID.
- */
- public ListingRemoveProcessor(String fileName, IgniteUuid fileId) {
- this.fileName = fileName;
- this.fileId = fileId;
- }
-
- /** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args)
- throws EntryProcessorException {
- IgfsEntryInfo fileInfo = e.getValue();
-
- assert fileInfo != null;
- assert fileInfo.isDirectory();
-
- Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
-
- listing.putAll(fileInfo.listing());
-
- IgfsListingEntry oldEntry = listing.get(fileName);
-
- if (oldEntry == null || !oldEntry.fileId().equals(fileId))
- throw new IgniteException("Directory listing doesn't contain expected file" +
- " [listing=" + listing + ", fileName=" + fileName + "]");
-
- // Modify listing in-place.
- listing.remove(fileName);
-
- e.setValue(fileInfo.listing(listing));
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeString(out, fileName);
- U.writeGridUuid(out, fileId);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- fileName = U.readString(in);
- fileId = U.readGridUuid(in);
- }
- }
-
- /**
- * Update directory listing closure.
- */
- @GridInternal
- private static final class ListingAddProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** File name to add into parent listing. */
- private String fileName;
-
- /** File ID.*/
- private IgfsListingEntry entry;
-
- /**
- * Empty constructor required for {@link Externalizable}.
- *
- */
- public ListingAddProcessor() {
- // No-op.
- }
-
- /**
- * Constructs update directory listing closure.
- *
- * @param fileName File name to add into parent listing.
- * @param entry Listing entry to add or remove.
- */
- private ListingAddProcessor(String fileName, IgfsListingEntry entry) {
- assert fileName != null;
- assert entry != null;
-
- this.fileName = fileName;
- this.entry = entry;
- }
-
- /** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) {
- IgfsEntryInfo fileInfo = e.getValue();
-
- assert fileInfo.isDirectory();
-
- Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
-
- // Modify listing in-place.
- IgfsListingEntry oldEntry = listing.put(fileName, entry);
-
- if (oldEntry != null && !oldEntry.fileId().equals(entry.fileId()))
- throw new IgniteException("Directory listing contains unexpected file" +
- " [listing=" + listing + ", fileName=" + fileName + ", entry=" + entry +
- ", oldEntry=" + oldEntry + ']');
-
- e.setValue(fileInfo.listing(listing));
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeString(out, fileName);
- out.writeObject(entry);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- fileName = U.readString(in);
- entry = (IgfsListingEntry)in.readObject();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(ListingAddProcessor.class, this);
- }
- }
-
- /**
- * Listing replace processor.
- */
- private static final class ListingReplaceProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Name. */
- private String name;
-
- /** New ID. */
- private IgniteUuid id;
-
- /**
- * Constructor.
- */
- public ListingReplaceProcessor() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param name Name.
- * @param id ID.
- */
- public ListingReplaceProcessor(String name, IgniteUuid id) {
- this.name = name;
- this.id = id;
- }
-
- /** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args)
- throws EntryProcessorException {
- IgfsEntryInfo fileInfo = e.getValue();
-
- assert fileInfo.isDirectory();
-
- Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
-
- // Modify listing in-place.
- IgfsListingEntry oldEntry = listing.get(name);
-
- if (oldEntry == null)
- throw new IgniteException("Directory listing doesn't contain expected entry: " + name);
-
- listing.put(name, new IgfsListingEntry(id, oldEntry.isDirectory()));
-
- e.setValue(fileInfo.listing(listing));
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeString(out, name);
- out.writeObject(id);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- name = U.readString(in);
- id = (IgniteUuid)in.readObject();
- }
- }
-
- /**
- * Update path closure.
- */
- @GridInternal
- private static final class UpdatePathProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** New path. */
- private IgfsPath path;
-
- /**
- * @param path Path.
- */
- private UpdatePathProcessor(IgfsPath path) {
- this.path = path;
- }
-
- /**
- * Default constructor (required by Externalizable).
- */
- public UpdatePathProcessor() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) {
- IgfsEntryInfo info = e.getValue();
-
- IgfsEntryInfo newInfo = info.path(path);
-
- e.setValue(newInfo);
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(path);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- path = (IgfsPath)in.readObject();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(UpdatePathProcessor.class, this);
- }
- }
-
- /**
* Append routine.
*
* @param path Path.
@@ -3409,9 +2932,7 @@ public class IgfsMetaManager extends IgfsManager {
pathIds.addSurrogateIds(lockIds);
// Start TX.
- IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (!pathIds.verifyIntegrity(lockInfos))
@@ -3458,9 +2979,6 @@ public class IgfsMetaManager extends IgfsManager {
return new T2<>(res.info(), res.parentId());
}
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -3472,16 +2990,17 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * Create a new file.
+ * Create a file.
*
* @param path Path.
- * @param bufSize Buffer size.
+ * @param dirProps Directory properties.
* @param overwrite Overwrite flag.
+ * @param blockSize Block size.
* @param affKey Affinity key.
- * @param replication Replication factor.
- * @param props Properties.
- * @param simpleCreate Whether new file should be created in secondary FS using create(Path, boolean) method.
- * @return Tuple containing the created file info and its parent id.
+ * @param evictExclude Evict exclude flag.
+ * @param fileProps File properties.
+ * @return @return Tuple containing the created file info and its parent id.
+ * @throws IgniteCheckedException If failed.
*/
IgniteBiTuple<IgfsEntryInfo, IgniteUuid> create(
final IgfsPath path,
@@ -3518,9 +3037,7 @@ public class IgfsMetaManager extends IgfsManager {
}
// Start TX.
- IgniteInternalTx tx = startTx();
-
- try {
+ try (IgniteInternalTx tx = startTx()) {
Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (!pathIds.verifyIntegrity(lockInfos))
@@ -3548,19 +3065,19 @@ public class IgfsMetaManager extends IgfsManager {
// First step: add existing to trash listing.
IgniteUuid oldId = pathIds.lastId();
- id2InfoPrj.invoke(trashId, new ListingAddProcessor(oldId.toString(),
+ id2InfoPrj.invoke(trashId, new IgfsMetaDirectoryListingAddProcessor(oldId.toString(),
new IgfsListingEntry(oldInfo)));
// Second step: replace ID in parent directory.
String name = pathIds.lastPart();
IgniteUuid parentId = pathIds.lastParentId();
- id2InfoPrj.invoke(parentId, new ListingReplaceProcessor(name, overwriteId));
+ id2InfoPrj.invoke(parentId, new IgfsMetaDirectoryListingReplaceProcessor(name, overwriteId));
// Third step: create the file.
long createTime = System.currentTimeMillis();
- IgfsEntryInfo newInfo = invokeAndGet(overwriteId, new FileCreateProcessor(createTime,
+ IgfsEntryInfo newInfo = invokeAndGet(overwriteId, new IgfsMetaFileCreateProcessor(createTime,
fileProps, blockSize, affKey, createFileLockId(false), evictExclude));
// Fourth step: update path of remove file.
@@ -3592,9 +3109,6 @@ public class IgfsMetaManager extends IgfsManager {
return new T2<>(res.info(), res.parentId());
}
}
- finally {
- tx.close();
- }
}
finally {
busyLock.leaveBusy();
@@ -3682,7 +3196,7 @@ public class IgfsMetaManager extends IgfsManager {
return null;
// First step: add new entry to the last existing element.
- id2InfoPrj.invoke(lastExistingInfo.id(), new ListingAddProcessor(curPart,
+ id2InfoPrj.invoke(lastExistingInfo.id(), new IgfsMetaDirectoryListingAddProcessor(curPart,
new IgfsListingEntry(curId, dir || !pathIds.isLastIndex(curIdx))));
// Events support.
@@ -3699,7 +3213,7 @@ public class IgfsMetaManager extends IgfsManager {
String nextPart = pathIds.part(nextIdx);
IgniteUuid nextId = pathIds.surrogateId(nextIdx);
- id2InfoPrj.invoke(curId, new DirectoryCreateProcessor(createTime, dirProps,
+ id2InfoPrj.invoke(curId, new IgfsMetaDirectoryCreateProcessor(createTime, dirProps,
nextPart, new IgfsListingEntry(nextId, dir || !pathIds.isLastIndex(nextIdx))));
// Save event.
@@ -3720,9 +3234,9 @@ public class IgfsMetaManager extends IgfsManager {
IgfsEntryInfo info;
if (dir)
- info = invokeAndGet(curId, new DirectoryCreateProcessor(createTime, dirProps));
+ info = invokeAndGet(curId, new IgfsMetaDirectoryCreateProcessor(createTime, dirProps));
else
- info = invokeAndGet(curId, new FileCreateProcessor(createTime, fileProps,
+ info = invokeAndGet(curId, new IgfsMetaFileCreateProcessor(createTime, fileProps,
blockSize, affKey, createFileLockId(false), evictExclude));
createdPaths.add(pathIds.path());
@@ -3752,476 +3266,4 @@ public class IgfsMetaManager extends IgfsManager {
else
IgfsUtils.sendEvents(igfsCtx.kernalContext(), leafPath, EventType.EVT_IGFS_DIR_CREATED);
}
-
- /**
- * File create processor.
- */
- private static class FileCreateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Create time. */
- private long createTime;
-
- /** Properties. */
- private Map<String, String> props;
-
- /** Block size. */
- private int blockSize;
-
- /** Affintiy key. */
- private IgniteUuid affKey;
-
- /** Lcok ID. */
- private IgniteUuid lockId;
-
- /** Evict exclude flag. */
- private boolean evictExclude;
-
- /**
- * Constructor.
- */
- public FileCreateProcessor() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param createTime Create time.
- * @param props Properties.
- * @param blockSize Block size.
- * @param affKey Affinity key.
- * @param lockId Lock ID.
- * @param evictExclude Evict exclude flag.
- */
- public FileCreateProcessor(long createTime, Map<String, String> props, int blockSize,
- @Nullable IgniteUuid affKey, IgniteUuid lockId, boolean evictExclude) {
- this.createTime = createTime;
- this.props = props;
- this.blockSize = blockSize;
- this.affKey = affKey;
- this.lockId = lockId;
- this.evictExclude = evictExclude;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
- throws EntryProcessorException {
- IgfsEntryInfo info = IgfsUtils.createFile(
- entry.getKey(),
- blockSize,
- 0L,
- affKey,
- lockId,
- evictExclude,
- props,
- createTime,
- createTime
- );
-
- entry.setValue(info);
-
- return info;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeLong(createTime);
- U.writeStringMap(out, props);
- out.writeInt(blockSize);
- out.writeObject(affKey);
- out.writeObject(lockId);
- out.writeBoolean(evictExclude);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- createTime = in.readLong();
- props = U.readStringMap(in);
- blockSize = in.readInt();
- affKey = (IgniteUuid)in.readObject();
- lockId = (IgniteUuid)in.readObject();
- evictExclude = in.readBoolean();
- }
- }
-
- /**
- * Directory create processor.
- */
- private static class DirectoryCreateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Create time. */
- private long createTime;
-
- /** Properties. */
- private Map<String, String> props;
-
- /** Child name (optional). */
- private String childName;
-
- /** Child entry (optional. */
- private IgfsListingEntry childEntry;
-
- /**
- * Constructor.
- */
- public DirectoryCreateProcessor() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param createTime Create time.
- * @param props Properties.
- */
- public DirectoryCreateProcessor(long createTime, Map<String, String> props) {
- this(createTime, props, null, null);
- }
-
- /**
- * Constructor.
- *
- * @param createTime Create time.
- * @param props Properties.
- * @param childName Child name.
- * @param childEntry Child entry.
- */
- public DirectoryCreateProcessor(long createTime, Map<String, String> props, String childName,
- IgfsListingEntry childEntry) {
- this.createTime = createTime;
- this.props = props;
- this.childName = childName;
- this.childEntry = childEntry;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
- throws EntryProcessorException {
-
- IgfsEntryInfo info = IgfsUtils.createDirectory(
- entry.getKey(),
- null,
- props,
- createTime,
- createTime
- );
-
- if (childName != null)
- info = info.listing(Collections.singletonMap(childName, childEntry));
-
- entry.setValue(info);
-
- return info;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeLong(createTime);
- U.writeStringMap(out, props);
-
- if (childName != null) {
- out.writeBoolean(true);
-
- U.writeString(out, childName);
- out.writeObject(childEntry);
- }
- else
- out.writeBoolean(false);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- createTime = in.readLong();
- props = U.readStringMap(in);
-
- if (in.readBoolean()) {
- childName = U.readString(in);
- childEntry = (IgfsListingEntry)in.readObject();
- }
- }
- }
-
- /**
- * File lock entry processor.
- */
- private static class FileLockProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Lock Id. */
- private IgniteUuid lockId;
-
- /**
- * Default constructor.
- */
- public FileLockProcessor() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param lockId Lock ID.
- */
- public FileLockProcessor(IgniteUuid lockId) {
- this.lockId = lockId;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
- throws EntryProcessorException {
- IgfsEntryInfo oldInfo = entry.getValue();
-
- IgfsEntryInfo newInfo = oldInfo.lock(lockId);
-
- entry.setValue(newInfo);
-
- return newInfo;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeGridUuid(out, lockId);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- lockId = U.readGridUuid(in);
- }
- }
-
- /**
- * File unlock entry processor.
- */
- private static class FileUnlockProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Modification time. */
- private long modificationTime;
-
- /**
- * Default constructor.
- */
- public FileUnlockProcessor() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param modificationTime Modification time.
- */
- public FileUnlockProcessor(long modificationTime) {
- this.modificationTime = modificationTime;
- }
-
- /** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
- throws EntryProcessorException {
- IgfsEntryInfo old = entry.getValue();
-
- entry.setValue(old.unlock(modificationTime));
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeLong(modificationTime);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- modificationTime = in.readLong();
- }
- }
-
- /**
- * File reserve space entry processor.
- */
- private static class FileReserveSpaceProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Space. */
- private long space;
-
- /** Affinity range. */
- private IgfsFileAffinityRange affRange;
-
- /**
- * Default constructor.
- */
- public FileReserveSpaceProcessor() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param space Space.
- * @param affRange
- */
- public FileReserveSpaceProcessor(long space, IgfsFileAffinityRange affRange) {
- this.space = space;
- this.affRange = affRange;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
- throws EntryProcessorException {
- IgfsEntryInfo oldInfo = entry.getValue();
-
- IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
-
- newMap.addRange(affRange);
-
- IgfsEntryInfo newInfo = oldInfo.length(oldInfo.length() + space).fileMap(newMap);
-
- entry.setValue(newInfo);
-
- return newInfo;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeLong(space);
- out.writeObject(affRange);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- space = in.readLong();
- affRange = (IgfsFileAffinityRange)in.readObject();
- }
- }
-
- /**
- * Update properties processor.
- */
- private static class UpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Properties to be updated. */
- private Map<String, String> props;
-
- /**
- * Constructor.
- */
- public UpdatePropertiesProcessor() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param props Properties.
- */
- public UpdatePropertiesProcessor(Map<String, String> props) {
- this.props = props;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
- throws EntryProcessorException {
- IgfsEntryInfo oldInfo = entry.getValue();
-
- Map<String, String> tmp = oldInfo.properties();
-
- tmp = tmp == null ? new GridLeanMap<String, String>(props.size()) : new GridLeanMap<>(tmp);
-
- for (Map.Entry<String, String> e : props.entrySet()) {
- if (e.getValue() == null)
- // Remove properties with 'null' values.
- tmp.remove(e.getKey());
- else
- // Add/overwrite property.
- tmp.put(e.getKey(), e.getValue());
- }
-
- IgfsEntryInfo newInfo = oldInfo.properties(tmp);
-
- entry.setValue(newInfo);
-
- return newInfo;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeStringMap(out, props);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- props = U.readStringMap(in);
- }
- }
-
- /**
- * Update times entry processor.
- */
- private static class UpdateTimesProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Access time. */
- private long accessTime;
-
- /** Modification time. */
- private long modificationTime;
-
- /**
- * Default constructor.
- */
- public UpdateTimesProcessor() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param accessTime Access time.
- * @param modificationTime Modification time.
- */
- public UpdateTimesProcessor(long accessTime, long modificationTime) {
- this.accessTime = accessTime;
- this.modificationTime = modificationTime;
- }
-
- /** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
- throws EntryProcessorException {
-
- IgfsEntryInfo oldInfo = entry.getValue();
-
- entry.setValue(oldInfo.accessModificationTime(accessTime, modificationTime));
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeLong(accessTime);
- out.writeLong(modificationTime);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- accessTime = in.readLong();
- modificationTime = in.readLong();
- }
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
index 2903239..e2fe58d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
@@ -134,7 +134,7 @@ public class IgfsPathIds {
*
* @return Last ID.
*/
- @Nullable public IgniteUuid lastId() {
+ public IgniteUuid lastId() {
return ids[ids.length - 1];
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
new file mode 100644
index 0000000..ffba042
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
@@ -0,0 +1,117 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsListingEntry;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Directory create processor.
+ */
+public class IgfsMetaDirectoryCreateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Create time. */
+ private long createTime;
+
+ /** Properties. */
+ private Map<String, String> props;
+
+ /** Child name (optional). */
+ private String childName;
+
+ /** Child entry (optional. */
+ private IgfsListingEntry childEntry;
+
+ /**
+ * Constructor.
+ */
+ public IgfsMetaDirectoryCreateProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param createTime Create time.
+ * @param props Properties.
+ */
+ public IgfsMetaDirectoryCreateProcessor(long createTime, Map<String, String> props) {
+ this(createTime, props, null, null);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param createTime Create time.
+ * @param props Properties.
+ * @param childName Child name.
+ * @param childEntry Child entry.
+ */
+ public IgfsMetaDirectoryCreateProcessor(long createTime, Map<String, String> props, String childName,
+ IgfsListingEntry childEntry) {
+ this.createTime = createTime;
+ this.props = props;
+ this.childName = childName;
+ this.childEntry = childEntry;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
+ throws EntryProcessorException {
+
+ IgfsEntryInfo info = IgfsUtils.createDirectory(
+ entry.getKey(),
+ null,
+ props,
+ createTime,
+ createTime
+ );
+
+ if (childName != null)
+ info = info.listing(Collections.singletonMap(childName, childEntry));
+
+ entry.setValue(info);
+
+ return info;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(createTime);
+ U.writeStringMap(out, props);
+
+ if (childName != null) {
+ out.writeBoolean(true);
+
+ U.writeString(out, childName);
+ out.writeObject(childEntry);
+ }
+ else
+ out.writeBoolean(false);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ createTime = in.readLong();
+ props = U.readStringMap(in);
+
+ if (in.readBoolean()) {
+ childName = U.readString(in);
+ childEntry = (IgfsListingEntry)in.readObject();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
new file mode 100644
index 0000000..ab5cd5d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
@@ -0,0 +1,92 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsListingEntry;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Update directory listing closure.
+ */
+public final class IgfsMetaDirectoryListingAddProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** File name to add into parent listing. */
+ private String fileName;
+
+ /** File ID.*/
+ private IgfsListingEntry entry;
+
+ /**
+ * Empty constructor required for {@link Externalizable}.
+ *
+ */
+ public IgfsMetaDirectoryListingAddProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructs update directory listing closure.
+ *
+ * @param fileName File name to add into parent listing.
+ * @param entry Listing entry to add or remove.
+ */
+ public IgfsMetaDirectoryListingAddProcessor(String fileName, IgfsListingEntry entry) {
+ assert fileName != null;
+ assert entry != null;
+
+ this.fileName = fileName;
+ this.entry = entry;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) {
+ IgfsEntryInfo fileInfo = e.getValue();
+
+ assert fileInfo.isDirectory();
+
+ Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
+
+ // Modify listing in-place.
+ IgfsListingEntry oldEntry = listing.put(fileName, entry);
+
+ if (oldEntry != null && !oldEntry.fileId().equals(entry.fileId()))
+ throw new IgniteException("Directory listing contains unexpected file" +
+ " [listing=" + listing + ", fileName=" + fileName + ", entry=" + entry +
+ ", oldEntry=" + oldEntry + ']');
+
+ e.setValue(fileInfo.listing(listing));
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeString(out, fileName);
+ out.writeObject(entry);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ fileName = U.readString(in);
+ entry = (IgfsListingEntry)in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaDirectoryListingAddProcessor.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java
new file mode 100644
index 0000000..181a73e
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java
@@ -0,0 +1,89 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsListingEntry;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Remove entry from directory listing.
+ */
+public class IgfsMetaDirectoryListingRemoveProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** File name. */
+ private String fileName;
+
+ /** Expected ID. */
+ private IgniteUuid fileId;
+
+ /**
+ * Default constructor.
+ */
+ public IgfsMetaDirectoryListingRemoveProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param fileName File name.
+ * @param fileId File ID.
+ */
+ public IgfsMetaDirectoryListingRemoveProcessor(String fileName, IgniteUuid fileId) {
+ this.fileName = fileName;
+ this.fileId = fileId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args)
+ throws EntryProcessorException {
+ IgfsEntryInfo fileInfo = e.getValue();
+
+ assert fileInfo != null;
+ assert fileInfo.isDirectory();
+
+ Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
+
+ listing.putAll(fileInfo.listing());
+
+ IgfsListingEntry oldEntry = listing.get(fileName);
+
+ if (oldEntry == null || !oldEntry.fileId().equals(fileId))
+ throw new IgniteException("Directory listing doesn't contain expected file" +
+ " [listing=" + listing + ", fileName=" + fileName + "]");
+
+ // Modify listing in-place.
+ listing.remove(fileName);
+
+ e.setValue(fileInfo.listing(listing));
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeString(out, fileName);
+ U.writeGridUuid(out, fileId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ fileName = U.readString(in);
+ fileId = U.readGridUuid(in);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
new file mode 100644
index 0000000..4c4888c
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
@@ -0,0 +1,84 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsListingEntry;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Listing replace processor.
+ */
+public final class IgfsMetaDirectoryListingReplaceProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Name. */
+ private String name;
+
+ /** New ID. */
+ private IgniteUuid id;
+
+ /**
+ * Constructor.
+ */
+ public IgfsMetaDirectoryListingReplaceProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param name Name.
+ * @param id ID.
+ */
+ public IgfsMetaDirectoryListingReplaceProcessor(String name, IgniteUuid id) {
+ this.name = name;
+ this.id = id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args)
+ throws EntryProcessorException {
+ IgfsEntryInfo fileInfo = e.getValue();
+
+ assert fileInfo.isDirectory();
+
+ Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
+
+ // Modify listing in-place.
+ IgfsListingEntry oldEntry = listing.get(name);
+
+ if (oldEntry == null)
+ throw new IgniteException("Directory listing doesn't contain expected entry: " + name);
+
+ listing.put(name, new IgfsListingEntry(id, oldEntry.isDirectory()));
+
+ e.setValue(fileInfo.listing(listing));
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeString(out, name);
+ out.writeObject(id);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = U.readString(in);
+ id = (IgniteUuid)in.readObject();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
new file mode 100644
index 0000000..a07d764
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
@@ -0,0 +1,110 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Map;
+
+/**
+ * File create processor.
+ */
+public class IgfsMetaFileCreateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Create time. */
+ private long createTime;
+
+ /** Properties. */
+ private Map<String, String> props;
+
+ /** Block size. */
+ private int blockSize;
+
+ /** Affintiy key. */
+ private IgniteUuid affKey;
+
+ /** Lcok ID. */
+ private IgniteUuid lockId;
+
+ /** Evict exclude flag. */
+ private boolean evictExclude;
+
+ /**
+ * Constructor.
+ */
+ public IgfsMetaFileCreateProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param createTime Create time.
+ * @param props Properties.
+ * @param blockSize Block size.
+ * @param affKey Affinity key.
+ * @param lockId Lock ID.
+ * @param evictExclude Evict exclude flag.
+ */
+ public IgfsMetaFileCreateProcessor(long createTime, Map<String, String> props, int blockSize,
+ @Nullable IgniteUuid affKey, IgniteUuid lockId, boolean evictExclude) {
+ this.createTime = createTime;
+ this.props = props;
+ this.blockSize = blockSize;
+ this.affKey = affKey;
+ this.lockId = lockId;
+ this.evictExclude = evictExclude;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsEntryInfo info = IgfsUtils.createFile(
+ entry.getKey(),
+ blockSize,
+ 0L,
+ affKey,
+ lockId,
+ evictExclude,
+ props,
+ createTime,
+ createTime
+ );
+
+ entry.setValue(info);
+
+ return info;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(createTime);
+ U.writeStringMap(out, props);
+ out.writeInt(blockSize);
+ out.writeObject(affKey);
+ out.writeObject(lockId);
+ out.writeBoolean(evictExclude);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ createTime = in.readLong();
+ props = U.readStringMap(in);
+ blockSize = in.readInt();
+ affKey = (IgniteUuid)in.readObject();
+ lockId = (IgniteUuid)in.readObject();
+ evictExclude = in.readBoolean();
+ }
+}
[34/50] [abbrv] ignite git commit: IGNITE-2876: Fixed possible
starvation in system pool caused by IgfsBlockMessage. This closes #575.
Posted by sb...@apache.org.
IGNITE-2876: Fixed possible starvation in system pool caused by IgfsBlockMessage. This closes #575.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/01a6e86e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/01a6e86e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/01a6e86e
Branch: refs/heads/ignite-1837
Commit: 01a6e86ec4e19d372b8efbc5c497c84f4238a46c
Parents: 00a0e4b
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Mar 24 13:28:30 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:14:27 2016 +0300
----------------------------------------------------------------------
.../managers/communication/GridIoManager.java | 11 +
.../managers/communication/GridIoPolicy.java | 3 +
.../processors/igfs/IgfsDataManager.java | 29 +-
.../processors/igfs/IgfsDeleteWorker.java | 2 +-
.../igfs/IgfsFragmentizerManager.java | 4 +-
...lockMessageSystemPoolStarvationSelfTest.java | 299 +++++++++++++++++++
.../ignite/testsuites/IgniteIgfsTestSuite.java | 3 +
7 files changed, 329 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/01a6e86e/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index 0438b64..8ba6a1c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -87,6 +87,7 @@ import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.internal.GridTopic.TOPIC_COMM_USER;
import static org.apache.ignite.internal.managers.communication.GridIoPolicy.AFFINITY_POOL;
+import static org.apache.ignite.internal.managers.communication.GridIoPolicy.IGFS_POOL;
import static org.apache.ignite.internal.managers.communication.GridIoPolicy.MANAGEMENT_POOL;
import static org.apache.ignite.internal.managers.communication.GridIoPolicy.MARSH_CACHE_POOL;
import static org.apache.ignite.internal.managers.communication.GridIoPolicy.P2P_POOL;
@@ -146,6 +147,9 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
/** Marshaller cache pool. */
private ExecutorService marshCachePool;
+ /** IGFS pool. */
+ private ExecutorService igfsPool;
+
/** Discovery listener. */
private GridLocalEventListener discoLsnr;
@@ -244,6 +248,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
mgmtPool = ctx.getManagementExecutorService();
utilityCachePool = ctx.utilityCachePool();
marshCachePool = ctx.marshallerCachePool();
+ igfsPool = ctx.getIgfsExecutorService();
affPool = new IgniteThreadPoolExecutor(
"aff",
ctx.gridName(),
@@ -635,6 +640,7 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
case AFFINITY_POOL:
case UTILITY_CACHE_POOL:
case MARSH_CACHE_POOL:
+ case IGFS_POOL:
{
if (msg.isOrdered())
processOrderedMessage(nodeId, msg, plc, msgC);
@@ -695,6 +701,11 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
return marshCachePool;
+ case IGFS_POOL:
+ assert igfsPool != null : "IGFS pool is not configured.";
+
+ return igfsPool;
+
default: {
assert plc >= 0 : "Negative policy: " + plc;
http://git-wip-us.apache.org/repos/asf/ignite/blob/01a6e86e/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoPolicy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoPolicy.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoPolicy.java
index 57622c9..00590ba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoPolicy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoPolicy.java
@@ -43,6 +43,9 @@ public class GridIoPolicy {
/** Marshaller cache execution pool. */
public static final byte MARSH_CACHE_POOL = 6;
+ /** Marshaller cache execution pool. */
+ public static final byte IGFS_POOL = 7;
+
/**
* Defines the range of reserved pools that are not available for plugins.
* @param key The key.
http://git-wip-us.apache.org/repos/asf/ignite/blob/01a6e86e/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index 3825086..16fbeb8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@ -91,7 +91,7 @@ import java.util.concurrent.locks.ReentrantLock;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.internal.GridTopic.TOPIC_IGFS;
-import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL;
+import static org.apache.ignite.internal.managers.communication.GridIoPolicy.IGFS_POOL;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
@@ -1014,26 +1014,18 @@ public class IgfsDataManager extends IgfsManager {
if (!node.isLocal()) {
final IgfsBlocksMessage msg = new IgfsBlocksMessage(fileId, batchId, blocks);
- callIgfsLocalSafe(new GridPlainCallable<Object>() {
- @Override @Nullable public Object call() throws Exception {
- try {
- igfsCtx.send(nodeId, topic, msg, SYSTEM_POOL);
- } catch (IgniteCheckedException e) {
- completionFut.onError(nodeId, e);
- }
-
- return null;
- }
- });
+ try {
+ igfsCtx.send(nodeId, topic, msg, IGFS_POOL);
+ }
+ catch (IgniteCheckedException e) {
+ completionFut.onError(nodeId, e);
+ }
}
else {
callIgfsLocalSafe(new GridPlainCallable<Object>() {
- @Override
- @Nullable
- public Object call() throws Exception {
+ @Override @Nullable public Object call() throws Exception {
storeBlocksAsync(blocks).listen(new CI1<IgniteInternalFuture<?>>() {
- @Override
- public void apply(IgniteInternalFuture<?> fut) {
+ @Override public void apply(IgniteInternalFuture<?> fut) {
try {
fut.get();
@@ -1276,8 +1268,7 @@ public class IgfsDataManager extends IgfsManager {
try {
// Send reply back to node.
- igfsCtx.send(nodeId, topic, new IgfsAckMessage(blocksMsg.fileId(), blocksMsg.id(), err),
- SYSTEM_POOL);
+ igfsCtx.send(nodeId, topic, new IgfsAckMessage(blocksMsg.fileId(), blocksMsg.id(), err), IGFS_POOL);
}
catch (IgniteCheckedException e) {
U.warn(log, "Failed to send batch acknowledgement (did node leave the grid?) [nodeId=" + nodeId +
http://git-wip-us.apache.org/repos/asf/ignite/blob/01a6e86e/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
index 7e4dac8..e5914e0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
@@ -357,7 +357,7 @@ public class IgfsDeleteWorker extends IgfsThread {
for (ClusterNode node : nodes) {
try {
- igfsCtx.send(node, topic, msg, GridIoPolicy.SYSTEM_POOL);
+ igfsCtx.send(node, topic, msg, GridIoPolicy.IGFS_POOL);
}
catch (IgniteCheckedException e) {
U.warn(log, "Failed to send IGFS delete message to node [nodeId=" + node.id() +
http://git-wip-us.apache.org/repos/asf/ignite/blob/01a6e86e/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
index 99e7cd6..d64c64a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
@@ -59,7 +59,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.internal.GridTopic.TOPIC_IGFS;
-import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL;
+import static org.apache.ignite.internal.managers.communication.GridIoPolicy.IGFS_POOL;
import static org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange.RANGE_STATUS_INITIAL;
import static org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange.RANGE_STATUS_MOVED;
import static org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange.RANGE_STATUS_MOVING;
@@ -186,7 +186,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
private void sendWithRetries(UUID nodeId, IgfsCommunicationMessage msg) throws IgniteCheckedException {
for (int i = 0; i < MESSAGE_SEND_RETRY_COUNT; i++) {
try {
- igfsCtx.send(nodeId, topic, msg, SYSTEM_POOL);
+ igfsCtx.send(nodeId, topic, msg, IGFS_POOL);
return;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/01a6e86e/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java
new file mode 100644
index 0000000..ec3b808
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsBlockMessageSystemPoolStarvationSelfTest.java
@@ -0,0 +1,299 @@
+/*
+ * 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.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteFileSystem;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.FileSystemConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
+import org.apache.ignite.igfs.IgfsMode;
+import org.apache.ignite.igfs.IgfsOutputStream;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
+import org.apache.ignite.internal.util.lang.GridAbsPredicateX;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ * Test to check for system pool starvation due to {@link IgfsBlocksMessage}.
+ */
+public class IgfsBlockMessageSystemPoolStarvationSelfTest extends IgfsCommonAbstractTest {
+ /** First node name. */
+ private static final String NODE_1_NAME = "node1";
+
+ /** Second node name. */
+ private static final String NODE_2_NAME = "node2";
+
+ /** Data cache name. */
+ private static final String DATA_CACHE_NAME = "data";
+
+ /** Meta cache name. */
+ private static final String META_CACHE_NAME = "meta";
+
+ /** Key in data caceh we will use to reproduce the issue. */
+ private static final Integer DATA_KEY = 1;
+
+ /** First node. */
+ private Ignite victim;
+
+ /** Second node. */
+ private Ignite attacker;
+
+ /** {@inheritDoc} */
+ @SuppressWarnings({"unchecked", "ConstantConditions"})
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ // Start nodes.
+ TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ victim = Ignition.start(config(NODE_1_NAME, ipFinder));
+ attacker = Ignition.start(config(NODE_2_NAME, ipFinder));
+
+ // Check if we selected victim correctly.
+ if (F.eq(dataCache(victim).affinity().mapKeyToNode(DATA_KEY).id(), attacker.cluster().localNode().id())) {
+ Ignite tmp = victim;
+
+ victim = attacker;
+
+ attacker = tmp;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ G.stopAll(true);
+
+ victim = null;
+ attacker = null;
+
+ super.afterTest();
+ }
+
+ /**
+ * Test starvation.
+ *
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("unchecked")
+ public void testStarvation() throws Exception {
+ // 1. Create two IGFS file to make all system threads busy.
+ CountDownLatch fileWriteLatch = new CountDownLatch(1);
+
+ final IgniteInternalFuture fileFut1 = createFileAsync(new IgfsPath("/file1"), fileWriteLatch);
+ final IgniteInternalFuture fileFut2 = createFileAsync(new IgfsPath("/file2"), fileWriteLatch);
+
+ // 2. Start transaction and keep it opened.
+ final CountDownLatch txStartLatch = new CountDownLatch(1);
+ final CountDownLatch txCommitLatch = new CountDownLatch(1);
+
+ IgniteInternalFuture<Void> txFut = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ GridCacheAdapter dataCache = dataCache(attacker);
+
+ try (IgniteInternalTx tx =
+ dataCache.txStartEx(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)) {
+ dataCache.put(DATA_KEY, 0);
+
+ txStartLatch.countDown();
+
+ txCommitLatch.await();
+
+ tx.commit();
+ }
+
+ return null;
+ }
+ });
+
+ txStartLatch.await();
+
+ // 3. Start async operation to drain semaphore permits.
+ final IgniteInternalFuture putFut = dataCache(victim).putAsync(DATA_KEY, 1);
+
+ assert !awaitFuture(putFut);
+
+ // 4. Write data to files and ensure we stuck.
+ fileWriteLatch.countDown();
+
+ assert !awaitFuture(fileFut1);
+ assert !awaitFuture(fileFut2);
+
+ // 5. Finish transaction.
+ txCommitLatch.countDown();
+
+ assert awaitFuture(txFut);
+
+ // 6. Async put must succeed.
+ assert awaitFuture(putFut);
+
+ // 7. Writes must succeed.
+ assert awaitFuture(fileFut1);
+ assert awaitFuture(fileFut2);
+ }
+
+ /**
+ * Await future completion.
+ *
+ * @param fut Future.
+ * @return {@code True} if future completed.
+ * @throws Exception If failed.
+ */
+ private static boolean awaitFuture(final IgniteInternalFuture fut) throws Exception {
+ return GridTestUtils.waitForCondition(new GridAbsPredicateX() {
+ @Override public boolean applyx() throws IgniteCheckedException {
+ return fut.isDone();
+ }
+ }, 1000);
+ }
+
+ /**
+ * Create IGFS file asynchronously.
+ *
+ * @param path Path.
+ * @return Future.
+ */
+ private IgniteInternalFuture<Void> createFileAsync(final IgfsPath path, final CountDownLatch writeStartLatch) {
+ return GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ IgniteFileSystem igfs = attacker.fileSystem(null);
+
+ try (IgfsOutputStream out = igfs.create(path, true)) {
+ writeStartLatch.await();
+
+ out.write(new byte[1024]);
+
+ out.flush();
+ }
+
+ return null;
+ }
+ });
+ }
+
+ /**
+ * Get data cache for node.
+ *
+ * @param node Node.
+ * @return Data cache.
+ * @throws Exception If failed.
+ */
+ private GridCacheAdapter dataCache(Ignite node) throws Exception {
+ return ((IgniteKernal)node).internalCache(DATA_CACHE_NAME);
+ }
+
+ /**
+ * Create node configuration.
+ *
+ * @param name Node name.
+ * @return Configuration.
+ * @throws Exception If failed.
+ */
+ private IgniteConfiguration config(String name, TcpDiscoveryVmIpFinder ipFinder) throws Exception {
+ // Data cache configuration.
+ CacheConfiguration dataCcfg = new CacheConfiguration();
+
+ dataCcfg.setName(DATA_CACHE_NAME);
+ dataCcfg.setCacheMode(CacheMode.REPLICATED);
+ dataCcfg.setAtomicityMode(TRANSACTIONAL);
+ dataCcfg.setWriteSynchronizationMode(FULL_SYNC);
+ dataCcfg.setAffinityMapper(new DummyAffinityMapper(1));
+ dataCcfg.setMaxConcurrentAsyncOperations(1);
+
+ // Meta cache configuration.
+ CacheConfiguration metaCcfg = new CacheConfiguration();
+
+ metaCcfg.setName(META_CACHE_NAME);
+ metaCcfg.setCacheMode(CacheMode.REPLICATED);
+ metaCcfg.setAtomicityMode(TRANSACTIONAL);
+ metaCcfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ // File system configuration.
+ FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
+
+ igfsCfg.setDefaultMode(IgfsMode.PRIMARY);
+ igfsCfg.setDataCacheName(DATA_CACHE_NAME);
+ igfsCfg.setMetaCacheName(META_CACHE_NAME);
+ igfsCfg.setFragmentizerEnabled(false);
+ igfsCfg.setBlockSize(1024);
+
+ // Ignite configuration.
+ IgniteConfiguration cfg = getConfiguration(name);
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ discoSpi.setIpFinder(ipFinder);
+
+ cfg.setDiscoverySpi(discoSpi);
+ cfg.setCacheConfiguration(dataCcfg, metaCcfg);
+ cfg.setFileSystemConfiguration(igfsCfg);
+
+ cfg.setLocalHost("127.0.0.1");
+ cfg.setConnectorConfiguration(null);
+
+ cfg.setSystemThreadPoolSize(2);
+ cfg.setRebalanceThreadPoolSize(1);
+ cfg.setPublicThreadPoolSize(1);
+
+ return cfg;
+ }
+
+ /**
+ * Dimmy affinity mapper.
+ */
+ private static class DummyAffinityMapper extends IgfsGroupDataBlocksKeyMapper {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Dummy affinity key. */
+ private static final Integer KEY = 1;
+
+ /**
+ * Constructor.
+ *
+ * @param grpSize Group size.
+ */
+ public DummyAffinityMapper(int grpSize) {
+ super(grpSize);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object affinityKey(Object key) {
+ return KEY;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/01a6e86e/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
index aff3ad7..25c54e4 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsAttributesSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsBackupsDualAsyncSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsBackupsDualSyncSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsBackupsPrimarySelfTest;
+import org.apache.ignite.internal.processors.igfs.IgfsBlockMessageSystemPoolStarvationSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsCachePerBlockLruEvictionPolicySelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsCacheSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsClientCacheSelfTest;
@@ -118,6 +119,8 @@ public class IgniteIgfsTestSuite extends TestSuite {
suite.addTestSuite(IgfsBackupsDualSyncSelfTest.class);
suite.addTestSuite(IgfsBackupsDualAsyncSelfTest.class);
+ suite.addTestSuite(IgfsBlockMessageSystemPoolStarvationSelfTest.class);
+
// TODO: Enable when IGFS failover is fixed.
//suite.addTestSuite(IgfsBackupFailoverSelfTest.class);
[37/50] [abbrv] ignite git commit: Minor change to Visor classes:
added setters for name and queryMetrics properties.
Posted by sb...@apache.org.
Minor change to Visor classes: added setters for name and queryMetrics properties.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/28d2a7bf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/28d2a7bf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/28d2a7bf
Branch: refs/heads/ignite-1837
Commit: 28d2a7bf7f35ec4b51fba872ace47cdbc255ded8
Parents: 0412c9b
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Wed Mar 30 14:42:12 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Wed Mar 30 14:42:12 2016 +0700
----------------------------------------------------------------------
.../ignite/internal/visor/cache/VisorCache.java | 9 +++++++++
.../internal/visor/cache/VisorCacheMetrics.java | 18 ++++++++++++++++++
2 files changed, 27 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d2a7bf/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
index 7cd0669..b5151c7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
@@ -301,6 +301,15 @@ public class VisorCache implements Serializable {
}
/**
+ * Sets new value for cache name.
+ *
+ * @param name New cache name.
+ */
+ public void name(String name) {
+ this.name = name;
+ }
+
+ /**
* @return Dynamic deployment ID.
*/
public IgniteUuid dynamicDeploymentId() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/28d2a7bf/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java
index 1a88813..0397fe0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheMetrics.java
@@ -238,6 +238,15 @@ public class VisorCacheMetrics implements Serializable {
}
/**
+ * Sets cache name.
+ *
+ * @param name New value for cache name.
+ */
+ public void name(String name) {
+ this.name = name;
+ }
+
+ /**
* @return Cache mode.
*/
public CacheMode mode() {
@@ -406,6 +415,15 @@ public class VisorCacheMetrics implements Serializable {
}
/**
+ * Sets cache query metrics.
+ *
+ * @param qryMetrics New value for query metrics.
+ */
+ public void queryMetrics(VisorCacheQueryMetrics qryMetrics) {
+ this.qryMetrics = qryMetrics;
+ }
+
+ /**
* @return Current size of evict queue used to batch up evictions.
*/
public int dhtEvictQueueCurrentSize() {
[21/50] [abbrv] ignite git commit: IGNITE-2813: IGFS: Optimized
metadata values splitting file and directory into separate classes.
Posted by sb...@apache.org.
IGNITE-2813: IGFS: Optimized metadata values splitting file and directory into separate classes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bfa7bf6c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bfa7bf6c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bfa7bf6c
Branch: refs/heads/ignite-1837
Commit: bfa7bf6c3d693406f1dd5121488796687aebbe7d
Parents: 8e9e790
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Mar 18 17:45:48 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:38 2016 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsDataManager.java | 103 ++--
.../processors/igfs/IgfsDeleteWorker.java | 27 +-
.../processors/igfs/IgfsDirectoryInfo.java | 210 ++++++++
.../internal/processors/igfs/IgfsEntryInfo.java | 305 +++++++++++
.../internal/processors/igfs/IgfsFileImpl.java | 15 +-
.../internal/processors/igfs/IgfsFileInfo.java | 500 +++----------------
.../processors/igfs/IgfsFileWorkerBatch.java | 75 +--
.../IgfsFileWorkerBatchCancelledException.java | 51 ++
.../igfs/IgfsFragmentizerManager.java | 64 ++-
.../internal/processors/igfs/IgfsImpl.java | 28 +-
.../processors/igfs/IgfsInputStreamAdapter.java | 5 +-
.../processors/igfs/IgfsInputStreamImpl.java | 32 +-
.../processors/igfs/IgfsIpcHandler.java | 16 +-
.../processors/igfs/IgfsListingEntry.java | 12 +-
.../processors/igfs/IgfsMetaManager.java | 432 ++++++++--------
.../processors/igfs/IgfsOutputStreamImpl.java | 19 +-
.../internal/processors/igfs/IgfsPathIds.java | 4 +-
.../processors/igfs/IgfsPathsCreateResult.java | 6 +-
.../IgfsSecondaryInputStreamDescriptor.java | 6 +-
.../IgfsSecondaryOutputStreamDescriptor.java | 9 +-
.../internal/processors/igfs/IgfsUtils.java | 68 +++
.../internal/processors/igfs/package-info.java | 2 +-
.../igfs/IgfsFragmentizerAbstractSelfTest.java | 4 +-
.../processors/igfs/IgfsAbstractSelfTest.java | 4 +-
.../igfs/IgfsDataManagerSelfTest.java | 55 +-
.../igfs/IgfsDualAbstractSelfTest.java | 17 +-
.../processors/igfs/IgfsFileInfoSelfTest.java | 31 +-
.../igfs/IgfsMetaManagerSelfTest.java | 34 +-
.../processors/igfs/IgfsProcessorSelfTest.java | 31 +-
.../processors/igfs/IgfsSizeSelfTest.java | 35 +-
.../processors/igfs/IgfsStreamsSelfTest.java | 25 +-
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 32 +-
.../igfs/HadoopIgfsDualAbstractSelfTest.java | 11 +-
.../IgniteHadoopFileSystemLoggerSelfTest.java | 21 +-
.../testsuites/IgniteHadoopTestSuite.java | 26 +-
35 files changed, 1321 insertions(+), 994 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index 125d728..3825086 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@ -17,35 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.DataInput;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Deque;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.RejectedExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.MutableEntry;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteException;
@@ -87,6 +58,36 @@ import org.apache.ignite.thread.IgniteThreadPoolExecutor;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.MutableEntry;
+import java.io.DataInput;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.internal.GridTopic.TOPIC_IGFS;
@@ -368,7 +369,7 @@ public class IgfsDataManager extends IgfsManager {
* @return Requested data block or {@code null} if nothing found.
* @throws IgniteCheckedException If failed.
*/
- @Nullable public IgniteInternalFuture<byte[]> dataBlock(final IgfsFileInfo fileInfo, final IgfsPath path,
+ @Nullable public IgniteInternalFuture<byte[]> dataBlock(final IgfsEntryInfo fileInfo, final IgfsPath path,
final long blockIdx, @Nullable final IgfsSecondaryFileSystemPositionedReadable secReader)
throws IgniteCheckedException {
//assert validTxState(any); // Allow this method call for any transaction state.
@@ -476,7 +477,7 @@ public class IgfsDataManager extends IgfsManager {
* @param fileInfo File info of file opened to write.
* @return Future that will be completed when all ack messages are received or when write failed.
*/
- public IgniteInternalFuture<Boolean> writeStart(IgfsFileInfo fileInfo) {
+ public IgniteInternalFuture<Boolean> writeStart(IgfsEntryInfo fileInfo) {
WriteCompletionFuture fut = new WriteCompletionFuture(fileInfo.id());
WriteCompletionFuture oldFut = pendingWrites.putIfAbsent(fileInfo.id(), fut);
@@ -495,7 +496,7 @@ public class IgfsDataManager extends IgfsManager {
*
* @param fileInfo File info being written.
*/
- public void writeClose(IgfsFileInfo fileInfo) {
+ public void writeClose(IgfsEntryInfo fileInfo) {
WriteCompletionFuture fut = pendingWrites.get(fileInfo.id());
if (fut != null)
@@ -524,7 +525,7 @@ public class IgfsDataManager extends IgfsManager {
* @throws IgniteCheckedException If failed.
*/
@Nullable public byte[] storeDataBlocks(
- IgfsFileInfo fileInfo,
+ IgfsEntryInfo fileInfo,
long reservedLen,
@Nullable byte[] remainder,
int remainderLen,
@@ -557,7 +558,7 @@ public class IgfsDataManager extends IgfsManager {
* @throws IOException If store failed.
*/
@Nullable public byte[] storeDataBlocks(
- IgfsFileInfo fileInfo,
+ IgfsEntryInfo fileInfo,
long reservedLen,
@Nullable byte[] remainder,
int remainderLen,
@@ -579,7 +580,7 @@ public class IgfsDataManager extends IgfsManager {
* @param fileInfo File details to remove data for.
* @return Delete future that will be completed when file is actually erased.
*/
- public IgniteInternalFuture<Object> delete(IgfsFileInfo fileInfo) {
+ public IgniteInternalFuture<Object> delete(IgfsEntryInfo fileInfo) {
if (!fileInfo.isFile()) {
if (log.isDebugEnabled())
log.debug("Cannot delete content of not-data file: " + fileInfo);
@@ -595,7 +596,7 @@ public class IgfsDataManager extends IgfsManager {
* @param fileInfo File info.
* @return Block key.
*/
- public IgfsBlockKey blockKey(long blockIdx, IgfsFileInfo fileInfo) {
+ public IgfsBlockKey blockKey(long blockIdx, IgfsEntryInfo fileInfo) {
if (fileInfo.affinityKey() != null)
return new IgfsBlockKey(fileInfo.id(), fileInfo.affinityKey(), fileInfo.evictExclude(), blockIdx);
@@ -616,7 +617,7 @@ public class IgfsDataManager extends IgfsManager {
* @param range Range to clean up.
* @param cleanNonColocated {@code True} if all blocks should be cleaned.
*/
- public void cleanBlocks(IgfsFileInfo fileInfo, IgfsFileAffinityRange range, boolean cleanNonColocated) {
+ public void cleanBlocks(IgfsEntryInfo fileInfo, IgfsFileAffinityRange range, boolean cleanNonColocated) {
long startIdx = range.startOffset() / fileInfo.blockSize();
long endIdx = range.endOffset() / fileInfo.blockSize();
@@ -646,7 +647,7 @@ public class IgfsDataManager extends IgfsManager {
* @param fileInfo File info to move data for.
* @param range Range to move.
*/
- public void spreadBlocks(IgfsFileInfo fileInfo, IgfsFileAffinityRange range) {
+ public void spreadBlocks(IgfsEntryInfo fileInfo, IgfsFileAffinityRange range) {
long startIdx = range.startOffset() / fileInfo.blockSize();
long endIdx = range.endOffset() / fileInfo.blockSize();
@@ -721,7 +722,7 @@ public class IgfsDataManager extends IgfsManager {
* @return Affinity blocks locations.
* @throws IgniteCheckedException If failed.
*/
- public Collection<IgfsBlockLocation> affinity(IgfsFileInfo info, long start, long len)
+ public Collection<IgfsBlockLocation> affinity(IgfsEntryInfo info, long start, long len)
throws IgniteCheckedException {
return affinity(info, start, len, 0);
}
@@ -736,7 +737,7 @@ public class IgfsDataManager extends IgfsManager {
* @return Affinity blocks locations.
* @throws IgniteCheckedException If failed.
*/
- public Collection<IgfsBlockLocation> affinity(IgfsFileInfo info, long start, long len, long maxLen)
+ public Collection<IgfsBlockLocation> affinity(IgfsEntryInfo info, long start, long len, long maxLen)
throws IgniteCheckedException {
assert validTxState(false);
assert info.isFile() : "Failed to get affinity (not a file): " + info;
@@ -845,7 +846,7 @@ public class IgfsDataManager extends IgfsManager {
* @param maxLen Maximum allowed split length.
* @param res Result collection to add regions to.
*/
- private void affinity0(IgfsFileInfo info, long start, long len, long maxLen, Deque<IgfsBlockLocation> res) {
+ private void affinity0(IgfsEntryInfo info, long start, long len, long maxLen, Deque<IgfsBlockLocation> res) {
long firstGrpIdx = start / grpBlockSize;
long limitGrpIdx = (start + len + grpBlockSize - 1) / grpBlockSize;
@@ -1327,7 +1328,7 @@ public class IgfsDataManager extends IgfsManager {
*/
private IgfsBlockKey createBlockKey(
long block,
- IgfsFileInfo fileInfo,
+ IgfsEntryInfo fileInfo,
IgfsFileAffinityRange locRange
) {
// If affinityKey is present, return block key as is.
@@ -1373,7 +1374,7 @@ public class IgfsDataManager extends IgfsManager {
* @return Data remainder if {@code flush} flag is {@code false}.
*/
@Nullable public byte[] storeDataBlocks(
- IgfsFileInfo fileInfo,
+ IgfsEntryInfo fileInfo,
long reservedLen,
@Nullable byte[] remainder,
final int remainderLen,
@@ -1632,10 +1633,10 @@ public class IgfsDataManager extends IgfsManager {
*/
private class AsyncDeleteWorker extends GridWorker {
/** File info for stop request. */
- private final IgfsFileInfo stopInfo = new IgfsFileInfo();
+ private final IgfsEntryInfo stopInfo;
/** Delete requests queue. */
- private BlockingQueue<IgniteBiTuple<GridFutureAdapter<Object>, IgfsFileInfo>> delReqs =
+ private BlockingQueue<IgniteBiTuple<GridFutureAdapter<Object>, IgfsEntryInfo>> delReqs =
new LinkedBlockingQueue<>();
/**
@@ -1645,6 +1646,10 @@ public class IgfsDataManager extends IgfsManager {
*/
protected AsyncDeleteWorker(@Nullable String gridName, String name, IgniteLogger log) {
super(gridName, name, log);
+
+ long time = System.currentTimeMillis();
+
+ stopInfo = IgfsUtils.createDirectory(IgniteUuid.randomUuid());
}
/**
@@ -1658,7 +1663,7 @@ public class IgfsDataManager extends IgfsManager {
* @param info File info to delete.
* @return Future which completes when entry is actually removed.
*/
- private IgniteInternalFuture<Object> deleteAsync(IgfsFileInfo info) {
+ private IgniteInternalFuture<Object> deleteAsync(IgfsEntryInfo info) {
GridFutureAdapter<Object> fut = new GridFutureAdapter<>();
delReqs.offer(F.t(fut, info));
@@ -1670,10 +1675,10 @@ public class IgfsDataManager extends IgfsManager {
@Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException {
try {
while (!isCancelled()) {
- IgniteBiTuple<GridFutureAdapter<Object>, IgfsFileInfo> req = delReqs.take();
+ IgniteBiTuple<GridFutureAdapter<Object>, IgfsEntryInfo> req = delReqs.take();
GridFutureAdapter<Object> fut = req.get1();
- IgfsFileInfo fileInfo = req.get2();
+ IgfsEntryInfo fileInfo = req.get2();
// Identity check.
if (fileInfo == stopInfo) {
@@ -1734,7 +1739,7 @@ public class IgfsDataManager extends IgfsManager {
if (log.isDebugEnabled())
log.debug("Stopping asynchronous igfs file delete thread: " + name());
- IgniteBiTuple<GridFutureAdapter<Object>, IgfsFileInfo> req = delReqs.poll();
+ IgniteBiTuple<GridFutureAdapter<Object>, IgfsEntryInfo> req = delReqs.poll();
while (req != null) {
req.get1().onCancelled();
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
index ffddd3e..f6b26ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDeleteWorker.java
@@ -17,13 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cluster.ClusterNode;
@@ -37,6 +30,14 @@ import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_PURGED;
import static org.apache.ignite.internal.GridTopic.TOPIC_IGFS;
@@ -162,7 +163,7 @@ public class IgfsDeleteWorker extends IgfsThread {
* @param trashId Trash ID.
*/
private void delete(IgniteUuid trashId) {
- IgfsFileInfo info = null;
+ IgfsEntryInfo info = null;
try {
info = meta.info(trashId);
@@ -220,7 +221,7 @@ public class IgfsDeleteWorker extends IgfsThread {
assert id != null;
while (true) {
- IgfsFileInfo info = meta.info(id);
+ IgfsEntryInfo info = meta.info(id);
if (info != null) {
if (info.isDirectory()) {
@@ -234,7 +235,7 @@ public class IgfsDeleteWorker extends IgfsThread {
assert info.isFile();
// Lock the file with special lock Id to prevent concurrent writing:
- IgfsFileInfo lockedInfo = meta.lock(id, true);
+ IgfsEntryInfo lockedInfo = meta.lock(id, true);
if (lockedInfo == null)
return false; // File is locked, we cannot delete it.
@@ -271,7 +272,7 @@ public class IgfsDeleteWorker extends IgfsThread {
assert id != null;
while (true) {
- IgfsFileInfo info = meta.info(id);
+ IgfsEntryInfo info = meta.info(id);
if (info != null) {
assert info.isDirectory();
@@ -298,12 +299,12 @@ public class IgfsDeleteWorker extends IgfsThread {
failedFiles++;
}
else {
- IgfsFileInfo fileInfo = meta.info(entry.getValue().fileId());
+ IgfsEntryInfo fileInfo = meta.info(entry.getValue().fileId());
if (fileInfo != null) {
assert fileInfo.isFile();
- IgfsFileInfo lockedInfo = meta.lock(fileInfo.id(), true);
+ IgfsEntryInfo lockedInfo = meta.lock(fileInfo.id(), true);
if (lockedInfo == null)
// File is already locked:
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
new file mode 100644
index 0000000..01c8ff9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
@@ -0,0 +1,210 @@
+/*
+ * 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.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * IGFS directory info.
+ */
+public class IgfsDirectoryInfo extends IgfsEntryInfo {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Directory listing. */
+ @GridToStringInclude
+ private Map<String, IgfsListingEntry> listing;
+
+ /**
+ * {@link Externalizable} support.
+ */
+ public IgfsDirectoryInfo() {
+ // No-op.
+ }
+
+ /**
+ * Update length.
+ *
+ * @param len New length.
+ * @return Updated file info.
+ */
+ public IgfsEntryInfo length(long len) {
+ throw new UnsupportedOperationException("length");
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsDirectoryInfo listing(@Nullable Map<String, IgfsListingEntry> listing) {
+ IgfsDirectoryInfo res = copy();
+
+ res.listing = listing;
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo lock(IgniteUuid lockId) {
+ throw new UnsupportedOperationException("lock");
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo unlock(long modificationTime) {
+ throw new UnsupportedOperationException("unlock");
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo fileMap(IgfsFileMap fileMap) {
+ throw new UnsupportedOperationException("fileMap");
+ }
+
+ /**
+ * Constructs file info.
+ *
+ * @param id ID or {@code null} to generate it automatically.
+ * @param listing Directory listing.
+ * @param props File properties.
+ * @param accessTime Last access time.
+ * @param modificationTime Last modification time.
+ */
+ IgfsDirectoryInfo(IgniteUuid id, @Nullable Map<String, IgfsListingEntry> listing,
+ @Nullable Map<String, String> props, long accessTime, long modificationTime) {
+ super(id, props, accessTime, modificationTime);
+
+ this.listing = listing;
+ }
+
+ /** {@inheritDoc} */
+ protected IgfsDirectoryInfo copy() {
+ return new IgfsDirectoryInfo(id, listing, props, accessTime, modificationTime);
+ }
+
+ /** {@inheritDoc} */
+ public boolean isFile() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ public long length() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ public int blockSize() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ public long blocksCount() {
+ return 0;
+ }
+
+ /** {@inheritDoc} */
+ public Map<String, IgfsListingEntry> listing() {
+ return listing != null ? listing : Collections.<String, IgfsListingEntry>emptyMap();
+ }
+
+ /** {@inheritDoc} */
+ public boolean hasChildren() {
+ return !F.isEmpty(listing);
+ }
+
+ /** {@inheritDoc} */
+ public boolean hasChild(String name) {
+ return listing != null && listing.containsKey(name);
+ }
+
+ /** {@inheritDoc} */
+ public boolean hasChild(String name, IgniteUuid expId) {
+ if (listing != null) {
+ IgfsListingEntry entry = listing.get(name);
+
+ if (entry != null)
+ return F.eq(expId, entry.fileId());
+ }
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable public IgniteUuid affinityKey() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ public IgfsFileMap fileMap() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable public IgniteUuid lockId() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ public boolean evictExclude() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+
+ out.writeObject(listing);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+
+ listing = (Map<String, IgfsListingEntry>)in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return id.hashCode() ^ (props == null ? 0 : props.hashCode());
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object obj) {
+ if (obj == this)
+ return true;
+
+ if (obj == null || getClass() != obj.getClass())
+ return false;
+
+ IgfsDirectoryInfo that = (IgfsDirectoryInfo)obj;
+
+ return id.equals(that.id) && F.eq(props, that.props);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsDirectoryInfo.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
new file mode 100644
index 0000000..c5b1111
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
@@ -0,0 +1,305 @@
+/*
+ * 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.igfs.IgfsPath;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * Base IGFS entry.
+ */
+public abstract class IgfsEntryInfo implements Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** ID. */
+ protected IgniteUuid id;
+
+ /** Properties. */
+ protected Map<String, String> props;
+
+ /** Last access time. */
+ protected long accessTime;
+
+ /** Last modification time. */
+ protected long modificationTime;
+
+ /** Original file path. This is a helper field used only during real file delete. */
+ protected IgfsPath path;
+
+ /**
+ * Default constructor.
+ */
+ protected IgfsEntryInfo() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param id ID.
+ * @param props Properties.
+ * @param accessTime Access time.
+ * @param modificationTime Modification time.
+ */
+ protected IgfsEntryInfo(IgniteUuid id, @Nullable Map<String, String> props, long accessTime,
+ long modificationTime) {
+ assert id != null;
+
+ this.id = id;
+ this.props = props == null || props.isEmpty() ? null : props;
+ this.accessTime = accessTime;
+ this.modificationTime = modificationTime;
+ }
+
+ /**
+ * Gets this item ID.
+ *
+ * @return This item ID.
+ */
+ public IgniteUuid id() {
+ return id;
+ }
+
+ /**
+ * Get properties of the file.
+ *
+ * @return Properties of the file.
+ */
+ public Map<String, String> properties() {
+ return props == null ? Collections.<String, String>emptyMap() : Collections.unmodifiableMap(props);
+ }
+
+ /**
+ * @return Last access time.
+ */
+ public long accessTime() {
+ return accessTime;
+ }
+
+ /**
+ * @return Last modification time.
+ */
+ public long modificationTime() {
+ return modificationTime;
+ }
+
+ /**
+ * @return Original file path. This is a helper field used only in some operations like delete.
+ */
+ public IgfsPath path() {
+ return path;
+ }
+
+ /**
+ * @return {@code True} if this is a file.
+ */
+ public abstract boolean isFile();
+
+ /**
+ * Update length.
+ *
+ * @param len New length.
+ * @return Updated file info.
+ */
+ public abstract IgfsEntryInfo length(long len);
+
+ /**
+ * Update listing.
+ *
+ * @param listing Listing.
+ * @return Updated file info.
+ */
+ public abstract IgfsEntryInfo listing(@Nullable Map<String, IgfsListingEntry> listing);
+
+ /**
+ * Update properties.
+ *
+ * @param props Properties.
+ * @return Updated file info.
+ */
+ public IgfsEntryInfo properties(@Nullable Map<String, String> props) {
+ IgfsEntryInfo res = copy();
+
+ res.props = props;
+
+ return res;
+ }
+
+ /**
+ * Update path.
+ *
+ * @param path Path.
+ * @return Updated file info.
+ */
+ public IgfsEntryInfo path(IgfsPath path) {
+ IgfsEntryInfo res = copy();
+
+ res.path = path;
+
+ return res;
+ }
+
+ /**
+ * Update access and modification time.
+ *
+ * @param accessTime Access time.
+ * @param modificationTime Modification time.
+ * @return Updated file info.
+ */
+ public IgfsEntryInfo accessModificationTime(long accessTime, long modificationTime) {
+ IgfsEntryInfo res = copy();
+
+ res.accessTime = accessTime;
+ res.modificationTime = modificationTime;
+
+ return res;
+ }
+
+ /**
+ * Lock file.
+ *
+ * @param lockId Lock ID.
+ * @return Update file info.
+ */
+ public abstract IgfsEntryInfo lock(IgniteUuid lockId);
+
+ /**
+ * Unlock file.
+ *
+ * @param modificationTime Modification time.
+ * @return Updated file info.
+ */
+ public abstract IgfsEntryInfo unlock(long modificationTime);
+
+ /**
+ * Update file map.
+ *
+ * @param fileMap File affinity map.
+ * @return Updated file info.
+ */
+ public abstract IgfsEntryInfo fileMap(IgfsFileMap fileMap);
+
+ /**
+ * Copy file info.
+ *
+ * @return Copy.
+ */
+ protected abstract IgfsEntryInfo copy();
+
+ /**
+ * @return {@code True} if this is a directory.
+ */
+ public boolean isDirectory() {
+ return !isFile();
+ }
+
+ /**
+ * Get file size.
+ *
+ * @return File size.
+ */
+ public abstract long length();
+
+ /**
+ * Get single data block size to store this file.
+ *
+ * @return Single data block size to store this file.
+ */
+ public abstract int blockSize();
+
+ /**
+ * @return Number of data blocks to store this file.
+ */
+ public abstract long blocksCount();
+
+ /**
+ * @return Directory listing.
+ */
+ public abstract Map<String, IgfsListingEntry> listing();
+
+ /**
+ * @return {@code True} if at least one child exists.
+ */
+ public abstract boolean hasChildren();
+
+ /**
+ * @param name Child name.
+ * @return {@code True} if child with such name exists.
+ */
+ public abstract boolean hasChild(String name);
+
+ /**
+ * @param name Child name.
+ * @param expId Expected child ID.
+ * @return {@code True} if child with such name exists.
+ */
+ public abstract boolean hasChild(String name, IgniteUuid expId);
+
+ /**
+ * @return Affinity key used for single-node file collocation. If {@code null}, usual
+ * mapper procedure is used for block affinity detection.
+ */
+ @Nullable public abstract IgniteUuid affinityKey();
+
+ /**
+ * @return File affinity map.
+ */
+ public abstract IgfsFileMap fileMap();
+
+ /**
+ * Get lock ID.
+ *
+ * @return Lock ID if file is locked or {@code null} if file is free of locks.
+ */
+ @Nullable public abstract IgniteUuid lockId();
+
+ /**
+ * Get evict exclude flag.
+ *
+ * @return Evict exclude flag.
+ */
+ public abstract boolean evictExclude();
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeGridUuid(out, id);
+ U.writeStringMap(out, props);
+ out.writeLong(accessTime);
+ out.writeLong(modificationTime);
+ out.writeObject(path);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ id = U.readGridUuid(in);
+ props = U.readStringMap(in);
+ accessTime = in.readLong();
+ modificationTime = in.readLong();
+ path = (IgfsPath)in.readObject();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
index 3576a06..be8d0fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileImpl.java
@@ -17,12 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Collections;
-import java.util.Map;
import org.apache.ignite.igfs.IgfsFile;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.util.typedef.internal.A;
@@ -31,6 +25,13 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collections;
+import java.util.Map;
+
/**
* File or directory information.
*/
@@ -97,7 +98,7 @@ public final class IgfsFileImpl implements IgfsFile, Externalizable {
*
* @param path Path.
*/
- public IgfsFileImpl(IgfsPath path, IgfsFileInfo info, long globalGrpBlockSize) {
+ public IgfsFileImpl(IgfsPath path, IgfsEntryInfo info, long globalGrpBlockSize) {
A.notNull(path, "path");
A.notNull(info, "info");
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
index 13c54ff..30f505e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
@@ -17,44 +17,32 @@
package org.apache.ignite.internal.processors.igfs;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
+
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Collections;
import java.util.Map;
-import org.apache.ignite.configuration.FileSystemConfiguration;
-import org.apache.ignite.igfs.IgfsPath;
-import org.apache.ignite.internal.util.GridLeanMap;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteUuid;
-import org.jetbrains.annotations.Nullable;
/**
- * Unmodifiable file information.
+ * IGFS file info.
*/
-public final class IgfsFileInfo implements Externalizable {
+public final class IgfsFileInfo extends IgfsEntryInfo {
/** */
private static final long serialVersionUID = 0L;
- /** Special access time value, indicating that the modification time value should be taken. */
- private static final long ACCESS_TIME_TAKE_MODIFICATION_TIME = -1L;
-
- /** Info ID. */
- private IgniteUuid id;
-
/** File length in bytes. */
private long len;
/** File block size, {@code zero} for directories. */
private int blockSize;
- /** File properties. */
- private Map<String, String> props;
-
/** File lock ID. */
private IgniteUuid lockId;
@@ -64,491 +52,181 @@ public final class IgfsFileInfo implements Externalizable {
/** File affinity map. */
private IgfsFileMap fileMap;
- /** Last access time. Modified on-demand. */
- private long accessTime;
-
- /** Last modification time. */
- private long modificationTime;
-
- /** Directory listing. */
- @GridToStringInclude
- private Map<String, IgfsListingEntry> listing;
-
/** Whether data blocks of this entry should never be excluded. */
private boolean evictExclude;
/**
- * Original file path. This is a helper field used only in some
- * operations like delete.
- */
- private IgfsPath path;
-
- /**
* {@link Externalizable} support.
*/
public IgfsFileInfo() {
- this(IgfsUtils.ROOT_ID);
+ // No-op.
}
- /**
- * Constructs directory file info with the given ID.
- *
- * @param id ID.
- */
- IgfsFileInfo(IgniteUuid id) {
- this(true, id, 0, 0, null, null, null, null, false, ACCESS_TIME_TAKE_MODIFICATION_TIME,
- System.currentTimeMillis(), false);
- }
+ /** {@inheritDoc} */
+ @Override public IgfsFileInfo length(long len) {
+ IgfsFileInfo res = copy();
- /**
- * Constructs directory or file info with
- * {@link org.apache.ignite.configuration.FileSystemConfiguration#DFLT_BLOCK_SIZE default} block size.
- *
- * @param isDir Constructs directory info if {@code true} or file info if {@code false}.
- * @param props Meta properties to set.
- * @param accessTime The access time.
- * @param modificationTime The modification time.
- */
- public IgfsFileInfo(boolean isDir, @Nullable Map<String, String> props, long accessTime, long modificationTime) {
- this(isDir, null, isDir ? 0 : FileSystemConfiguration.DFLT_BLOCK_SIZE, 0, null, null, props, null, false,
- accessTime, modificationTime, false);
- }
+ res.len = len;
- /**
- * Consturcts directory with random ID and provided listing.
- *
- * @param listing Listing.
- */
- IgfsFileInfo(Map<String, IgfsListingEntry> listing) {
- this(listing, (Map<String,String>)null);
+ return res;
}
- /**
- * Consturcts directory with random ID, provided listing and properties.
- *
- * @param listing Listing.
- * @param props The properties to set for the new directory.
- */
- IgfsFileInfo(@Nullable Map<String, IgfsListingEntry> listing, @Nullable Map<String,String> props) {
- this(true/*dir*/, null, 0, 0, null, listing, props, null, false, ACCESS_TIME_TAKE_MODIFICATION_TIME,
- System.currentTimeMillis(), false);
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo listing(@Nullable Map<String, IgfsListingEntry> listing) {
+ throw new UnsupportedOperationException("listing");
}
- /**
- * Constructs file info.
- *
- * @param blockSize Block size.
- * @param len Length.
- * @param affKey Affinity key.
- * @param lockId Lock ID.
- * @param props Properties.
- * @param evictExclude Evict exclude flag.
- * @param accessTime The access time.
- * @param modificationTime The modification time.
- */
- public IgfsFileInfo(int blockSize, long len, @Nullable IgniteUuid affKey, @Nullable IgniteUuid lockId,
- boolean evictExclude, @Nullable Map<String, String> props, long accessTime, long modificationTime) {
- this(false, null, blockSize, len, affKey, null, props, lockId, true, accessTime, modificationTime,
- evictExclude);
- }
+ /** {@inheritDoc} */
+ @Override public IgfsFileInfo lock(IgniteUuid lockId) {
+ assert lockId != null;
+ assert this.lockId == null;
- /**
- * Constructs file information.
- *
- * @param info File information to copy data from.
- * @param len Size of a file.
- */
- IgfsFileInfo(IgfsFileInfo info, long len) {
- this(info.isDirectory(), info.id, info.blockSize, len, info.affKey, info.listing, info.props, info.fileMap(),
- info.lockId, true, info.accessTime, info.modificationTime, info.evictExclude());
- }
+ IgfsFileInfo res = copy();
- /**
- * Constructs file info.
- *
- * @param info File info.
- * @param accessTime Last access time.
- * @param modificationTime Last modification time.
- */
- IgfsFileInfo(IgfsFileInfo info, long accessTime, long modificationTime) {
- this(info.isDirectory(), info.id, info.blockSize, info.len, info.affKey, info.listing, info.props,
- info.fileMap(), info.lockId, false, accessTime, modificationTime, info.evictExclude());
- }
+ res.lockId = lockId;
- /**
- * Constructs file information.
- *
- * @param info File information to copy data from.
- * @param props File properties to set.
- */
- IgfsFileInfo(IgfsFileInfo info, @Nullable Map<String, String> props) {
- this(info.isDirectory(), info.id, info.blockSize, info.len, info.affKey, info.listing, props,
- info.fileMap(), info.lockId, true, info.accessTime, info.modificationTime, info.evictExclude());
+ return res;
}
- /**
- * Constructs file info.
- *
- * @param blockSize Block size,
- * @param len Size of a file.
- * @param props File properties to set.
- * @param evictExclude Evict exclude flag.
- * @param accessTime The access time.
- * @param modificationTime The modification time.
- */
- IgfsFileInfo(int blockSize, long len, boolean evictExclude, @Nullable Map<String, String> props,
- long accessTime, long modificationTime) {
- this(blockSize == 0, // NB The contract is: (blockSize == 0) <=> isDirectory()
- null, blockSize, len, null, null, props, null, true, accessTime, modificationTime, evictExclude);
- }
+ /** {@inheritDoc} */
+ @Override public IgfsFileInfo unlock(long modificationTime) {
+ IgfsFileInfo res = copy();
- /**
- * Constructs file information.
- *
- * @param info File information to copy data from.
- * @param lockId Lock ID.
- * @param modificationTime Last modification time.
- */
- IgfsFileInfo(IgfsFileInfo info, @Nullable IgniteUuid lockId, long modificationTime) {
- this(info.isDirectory(), info.id, info.blockSize, info.len, info.affKey, info.listing, info.props,
- info.fileMap(), lockId, true, info.accessTime, modificationTime, info.evictExclude());
+ res.lockId = null;
+ res.modificationTime = modificationTime;
+
+ return res;
}
- /**
- * Constructs file info.
- *
- * @param listing New directory listing.
- * @param old Old file info.
- */
- IgfsFileInfo(@Nullable Map<String, IgfsListingEntry> listing, IgfsFileInfo old) {
- this(old.isDirectory(), old.id, old.blockSize, old.len, old.affKey, listing, old.props, old.fileMap(),
- old.lockId, false, old.accessTime, old.modificationTime, old.evictExclude());
+ /** {@inheritDoc} */
+ @Override public IgfsFileInfo fileMap(IgfsFileMap fileMap) {
+ IgfsFileInfo res = copy();
+
+ res.fileMap = fileMap;
+
+ return res;
}
- /**
- * Constructs file info.
- *
- * @param isDir Constructs directory info if {@code true} or file info if {@code false}.
- * @param id ID or {@code null} to generate it automatically.
- * @param blockSize Block size.
- * @param len Size of a file.
- * @param affKey Affinity key for data blocks.
- * @param listing Directory listing.
- * @param props File properties.
- * @param lockId Lock ID.
- * @param cpProps Flag to copy properties map.
- * @param accessTime The access time.
- * @param modificationTime Last modification time.
- * @param evictExclude Evict exclude flag.
- */
- private IgfsFileInfo(boolean isDir, @Nullable IgniteUuid id, int blockSize, long len, @Nullable IgniteUuid affKey,
- @Nullable Map<String, IgfsListingEntry> listing, @Nullable Map<String, String> props,
- @Nullable IgniteUuid lockId, boolean cpProps, long accessTime, long modificationTime, boolean evictExclude) {
- this(isDir, id, blockSize, len, affKey, listing, props, null, lockId, cpProps, accessTime,
- modificationTime, evictExclude);
+ /** {@inheritDoc} */
+ @Override protected IgfsFileInfo copy() {
+ return new IgfsFileInfo(id, blockSize, len, affKey, props, fileMap, lockId, accessTime, modificationTime,
+ evictExclude);
}
/**
* Constructs file info.
*
- * @param isDir Constructs directory info if {@code true} or file info if {@code false}.
* @param id ID or {@code null} to generate it automatically.
* @param blockSize Block size.
* @param len Size of a file.
* @param affKey Affinity key for data blocks.
- * @param listing Directory listing.
* @param props File properties.
* @param fileMap File map.
* @param lockId Lock ID.
- * @param cpProps Flag to copy properties map.
* @param accessTime Last access time.
* @param modificationTime Last modification time.
* @param evictExclude Evict exclude flag.
*/
- private IgfsFileInfo(boolean isDir, @Nullable IgniteUuid id, int blockSize, long len, @Nullable IgniteUuid affKey,
- @Nullable Map<String, IgfsListingEntry> listing, @Nullable Map<String, String> props,
- @Nullable IgfsFileMap fileMap, @Nullable IgniteUuid lockId, boolean cpProps, long accessTime,
- long modificationTime, boolean evictExclude) {
- assert F.isEmpty(listing) || isDir;
-
- if (isDir) {
- assert len == 0 : "Directory length should be zero: " + len;
- assert blockSize == 0 : "Directory block size should be zero: " + blockSize;
- }
- else {
- assert len >= 0 : "File length cannot be negative: " + len;
- assert blockSize > 0 : "File block size should be positive: " + blockSize;
- }
-
- this.id = id == null ? IgniteUuid.randomUuid() : id;
- this.len = isDir ? 0 : len;
- this.blockSize = isDir ? 0 : blockSize;
+ IgfsFileInfo(IgniteUuid id, int blockSize, long len, @Nullable IgniteUuid affKey,
+ @Nullable Map<String, String> props, @Nullable IgfsFileMap fileMap, @Nullable IgniteUuid lockId,
+ long accessTime, long modificationTime, boolean evictExclude) {
+ super(id, props, accessTime, modificationTime);
+
+ this.len = len;
+ this.blockSize = blockSize;
this.affKey = affKey;
- this.listing = listing;
- if (fileMap == null && !isDir)
+ if (fileMap == null)
fileMap = new IgfsFileMap();
this.fileMap = fileMap;
- this.accessTime = accessTime == ACCESS_TIME_TAKE_MODIFICATION_TIME ? modificationTime : accessTime;
- this.modificationTime = modificationTime;
-
- // Always make a copy of passed properties collection to escape concurrent modifications.
- this.props = props == null || props.isEmpty() ? null :
- cpProps ? new GridLeanMap<>(props) : props;
-
this.lockId = lockId;
this.evictExclude = evictExclude;
}
- /**
- * A copy constructor, which takes all data from the specified
- * object field-by-field.
- *
- * @param info An object to copy data info.
- */
- public IgfsFileInfo(IgfsFileInfo info) {
- this(info.isDirectory(), info.id, info.blockSize, info.len, info.affKey, info.listing, info.props,
- info.fileMap(), info.lockId, true, info.accessTime, info.modificationTime, info.evictExclude());
- }
-
- /**
- * Creates a builder for the new instance of file info.
- *
- * @return A builder to construct a new unmodifiable instance
- * of this class.
- */
- public static Builder builder() {
- return new Builder(new IgfsFileInfo());
- }
-
- /**
- * Creates a builder for the new instance of file info,
- * based on the specified origin.
- *
- * @param origin An origin for new instance, from which
- * the data will be copied.
- * @return A builder to construct a new unmodifiable instance
- * of this class.
- */
- public static Builder builder(IgfsFileInfo origin) {
- return new Builder(new IgfsFileInfo(origin));
- }
-
- /**
- * Gets this item ID.
- *
- * @return This item ID.
- */
- public IgniteUuid id() {
- return id;
- }
-
- /**
- * Temporal hack to change ID before saving entry to cache. Currently we have too much constructors and adding
- * more will make things even worse. Instead, we use this method until directories and files are split into
- * separate entities.
- *
- * @param id ID.
- * @deprecated Use only on not-yet-saved entries.
- */
- @Deprecated
- public void id(IgniteUuid id) {
- this.id = id;
- }
-
- /**
- * @return {@code True} if this is a file.
- */
+ /** {@inheritDoc} */
public boolean isFile() {
- return blockSize > 0;
- }
-
- /**
- * @return {@code True} if this is a directory.
- */
- public boolean isDirectory() {
- return blockSize == 0;
+ return true;
}
- /**
- * Get file size.
- *
- * @return File size.
- */
+ /** {@inheritDoc} */
public long length() {
- assert isFile();
-
return len;
}
- /**
- * Get single data block size to store this file.
- *
- * @return Single data block size to store this file.
- */
+ /** {@inheritDoc} */
public int blockSize() {
- assert isFile();
-
return blockSize;
}
- /**
- * @return Number of data blocks to store this file.
- */
+ /** {@inheritDoc} */
public long blocksCount() {
- assert isFile();
-
return (len + blockSize() - 1) / blockSize();
}
- /**
- * @return Last access time.
- */
- public long accessTime() {
- return accessTime;
- }
-
- /**
- * @return Last modification time.
- */
- public long modificationTime() {
- return modificationTime;
- }
-
- /**
- * @return Directory listing.
- */
+ /** {@inheritDoc} */
public Map<String, IgfsListingEntry> listing() {
- return listing != null ? listing : Collections.<String, IgfsListingEntry>emptyMap();
+ return Collections.emptyMap();
}
- /**
- * @return {@code True} if at least one child exists.
- */
+ /** {@inheritDoc} */
public boolean hasChildren() {
- return !F.isEmpty(listing);
+ return false;
}
- /**
- * @param name Child name.
- * @return {@code True} if child with such name exists.
- */
+ /** {@inheritDoc} */
public boolean hasChild(String name) {
- return listing != null && listing.containsKey(name);
+ return false;
}
- /**
- * @param name Child name.
- * @param expId Expected child ID.
- * @return {@code True} if child with such name exists.
- */
+ /** {@inheritDoc} */
public boolean hasChild(String name, IgniteUuid expId) {
- if (listing != null) {
- IgfsListingEntry entry = listing.get(name);
-
- if (entry != null)
- return F.eq(expId, entry.fileId());
- }
-
return false;
}
- /**
- * @return Affinity key used for single-node file collocation. If {@code null}, usual
- * mapper procedure is used for block affinity detection.
- */
+ /** {@inheritDoc} */
@Nullable public IgniteUuid affinityKey() {
return affKey;
}
- /**
- * @param affKey Affinity key used for single-node file collocation.
- */
- public void affinityKey(IgniteUuid affKey) {
- this.affKey = affKey;
- }
-
- /**
- * @return File affinity map.
- */
+ /** {@inheritDoc} */
public IgfsFileMap fileMap() {
return fileMap;
}
- /**
- * @param fileMap File affinity map.
- */
- public void fileMap(IgfsFileMap fileMap) {
- this.fileMap = fileMap;
- }
-
- /**
- * Get properties of the file.
- *
- * @return Properties of the file.
- */
- public Map<String, String> properties() {
- return props == null || props.isEmpty() ? Collections.<String, String>emptyMap() :
- Collections.unmodifiableMap(props);
- }
-
- /**
- * Get lock ID.
- *
- * @return Lock ID if file is locked or {@code null} if file is free of locks.
- */
+ /** {@inheritDoc} */
@Nullable public IgniteUuid lockId() {
return lockId;
}
- /**
- * Get evict exclude flag.
- *
- * @return Evict exclude flag.
- */
+ /** {@inheritDoc} */
public boolean evictExclude() {
return evictExclude;
}
- /**
- * @return Original file path. This is a helper field used only in some operations like delete.
- */
- public IgfsPath path() {
- return path;
- }
-
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeGridUuid(out, id);
+ super.writeExternal(out);
+
out.writeInt(blockSize);
out.writeLong(len);
- U.writeStringMap(out, props);
U.writeGridUuid(out, lockId);
U.writeGridUuid(out, affKey);
- out.writeObject(listing);
out.writeObject(fileMap);
- out.writeLong(accessTime);
- out.writeLong(modificationTime);
out.writeBoolean(evictExclude);
- out.writeObject(path);
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- id = U.readGridUuid(in);
+ super.readExternal(in);
+
blockSize = in.readInt();
len = in.readLong();
- props = U.readStringMap(in);
lockId = U.readGridUuid(in);
affKey = U.readGridUuid(in);
- listing = (Map<String, IgfsListingEntry>)in.readObject();
fileMap = (IgfsFileMap)in.readObject();
- accessTime = in.readLong();
- modificationTime = in.readLong();
evictExclude = in.readBoolean();
- path = (IgfsPath)in.readObject();
}
/** {@inheritDoc} */
@@ -575,42 +253,4 @@ public final class IgfsFileInfo implements Externalizable {
@Override public String toString() {
return S.toString(IgfsFileInfo.class, this);
}
-
- /**
- * Builder for {@link IgfsFileInfo}.
- */
- @SuppressWarnings("PublicInnerClass")
- public static class Builder {
- /** Instance to build. */
- private final IgfsFileInfo info;
-
- /**
- * Private constructor.
- *
- * @param info Instance to build.
- */
- private Builder(IgfsFileInfo info) {
- this.info = info;
- }
-
- /**
- * @param path A new path value.
- * @return This builder instance (for chaining).
- */
- public Builder path(IgfsPath path) {
- info.path = path;
-
- return this;
- }
-
- /**
- * Finishes instance construction and returns a resulting
- * unmodifiable instance.
- *
- * @return A constructed instance.
- */
- public IgfsFileInfo build() {
- return info;
- }
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatch.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatch.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatch.java
index 130846b..17875a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatch.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatch.java
@@ -17,22 +17,23 @@
package org.apache.ignite.internal.processors.igfs;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.BlockingDeque;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.igfs.IgfsPath;
-import org.apache.ignite.internal.util.future.GridFutureAdapter;
-import org.apache.ignite.internal.util.typedef.internal.U;
/**
* Work batch is an abstraction of the logically grouped tasks.
*/
public abstract class IgfsFileWorkerBatch implements Runnable {
/** Stop marker. */
- private static final byte[] STOP_MARKER = new byte[0];
+ private static final byte[] FINISH_MARKER = new byte[0];
/** Cancel marker. */
private static final byte[] CANCEL_MARKER = new byte[0];
@@ -49,9 +50,6 @@ public abstract class IgfsFileWorkerBatch implements Runnable {
/** Output stream to the file. */
private final OutputStream out;
- /** Cancel flag. */
- private volatile boolean cancelled;
-
/** Finishing flag. */
private volatile boolean finishing;
@@ -76,45 +74,55 @@ public abstract class IgfsFileWorkerBatch implements Runnable {
* @return {@code True} in case write was enqueued.
*/
synchronized boolean write(final byte[] data) {
- if (!finishing) {
- queue.add(data);
-
- return true;
- }
- else
- return false;
+ return offer(data, false, false);
}
/**
* Add the last task to that batch which will release all the resources.
+ *
+ * @return {@code True} if finish was signalled.
*/
- synchronized void finish() {
- if (!finishing) {
- finishing = true;
-
- queue.add(STOP_MARKER);
- }
+ synchronized boolean finish() {
+ return offer(FINISH_MARKER, false, true);
}
/**
* Cancel batch processing.
+ *
+ * @return {@code True} if cancel was signalled.
*/
- synchronized void cancel() {
- queue.addFirst(CANCEL_MARKER);
+ synchronized boolean cancel() {
+ return offer(CANCEL_MARKER, true, true);
}
/**
- * @return {@code True} if finish was called on this batch.
+ * Add request to queue.
+ *
+ * @param data Data.
+ * @param head Whether to add to head.
+ * @param finish Whether this is the last batch to be accepted.
+ * @return {@code True} if request was added to queue.
*/
- boolean finishing() {
- return finishing;
+ private synchronized boolean offer(byte[] data, boolean head, boolean finish) {
+ if (finishing)
+ return false;
+
+ if (head)
+ queue.addFirst(data);
+ else
+ queue.addLast(data);
+
+ if (finish)
+ finishing = true;
+
+ return true;
}
/**
- * @return {@code True} if batch write was terminated abruptly due to explicit cancellation.
+ * @return {@code True} if finish was called on this batch.
*/
- boolean cancelled() {
- return cancelled;
+ boolean finishing() {
+ return finishing;
}
/**
@@ -129,16 +137,13 @@ public abstract class IgfsFileWorkerBatch implements Runnable {
try {
byte[] data = queue.poll(1000, TimeUnit.MILLISECONDS);
- if (data == STOP_MARKER) {
+ if (data == FINISH_MARKER) {
assert queue.isEmpty();
break;
}
- else if (data == CANCEL_MARKER) {
- cancelled = true;
-
- throw new IgniteCheckedException("Write to file was cancelled due to node stop.");
- }
+ else if (data == CANCEL_MARKER)
+ throw new IgfsFileWorkerBatchCancelledException(path);
else if (data != null) {
try {
out.write(data);
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatchCancelledException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatchCancelledException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatchCancelledException.java
new file mode 100644
index 0000000..4ae6964
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileWorkerBatchCancelledException.java
@@ -0,0 +1,51 @@
+/*
+ * 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.IgniteCheckedException;
+import org.apache.ignite.igfs.IgfsPath;
+
+/**
+ * Exception indicating that file batch processing was cancelled.
+ */
+public class IgfsFileWorkerBatchCancelledException extends IgniteCheckedException {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Path. */
+ private IgfsPath path;
+
+ /**
+ * Default constructor.
+ */
+ public IgfsFileWorkerBatchCancelledException() {
+ // No-op.
+ }
+
+ public IgfsFileWorkerBatchCancelledException(IgfsPath path) {
+ this.path = path;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getMessage() {
+ if (path == null)
+ return "Asynchronous file processing was cancelled due to node stop.";
+ else
+ return "Asynchronous file processing was cancelled due to node stop: " + path;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
index 7cc5cb6..194a8ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
@@ -17,23 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterNode;
@@ -60,6 +43,23 @@ import org.jetbrains.annotations.Nullable;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
@@ -274,7 +274,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
Collection<IgfsFileAffinityRange> ranges = req.fragmentRanges();
IgniteUuid fileId = req.fileId();
- IgfsFileInfo fileInfo = igfsCtx.meta().info(fileId);
+ IgfsEntryInfo fileInfo = igfsCtx.meta().info(fileId);
if (fileInfo == null) {
if (log.isDebugEnabled())
@@ -288,7 +288,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
for (IgfsFileAffinityRange range : ranges) {
try {
- IgfsFileInfo updated;
+ IgfsEntryInfo updated;
switch (range.status()) {
case RANGE_STATUS_INITIAL: {
@@ -345,7 +345,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
/**
* Update range processor.
*/
- private static class RangeUpdateProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class RangeUpdateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -375,17 +375,15 @@ public class IgfsFragmentizerManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo oldInfo = entry.getValue();
+ IgfsEntryInfo oldInfo = entry.getValue();
IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
newMap.updateRangeStatus(range, status);
- IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, oldInfo.length());
-
- newInfo.fileMap(newMap);
+ IgfsEntryInfo newInfo = oldInfo.fileMap(newMap);
entry.setValue(newInfo);
@@ -413,7 +411,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
/**
* Delete range processor.
*/
- private static class RangeDeleteProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class RangeDeleteProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -438,17 +436,15 @@ public class IgfsFragmentizerManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo oldInfo = entry.getValue();
+ IgfsEntryInfo oldInfo = entry.getValue();
IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
newMap.deleteRange(range);
- IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, oldInfo.length());
-
- newInfo.fileMap(newMap);
+ IgfsEntryInfo newInfo = oldInfo.fileMap(newMap);
entry.setValue(newInfo);
@@ -507,7 +503,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
// If we have room for files, add them to fragmentizer.
try {
while (fragmentingFiles.size() < igfsCtx.configuration().getFragmentizerConcurrentFiles()) {
- IgfsFileInfo fileInfo = fileForFragmentizer(fragmentingFiles.keySet());
+ IgfsEntryInfo fileInfo = fileForFragmentizer(fragmentingFiles.keySet());
// If no colocated files found, exit loop.
if (fileInfo == null)
@@ -715,7 +711,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
*
* @param fileInfo File info to process.
*/
- private void requestFragmenting(IgfsFileInfo fileInfo) {
+ private void requestFragmenting(IgfsEntryInfo fileInfo) {
IgfsFileMap map = fileInfo.fileMap();
assert map != null && !map.ranges().isEmpty();
@@ -789,7 +785,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
* @return File ID to process or {@code null} if there are no such files.
* @throws IgniteCheckedException In case of error.
*/
- @Nullable private IgfsFileInfo fileForFragmentizer(Collection<IgniteUuid> exclude) throws IgniteCheckedException {
+ @Nullable private IgfsEntryInfo fileForFragmentizer(Collection<IgniteUuid> exclude) throws IgniteCheckedException {
return fragmentizerEnabled ? igfsCtx.meta().fileForFragmentizer(exclude) : null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/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 9ec583c..398428a 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
@@ -622,7 +622,7 @@ public final class IgfsImpl implements IgfsEx {
await(path);
- IgfsFileInfo info = meta.updateDual(secondaryFs, path, props);
+ IgfsEntryInfo info = meta.updateDual(secondaryFs, path, props);
if (info == null)
return null;
@@ -637,7 +637,7 @@ public final class IgfsImpl implements IgfsEx {
if (fileId == null)
return null;
- IgfsFileInfo info = meta.updateProperties(fileId, props);
+ IgfsEntryInfo info = meta.updateProperties(fileId, props);
if (info != null) {
if (evts.isRecordable(EVT_IGFS_META_UPDATED))
@@ -691,7 +691,7 @@ public final class IgfsImpl implements IgfsEx {
return null;
}
- IgfsFileInfo info = meta.move(src, dest);
+ IgfsEntryInfo info = meta.move(src, dest);
int evtTyp = info.isFile() ? EVT_IGFS_FILE_RENAMED : EVT_IGFS_DIR_RENAMED;
@@ -858,7 +858,7 @@ public final class IgfsImpl implements IgfsEx {
IgniteUuid fileId = meta.fileId(path);
if (fileId != null) {
- IgfsFileInfo info = meta.info(fileId);
+ IgfsEntryInfo info = meta.info(fileId);
// Handle concurrent deletion.
if (info != null) {
@@ -869,7 +869,7 @@ public final class IgfsImpl implements IgfsEx {
// Perform the listing.
for (Map.Entry<String, IgfsListingEntry> e : info.listing().entrySet()) {
- IgfsFileInfo childInfo = meta.info(e.getValue().fileId());
+ IgfsEntryInfo childInfo = meta.info(e.getValue().fileId());
if (childInfo != null) {
IgfsPath childPath = new IgfsPath(path, e.getKey());
@@ -933,7 +933,7 @@ public final class IgfsImpl implements IgfsEx {
return os;
}
- IgfsFileInfo info = meta.info(meta.fileId(path));
+ IgfsEntryInfo info = meta.info(meta.fileId(path));
if (info == null) {
checkConflictWithPrimary(path);
@@ -1034,7 +1034,7 @@ public final class IgfsImpl implements IgfsEx {
else
dirProps = fileProps = new HashMap<>(props);
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = meta.create(
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = meta.create(
path,
dirProps,
overwrite,
@@ -1112,7 +1112,7 @@ public final class IgfsImpl implements IgfsEx {
else
dirProps = fileProps = new HashMap<>(props);
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = meta.append(
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = meta.append(
path,
dirProps,
create,
@@ -1194,7 +1194,7 @@ public final class IgfsImpl implements IgfsEx {
// Check memory first.
IgniteUuid fileId = meta.fileId(path);
- IgfsFileInfo info = meta.info(fileId);
+ IgfsEntryInfo info = meta.info(fileId);
if (info == null && mode != PRIMARY) {
assert mode == DUAL_SYNC || mode == DUAL_ASYNC;
@@ -1291,7 +1291,7 @@ public final class IgfsImpl implements IgfsEx {
private void summary0(IgniteUuid fileId, IgfsPathSummary sum) throws IgniteCheckedException {
assert sum != null;
- IgfsFileInfo info = meta.info(fileId);
+ IgfsEntryInfo info = meta.info(fileId);
if (info != null) {
if (info.isDirectory()) {
@@ -1401,7 +1401,7 @@ public final class IgfsImpl implements IgfsEx {
List<IgniteUuid> ids = meta.fileIds(path);
- IgfsFileInfo fileInfo = meta.info(ids.get(ids.size() - 1));
+ IgfsEntryInfo fileInfo = meta.info(ids.get(ids.size() - 1));
if (fileInfo == null)
return null; // File does not exist.
@@ -1571,7 +1571,7 @@ public final class IgfsImpl implements IgfsEx {
assert path != null;
assert mode != null;
- IgfsFileInfo info = null;
+ IgfsEntryInfo info = null;
switch (mode) {
case PRIMARY:
@@ -1698,7 +1698,7 @@ public final class IgfsImpl implements IgfsEx {
* @param mode IGFS mode.
* @param batch Optional secondary file system batch.
*/
- IgfsEventAwareOutputStream(IgfsPath path, IgfsFileInfo fileInfo,
+ IgfsEventAwareOutputStream(IgfsPath path, IgfsEntryInfo fileInfo,
IgniteUuid parentId, int bufSize, IgfsMode mode, @Nullable IgfsFileWorkerBatch batch) {
super(igfsCtx, path, fileInfo, parentId, bufSize, mode, batch, metrics);
@@ -1737,7 +1737,7 @@ public final class IgfsImpl implements IgfsEx {
* @param secReader Optional secondary file system reader.
* @param metrics Metrics.
*/
- IgfsEventAwareInputStream(IgfsContext igfsCtx, IgfsPath path, IgfsFileInfo fileInfo,
+ IgfsEventAwareInputStream(IgfsContext igfsCtx, IgfsPath path, IgfsEntryInfo fileInfo,
int prefetchBlocks, int seqReadsBeforePrefetch, @Nullable IgfsSecondaryFileSystemPositionedReadable secReader,
IgfsLocalMetrics metrics) {
super(igfsCtx, path, fileInfo, prefetchBlocks, seqReadsBeforePrefetch, secReader, metrics);
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java
index afcece7..07ab051 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamAdapter.java
@@ -17,10 +17,11 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.IOException;
import org.apache.ignite.igfs.IgfsInputStream;
import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadable;
+import java.io.IOException;
+
/**
* Implementation adapter providing necessary methods.
*/
@@ -36,7 +37,7 @@ public abstract class IgfsInputStreamAdapter extends IgfsInputStream
*
* @return File info.
*/
- public abstract IgfsFileInfo fileInfo();
+ public abstract IgfsEntryInfo fileInfo();
/**
* Reads bytes from given position.
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
index 62f8034..5d41543 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInputStreamImpl.java
@@ -17,16 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.EOFException;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.igfs.IgfsCorruptedFileException;
@@ -42,6 +32,17 @@ import org.apache.ignite.lang.IgniteInClosure;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import java.io.EOFException;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
/**
* Input stream to read data from grid cache with separate blocks.
*/
@@ -66,7 +67,7 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
protected final IgfsPath path;
/** File descriptor. */
- private volatile IgfsFileInfo fileInfo;
+ private volatile IgfsEntryInfo fileInfo;
/** The number of already read bytes. Important! Access to the property is guarded by this object lock. */
private long pos;
@@ -121,7 +122,7 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
* @param secReader Optional secondary file system reader.
* @param metrics Local IGFS metrics.
*/
- IgfsInputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsFileInfo fileInfo, int prefetchBlocks,
+ IgfsInputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsEntryInfo fileInfo, int prefetchBlocks,
int seqReadsBeforePrefetch, @Nullable IgfsSecondaryFileSystemPositionedReadable secReader, IgfsLocalMetrics metrics) {
assert igfsCtx != null;
assert path != null;
@@ -157,7 +158,7 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo fileInfo() {
+ @Override public IgfsEntryInfo fileInfo() {
return fileInfo;
}
@@ -404,7 +405,7 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
// This failure may be caused by file being fragmented.
if (fileInfo.fileMap() != null && !fileInfo.fileMap().ranges().isEmpty()) {
- IgfsFileInfo newInfo = meta.info(fileInfo.id());
+ IgfsEntryInfo newInfo = meta.info(fileInfo.id());
// File was deleted.
if (newInfo == null)
@@ -534,7 +535,8 @@ public class IgfsInputStreamImpl extends IgfsInputStreamAdapter {
* @return Requested data block or {@code null} if nothing found.
* @throws IgniteCheckedException If failed.
*/
- @Nullable protected IgniteInternalFuture<byte[]> dataBlock(IgfsFileInfo fileInfo, long blockIdx) throws IgniteCheckedException {
+ @Nullable protected IgniteInternalFuture<byte[]> dataBlock(IgfsEntryInfo fileInfo, long blockIdx)
+ throws IgniteCheckedException {
return data.dataBlock(fileInfo, path, blockIdx, secReader);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java
index 0ed7c0d..eadbdb2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java
@@ -17,11 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.Closeable;
-import java.io.DataInput;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
@@ -46,6 +41,12 @@ import org.apache.ignite.lang.IgniteOutClosure;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
+import java.io.Closeable;
+import java.io.DataInput;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.concurrent.atomic.AtomicLong;
+
/**
* IGFS IPC handler.
*/
@@ -342,10 +343,7 @@ class IgfsIpcHandler implements IgfsServerHandler {
log.debug("Opened IGFS input stream for file read [igfsName=" + igfs.name() + ", path=" +
req.path() + ", streamId=" + streamId + ", ses=" + ses + ']');
- IgfsFileInfo info = new IgfsFileInfo(igfsIn.fileInfo(), null,
- igfsIn.fileInfo().modificationTime());
-
- res.response(new IgfsInputStreamDescriptor(streamId, info.length()));
+ res.response(new IgfsInputStreamDescriptor(streamId, igfsIn.fileInfo().length()));
break;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
index 4fe0dca..ea05ca3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
@@ -17,16 +17,16 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
/**
* Directory listing entry.
*/
@@ -52,7 +52,7 @@ public class IgfsListingEntry implements Externalizable {
*
* @param fileInfo File info to construct listing entry from.
*/
- public IgfsListingEntry(IgfsFileInfo fileInfo) {
+ public IgfsListingEntry(IgfsEntryInfo fileInfo) {
id = fileInfo.id();
dir = fileInfo.isDirectory();
}
[13/50] [abbrv] ignite git commit: IGNITE-2817: IGFS: Optimized
"updateProperties" and several other cache operations. Reafactored
IgfsMetaManager a bit to simplify work with cache.
Posted by sb...@apache.org.
IGNITE-2817: IGFS: Optimized "updateProperties" and several other cache operations. Reafactored IgfsMetaManager a bit to simplify work with cache.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4f7e3c1c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4f7e3c1c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4f7e3c1c
Branch: refs/heads/ignite-1837
Commit: 4f7e3c1c2e82596a26cec3b3587991ae18078b64
Parents: ba30ddb
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Mar 16 09:14:49 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:17 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsImpl.java | 4 +-
.../processors/igfs/IgfsMetaManager.java | 641 ++++++++++---------
.../igfs/IgfsMetaManagerSelfTest.java | 23 +-
3 files changed, 336 insertions(+), 332 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f7e3c1c/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 f44eda8..3065427 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
@@ -636,9 +636,7 @@ public final class IgfsImpl implements IgfsEx {
if (fileId == null)
return null;
- IgniteUuid parentId = fileIds.size() > 1 ? fileIds.get(fileIds.size() - 2) : null;
-
- IgfsFileInfo info = meta.updateProperties(parentId, fileId, path.name(), props);
+ IgfsFileInfo info = meta.updateProperties(fileId, props);
if (info != null) {
if (evts.isRecordable(EVT_IGFS_META_UPDATED))
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f7e3c1c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index 463e7a8..df69d49 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -40,7 +40,6 @@ import java.util.TreeSet;
import java.util.concurrent.CountDownLatch;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
-import javax.cache.processor.EntryProcessorResult;
import javax.cache.processor.MutableEntry;
import org.apache.ignite.IgniteCheckedException;
@@ -238,7 +237,7 @@ public class IgfsMetaManager extends IgfsManager {
@Nullable public IgniteUuid fileId(IgfsPath path) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
- assert validTxState(false);
+ validTxState(false);
return fileId(path, false);
}
@@ -322,7 +321,7 @@ public class IgfsMetaManager extends IgfsManager {
public List<IgniteUuid> fileIds(IgfsPath path) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
- assert validTxState(false);
+ validTxState(false);
return fileIds(path, false);
}
@@ -407,7 +406,7 @@ public class IgfsMetaManager extends IgfsManager {
if (fileId == null)
return null;
- IgfsFileInfo info = id2InfoPrj.get(fileId);
+ IgfsFileInfo info = getInfo(fileId);
// Force root ID always exist in cache.
if (info == null && IgfsUtils.ROOT_ID.equals(fileId))
@@ -433,13 +432,14 @@ public class IgfsMetaManager extends IgfsManager {
public Map<IgniteUuid, IgfsFileInfo> infos(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
- assert validTxState(false);
+ validTxState(false);
+
assert fileIds != null;
if (F.isEmpty(fileIds))
return Collections.emptyMap();
- Map<IgniteUuid, IgfsFileInfo> map = id2InfoPrj.getAll(fileIds);
+ Map<IgniteUuid, IgfsFileInfo> map = getInfos(fileIds);
// Force root ID always exist in cache.
if (fileIds.contains(IgfsUtils.ROOT_ID) && !map.containsKey(IgfsUtils.ROOT_ID)) {
@@ -469,7 +469,8 @@ public class IgfsMetaManager extends IgfsManager {
public @Nullable IgfsFileInfo lock(IgniteUuid fileId, boolean delete) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
- assert validTxState(false);
+ validTxState(false);
+
assert fileId != null;
IgniteInternalTx tx = startTx();
@@ -484,11 +485,7 @@ public class IgfsMetaManager extends IgfsManager {
if (oldInfo.lockId() != null)
return null; // The file is already locked, we cannot lock it.
- IgniteUuid lockId = createFileLockId(delete);
-
- id2InfoPrj.invoke(fileId, new FileLockProcessor(lockId));
-
- IgfsFileInfo newInfo = id2InfoPrj.get(fileId);
+ IgfsFileInfo newInfo = invokeLock(fileId, delete);
tx.commit();
@@ -530,7 +527,8 @@ public class IgfsMetaManager extends IgfsManager {
* @throws IgniteCheckedException If failed.
*/
public void unlock(final IgfsFileInfo info, final long modificationTime) throws IgniteCheckedException {
- assert validTxState(false);
+ validTxState(false);
+
assert info != null;
if (busyLock.enterBusy()) {
@@ -546,7 +544,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
IgfsUtils.doInTransactionWithRetries(id2InfoPrj, new IgniteOutClosureX<Void>() {
@Override public Void applyx() throws IgniteCheckedException {
- assert validTxState(true);
+ validTxState(true);
IgniteUuid fileId = info.id();
@@ -569,7 +567,7 @@ public class IgfsMetaManager extends IgfsManager {
});
}
finally {
- assert validTxState(false);
+ validTxState(false);
if (interrupted)
Thread.currentThread().interrupt();
@@ -591,7 +589,8 @@ public class IgfsMetaManager extends IgfsManager {
* @throws IgniteCheckedException If failed.
*/
private Map<IgniteUuid, IgfsFileInfo> lockIds(IgniteUuid... fileIds) throws IgniteCheckedException {
- assert validTxState(true);
+ validTxState(true);
+
assert fileIds != null && fileIds.length > 0;
Arrays.sort(fileIds);
@@ -631,13 +630,13 @@ public class IgfsMetaManager extends IgfsManager {
*/
private Map<IgniteUuid, IgfsFileInfo> lockIds(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
assert isSorted(fileIds);
- assert validTxState(true);
+ validTxState(true);
if (log.isDebugEnabled())
log.debug("Locking file ids: " + fileIds);
// Lock files and get their infos.
- Map<IgniteUuid, IgfsFileInfo> map = id2InfoPrj.getAll(fileIds);
+ Map<IgniteUuid, IgfsFileInfo> map = getInfos(fileIds);
if (log.isDebugEnabled())
log.debug("Locked file ids: " + fileIds);
@@ -769,7 +768,7 @@ public class IgfsMetaManager extends IgfsManager {
assert fileId != null;
IgfsFileInfo info = skipTx ? id2InfoPrj.getAllOutTx(Collections.singleton(fileId)).get(fileId) :
- id2InfoPrj.get(fileId);
+ getInfo(fileId);
return info == null ? Collections.<String, IgfsListingEntry>emptyMap() : info.listing();
}
@@ -789,7 +788,7 @@ public class IgfsMetaManager extends IgfsManager {
log.debug("Locking parent id [parentId=" + parentId + ", fileName=" + fileName + ", newFileInfo=" +
newFileInfo + ']');
- assert validTxState(true);
+ validTxState(true);
// Lock only parent file ID.
IgfsFileInfo parentInfo = info(parentId);
@@ -806,10 +805,7 @@ public class IgfsMetaManager extends IgfsManager {
if (childEntry != null)
return childEntry.fileId();
- if (!id2InfoPrj.putIfAbsent(newFileInfo.id(), newFileInfo))
- throw fsException("Failed to add file details into cache: " + newFileInfo);
-
- id2InfoPrj.invoke(parentId, new ListingAdd(fileName, new IgfsListingEntry(newFileInfo)));
+ createNewEntry(newFileInfo, parentId, fileName);
return null;
}
@@ -825,7 +821,7 @@ public class IgfsMetaManager extends IgfsManager {
public IgfsFileInfo move(IgfsPath srcPath, IgfsPath dstPath) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
- assert validTxState(false);
+ validTxState(false);
// 1. First get source and destination path IDs.
List<IgniteUuid> srcPathIds = fileIds(srcPath);
@@ -918,8 +914,7 @@ public class IgfsMetaManager extends IgfsManager {
// 8. Actual move: remove from source parent and add to destination target.
IgfsListingEntry entry = srcTargetInfo.listing().get(srcName);
- id2InfoPrj.invoke(srcTargetId, new ListingRemove(srcName, entry.fileId()));
- id2InfoPrj.invoke(dstTargetId, new ListingAdd(dstName, entry));
+ transferEntry(entry, srcTargetId, srcName, dstTargetId, dstName);
tx.commit();
@@ -990,7 +985,7 @@ public class IgfsMetaManager extends IgfsManager {
*/
private void moveNonTx(IgniteUuid fileId, @Nullable String srcFileName, IgniteUuid srcParentId, String destFileName,
IgniteUuid destParentId) throws IgniteCheckedException {
- assert validTxState(true);
+ validTxState(true);
assert fileId != null;
assert srcFileName != null;
@@ -1047,11 +1042,7 @@ public class IgfsMetaManager extends IgfsManager {
" directory (file already exists) [fileId=" + fileId + ", destFileName=" + destFileName +
", destParentId=" + destParentId + ']'));
- // Remove listing entry from the source parent listing.
- id2InfoPrj.invoke(srcParentId, new ListingRemove(srcFileName, srcEntry.fileId()));
-
- // Add listing entry into the destination parent listing.
- id2InfoPrj.invoke(destParentId, new ListingAdd(destFileName, srcEntry));
+ transferEntry(srcEntry, srcParentId, srcFileName, destParentId, destFileName);
}
/**
@@ -1064,7 +1055,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteUuid format() throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
- assert validTxState(false);
+ validTxState(false);
IgniteUuid trashId = IgfsUtils.randomTrashId();
@@ -1088,11 +1079,7 @@ public class IgfsMetaManager extends IgfsManager {
IgfsFileInfo newInfo = new IgfsFileInfo(transferListing);
- id2InfoPrj.put(newInfo.id(), newInfo);
-
- // Add new info to trash listing.
- id2InfoPrj.invoke(trashId, new ListingAdd(newInfo.id().toString(),
- new IgfsListingEntry(newInfo)));
+ createNewEntry(newInfo, trashId, newInfo.id().toString());
// Remove listing entries from root.
// Note that root directory properties and other attributes are preserved:
@@ -1128,7 +1115,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteUuid softDelete(final IgfsPath path, final boolean recursive) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
- assert validTxState(false);
+ validTxState(false);
final SortedSet<IgniteUuid> allIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
@@ -1191,15 +1178,12 @@ public class IgfsMetaManager extends IgfsManager {
assert victimId.equals(srcEntry.fileId());
- id2InfoPrj.invoke(srcParentId, new ListingRemove(srcFileName, srcEntry.fileId()));
-
- // Add listing entry into the destination parent listing.
- id2InfoPrj.invoke(trashId, new ListingAdd(destFileName, srcEntry));
+ transferEntry(srcEntry, srcParentId, srcFileName, trashId, destFileName);
if (victimInfo.isFile())
// Update a file info of the removed file with a file path,
// which will be used by delete worker for event notifications.
- id2InfoPrj.invoke(victimId, new UpdatePath(path));
+ invokeUpdatePath(victimId, path);
tx.commit();
@@ -1233,7 +1217,7 @@ public class IgfsMetaManager extends IgfsManager {
@Nullable private IgniteUuid softDeleteNonTx(@Nullable IgniteUuid parentId, @Nullable String name, IgniteUuid id,
IgniteUuid trashId)
throws IgniteCheckedException {
- assert validTxState(true);
+ validTxState(true);
IgniteUuid resId;
@@ -1241,7 +1225,7 @@ public class IgfsMetaManager extends IgfsManager {
// Handle special case when we deleting root directory.
assert IgfsUtils.ROOT_ID.equals(id);
- IgfsFileInfo rootInfo = id2InfoPrj.get(IgfsUtils.ROOT_ID);
+ IgfsFileInfo rootInfo = getInfo(IgfsUtils.ROOT_ID);
if (rootInfo == null)
return null; // Root was never created.
@@ -1269,11 +1253,7 @@ public class IgfsMetaManager extends IgfsManager {
IgfsFileInfo newInfo = new IgfsFileInfo(transferListing);
- id2InfoPrj.getAndPut(newInfo.id(), newInfo);
-
- // Add new info to trash listing.
- id2InfoPrj.invoke(trashId, new ListingAdd(newInfo.id().toString(),
- new IgfsListingEntry(newInfo)));
+ createNewEntry(newInfo, trashId, newInfo.id().toString());
// Remove listing entries from root.
for (Map.Entry<String, IgfsListingEntry> entry : transferListing.entrySet())
@@ -1311,7 +1291,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
assert parentId != null;
assert listing != null;
- assert validTxState(false);
+ validTxState(false);
IgniteInternalTx tx = startTx();
@@ -1353,7 +1333,7 @@ public class IgfsMetaManager extends IgfsManager {
// Delete only files or empty folders.
if (!entryInfo.hasChildren()) {
- id2InfoPrj.getAndRemove(childId);
+ id2InfoPrj.remove(childId);
newListing.remove(childName);
@@ -1402,7 +1382,7 @@ public class IgfsMetaManager extends IgfsManager {
boolean delete(IgniteUuid parentId, String name, IgniteUuid id) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
- assert validTxState(false);
+ validTxState(false);
IgniteInternalTx tx = startTx();
@@ -1428,11 +1408,9 @@ public class IgfsMetaManager extends IgfsManager {
IgfsListingEntry childEntry = parentInfo.listing().get(name);
if (childEntry != null)
- id2InfoPrj.invoke(parentId, new ListingRemove(name, childEntry.fileId()));
+ id2InfoPrj.invoke(parentId, new ListingRemove(name, id));
- IgfsFileInfo deleted = id2InfoPrj.getAndRemove(id);
-
- assert victim.id().equals(deleted.id());
+ id2InfoPrj.remove(id);
res = true;
}
@@ -1468,7 +1446,7 @@ public class IgfsMetaManager extends IgfsManager {
for (int i = 0; i < IgfsUtils.TRASH_CONCURRENCY; i++) {
IgniteUuid trashId = IgfsUtils.trashId(i);
- IgfsFileInfo trashInfo = id2InfoPrj.get(trashId);
+ IgfsFileInfo trashInfo = getInfo(trashId);
if (trashInfo != null && trashInfo.hasChildren()) {
for (IgfsListingEntry entry : trashInfo.listing().values())
@@ -1489,75 +1467,28 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Update file info (file properties) in cache in existing transaction.
*
- * @param parentId Parent ID ({@code null} if file is root).
- * @param fileName To update listing.
* @param fileId File ID to update information for.
* @param props Properties to set for the file.
* @return Updated file info or {@code null} if such file ID not found.
* @throws IgniteCheckedException If operation failed.
*/
- @Nullable private IgfsFileInfo updatePropertiesNonTx(final @Nullable IgniteUuid parentId, final IgniteUuid fileId,
- String fileName, Map<String, String> props) throws IgniteCheckedException {
+ @Nullable private IgfsFileInfo updatePropertiesNonTx(final IgniteUuid fileId, Map<String, String> props)
+ throws IgniteCheckedException {
assert fileId != null;
assert !F.isEmpty(props) : "Expects not-empty file's properties";
- assert validTxState(true);
+
+ validTxState(true);
if (log.isDebugEnabled())
log.debug("Update file properties [fileId=" + fileId + ", props=" + props + ']');
try {
- final IgfsFileInfo oldInfo;
- final IgfsFileInfo parentInfo;
-
- // Lock file ID for this transaction.
- if (parentId == null) {
- oldInfo = info(fileId);
- parentInfo = null;
- }
- else {
- Map<IgniteUuid, IgfsFileInfo> locked = lockIds(parentId, fileId);
-
- oldInfo = locked.get(fileId);
- parentInfo = locked.get(parentId);
-
- if (parentInfo == null)
- return null; // Parent not found.
- }
+ final IgfsFileInfo oldInfo = info(fileId);
if (oldInfo == null)
- return null; // File not found.
+ return null;
- if (parentInfo != null) {
- if (!parentInfo.hasChild(fileName, fileId)) // File was removed or recreated.
- return null;
- }
-
- Map<String, String> tmp = oldInfo.properties();
-
- tmp = tmp == null ? new GridLeanMap<String, String>(props.size()) : new GridLeanMap<>(tmp);
-
- for (Map.Entry<String, String> e : props.entrySet()) {
- if (e.getValue() == null)
- // Remove properties with 'null' values.
- tmp.remove(e.getKey());
- else
- // Add/overwrite property.
- tmp.put(e.getKey(), e.getValue());
- }
-
- IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, tmp);
-
- id2InfoPrj.put(fileId, newInfo);
-
- if (parentId != null) {
- IgfsListingEntry entry = new IgfsListingEntry(newInfo);
-
- assert id2InfoPrj.get(parentId) != null;
-
- id2InfoPrj.invoke(parentId, new ListingAdd(fileName, entry));
- }
-
- return newInfo;
+ return invokeAndGet(fileId, new UpdatePropertiesProcessor(props));
}
catch (GridClosureException e) {
throw U.cast(e);
@@ -1567,23 +1498,21 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Update file info (file properties) in cache.
*
- * @param parentId Parent ID ({@code null} if file is root).
- * @param fileName To update listing.
* @param fileId File ID to update information for.
* @param props Properties to set for the file.
* @return Updated file info or {@code null} if such file ID not found.
* @throws IgniteCheckedException If operation failed.
*/
- @Nullable public IgfsFileInfo updateProperties(@Nullable IgniteUuid parentId, IgniteUuid fileId, String fileName,
- Map<String, String> props) throws IgniteCheckedException {
+ @Nullable public IgfsFileInfo updateProperties(IgniteUuid fileId, Map<String, String> props)
+ throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
- assert validTxState(false);
+ validTxState(false);
IgniteInternalTx tx = startTx();
try {
- IgfsFileInfo info = updatePropertiesNonTx(parentId, fileId, fileName, props);
+ IgfsFileInfo info = updatePropertiesNonTx(fileId, props);
tx.commit();
@@ -1598,8 +1527,8 @@ public class IgfsMetaManager extends IgfsManager {
}
}
else
- throw new IllegalStateException("Failed to update properties because Grid is stopping [parentId=" +
- parentId + ", fileId=" + fileId + ", fileName=" + fileName + ", props=" + props + ']');
+ throw new IllegalStateException("Failed to update properties because Grid is stopping [fileId=" + fileId +
+ ", props=" + props + ']');
}
/**
@@ -1613,7 +1542,7 @@ public class IgfsMetaManager extends IgfsManager {
*/
public IgfsFileInfo reserveSpace(IgfsPath path, IgniteUuid fileId, long space, IgfsFileAffinityRange affRange)
throws IgniteCheckedException {
- assert validTxState(false);
+ validTxState(false);
if (busyLock.enterBusy()) {
try {
@@ -1629,9 +1558,7 @@ public class IgfsMetaManager extends IgfsManager {
if (oldInfo == null)
throw fsException("File has been deleted concurrently [path=" + path + ", id=" + fileId + ']');
- id2InfoPrj.invoke(fileId, new FileReserveSpaceProcessor(space, affRange));
-
- IgfsFileInfo newInfo = id2InfoPrj.get(fileId);
+ IgfsFileInfo newInfo = invokeAndGet(fileId, new FileReserveSpaceProcessor(space, affRange));
tx.commit();
@@ -1663,7 +1590,7 @@ public class IgfsMetaManager extends IgfsManager {
*/
@Nullable public IgfsFileInfo updateInfo(IgniteUuid fileId, IgniteClosure<IgfsFileInfo, IgfsFileInfo> c)
throws IgniteCheckedException {
- assert validTxState(false);
+ validTxState(false);
assert fileId != null;
assert c != null;
@@ -1672,7 +1599,7 @@ public class IgfsMetaManager extends IgfsManager {
if (log.isDebugEnabled())
log.debug("Update file info [fileId=" + fileId + ", c=" + c + ']');
- IgniteInternalTx tx = id2InfoPrj.isLockedByThread(fileId) ? null : startTx();
+ IgniteInternalTx tx = startTx();
try {
// Lock file ID for this transaction.
@@ -1732,14 +1659,14 @@ public class IgfsMetaManager extends IgfsManager {
*/
boolean mkdirs(final IgfsPath path, final Map<String, String> props) throws IgniteCheckedException {
assert props != null;
- assert validTxState(false);
+ validTxState(false);
DirectoryChainBuilder b = null;
while (true) {
if (busyLock.enterBusy()) {
try {
- b = new DirectoryChainBuilder(path, props, props);
+ b = new DirectoryChainBuilder(path, props);
// Start TX.
IgniteInternalTx tx = startTx();
@@ -1873,6 +1800,106 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
+ * Put new entry to meta cache immediately linking it to parent.
+ *
+ * @param info Info to put.
+ * @param parentId Parent ID.
+ * @param name Name in parent.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void createNewEntry(IgfsFileInfo info, IgniteUuid parentId, String name) throws IgniteCheckedException {
+ validTxState(true);
+
+ if (!id2InfoPrj.putIfAbsent(info.id(), info))
+ throw fsException("Failed to create new metadata entry due to ID conflict: " + info.id());
+
+ if (parentId != null)
+ id2InfoPrj.invoke(parentId, new ListingAdd(name, new IgfsListingEntry(info)));
+ }
+
+ /**
+ * Transfer entry from one directory to another.
+ *
+ * @param entry Entry to be transfered.
+ * @param srcId Source ID.
+ * @param srcName Source name.
+ * @param destId Destination ID.
+ * @param destName Destination name.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void transferEntry(IgfsListingEntry entry, IgniteUuid srcId, String srcName,
+ IgniteUuid destId, String destName) throws IgniteCheckedException {
+ validTxState(true);
+
+ id2InfoPrj.invoke(srcId, new ListingRemove(srcName, entry.fileId()));
+ id2InfoPrj.invoke(destId, new ListingAdd(destName, entry));
+ }
+
+ /**
+ * Invoke lock processor.
+ *
+ * @param id File ID.
+ * @param delete Whether lock is taken for delete.
+ * @return Resulting file info.
+ * @throws IgniteCheckedException If failed.
+ */
+ private IgfsFileInfo invokeLock(IgniteUuid id, boolean delete) throws IgniteCheckedException {
+ return invokeAndGet(id, new FileLockProcessor(createFileLockId(delete)));
+ }
+
+ /**
+ * Invoke path update processor.
+ *
+ * @param id File ID.
+ * @param path Path to be updated.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void invokeUpdatePath(IgniteUuid id, IgfsPath path) throws IgniteCheckedException {
+ validTxState(true);
+
+ id2InfoPrj.invoke(id, new UpdatePath(path));
+ }
+
+ /**
+ * Invoke some processor and return new value.
+ *
+ * @param id ID.
+ * @param proc Processor.
+ * @return New file info.
+ * @throws IgniteCheckedException If failed.
+ */
+ private IgfsFileInfo invokeAndGet(IgniteUuid id, EntryProcessor<IgniteUuid, IgfsFileInfo, Void> proc)
+ throws IgniteCheckedException {
+ validTxState(true);
+
+ id2InfoPrj.invoke(id, proc);
+
+ return getInfo(id);
+ }
+
+ /**
+ * Get info.
+ *
+ * @param id ID.
+ * @return Info.
+ * @throws IgniteCheckedException If failed.
+ */
+ @Nullable private IgfsFileInfo getInfo(IgniteUuid id) throws IgniteCheckedException {
+ return id2InfoPrj.get(id);
+ }
+
+ /**
+ * Get several infos.
+ *
+ * @param ids IDs.
+ * @return Infos map.
+ * @throws IgniteCheckedException If failed.
+ */
+ private Map<IgniteUuid, IgfsFileInfo> getInfos(Collection<IgniteUuid> ids) throws IgniteCheckedException {
+ return id2InfoPrj.getAll(ids);
+ }
+
+ /**
* Create the file in DUAL mode.
*
* @param fs File system.
@@ -1913,7 +1940,7 @@ public class IgfsMetaManager extends IgfsManager {
@Override public IgfsSecondaryOutputStreamDescriptor onSuccess(Map<IgfsPath,
IgfsFileInfo> infos) throws Exception {
- assert validTxState(true);
+ validTxState(true);
assert !infos.isEmpty();
@@ -1983,12 +2010,10 @@ public class IgfsMetaManager extends IgfsManager {
path + ", fileId=" + oldId + ", lockId=" + oldInfo.lockId() + ']');
id2InfoPrj.remove(oldId); // Remove the old one.
- id2InfoPrj.put(newInfo.id(), newInfo); // Put the new one.
-
id2InfoPrj.invoke(parentInfo.id(),
new ListingRemove(path.name(), parentInfo.listing().get(path.name()).fileId()));
- id2InfoPrj.invoke(parentInfo.id(),
- new ListingAdd(path.name(), new IgfsListingEntry(newInfo)));
+
+ createNewEntry(newInfo, parentInfo.id(), path.name()); // Put new one.
IgniteInternalFuture<?> delFut = igfsCtx.data().delete(oldInfo);
}
@@ -2052,7 +2077,7 @@ public class IgfsMetaManager extends IgfsManager {
@Override public IgfsSecondaryOutputStreamDescriptor onSuccess(Map<IgfsPath,
IgfsFileInfo> infos) throws Exception {
- assert validTxState(true);
+ validTxState(true);
final IgfsFileInfo info = infos.get(path);
@@ -2087,11 +2112,7 @@ public class IgfsMetaManager extends IgfsManager {
}
// Set lock and return.
- IgniteUuid lockId = createFileLockId(false);
-
- id2InfoPrj.invoke(info.id(), new FileLockProcessor(lockId));
-
- IgfsFileInfo lockedInfo = id2InfoPrj.get(info.id());
+ IgfsFileInfo lockedInfo = invokeLock(info.id(), false);
return new IgfsSecondaryOutputStreamDescriptor(infos.get(path.parent()).id(),
lockedInfo, out);
@@ -2453,7 +2474,7 @@ public class IgfsMetaManager extends IgfsManager {
}
// Update the deleted file info with path information for delete worker.
- id2InfoPrj.invoke(info.id(), new UpdatePath(path));
+ invokeUpdatePath(info.id(), path);
return true; // No additional handling is required.
}
@@ -2505,12 +2526,7 @@ public class IgfsMetaManager extends IgfsManager {
fs.update(path, props);
- IgfsFileInfo parentInfo = infos.get(path.parent());
-
- assert path.parent() == null || parentInfo != null;
-
- return updatePropertiesNonTx(parentInfo == null ? null : parentInfo.id(),
- infos.get(path).id(), path.name(), props);
+ return updatePropertiesNonTx(infos.get(path).id(), props);
}
@Override public IgfsFileInfo onFailure(@Nullable Exception err) throws IgniteCheckedException {
@@ -2865,7 +2881,7 @@ public class IgfsMetaManager extends IgfsManager {
*/
private <K, V> boolean putx(IgniteInternalCache<K, V> cache, K key, IgniteClosure<V, V> c)
throws IgniteCheckedException {
- assert validTxState(true);
+ validTxState(true);
V oldVal = cache.get(key);
V newVal = c.apply(oldVal);
@@ -2877,16 +2893,10 @@ public class IgfsMetaManager extends IgfsManager {
* Check transaction is (not) started.
*
* @param inTx Expected transaction state.
- * @return Transaction state is correct.
*/
- private boolean validTxState(boolean inTx) {
- boolean txState = inTx == (id2InfoPrj.tx() != null);
-
- assert txState : (inTx ? "Method cannot be called outside transaction " :
- "Method cannot be called in transaction ") + "[tx=" + id2InfoPrj.tx() + ", threadId=" +
- Thread.currentThread().getId() + ']';
-
- return txState;
+ private void validTxState(boolean inTx) {
+ assert (inTx && id2InfoPrj.tx() != null) || (!inTx && id2InfoPrj.tx() == null) :
+ "Invalid TX state [expected=" + inTx + ", actual=" + (id2InfoPrj.tx() != null) + ']';
}
/**
@@ -2912,7 +2922,7 @@ public class IgfsMetaManager extends IgfsManager {
long modificationTime) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
- assert validTxState(false);
+ validTxState(false);
// Start pessimistic transaction.
IgniteInternalTx tx = startTx();
@@ -3310,7 +3320,8 @@ public class IgfsMetaManager extends IgfsManager {
final @Nullable IgniteUuid affKey,
final boolean evictExclude,
@Nullable Map<String, String> fileProps) throws IgniteCheckedException {
- assert validTxState(false);
+ validTxState(false);
+
assert path != null;
final String name = path.name();
@@ -3322,15 +3333,7 @@ public class IgfsMetaManager extends IgfsManager {
while (true) {
if (busyLock.enterBusy()) {
try {
- b = new DirectoryChainBuilder(path, dirProps, fileProps) {
- /** {@inheritDoc} */
- @Override protected IgfsFileInfo buildLeaf() {
- long t = System.currentTimeMillis();
-
- return new IgfsFileInfo(blockSize, 0L, affKey, createFileLockId(false),
- evictExclude, leafProps, t, t);
- }
- };
+ b = new DirectoryChainBuilder(path, dirProps, fileProps, blockSize, affKey, evictExclude);
// Start Tx:
IgniteInternalTx tx = startTx();
@@ -3377,18 +3380,7 @@ public class IgfsMetaManager extends IgfsManager {
+ "[fileName=" + name + ", fileId=" + lowermostExistingInfo.id()
+ ", lockId=" + lockId + ']');
- IgniteUuid newLockId = createFileLockId(false);
-
- EntryProcessorResult<IgfsFileInfo> result
- = id2InfoPrj.invoke(lowermostExistingInfo.id(),
- new LockFileProcessor(newLockId));
-
- IgfsFileInfo lockedInfo = result.get();
-
- assert lockedInfo != null; // we already checked lock above.
- assert lockedInfo.lockId() != null;
- assert lockedInfo.lockId().equals(newLockId);
- assert lockedInfo.id().equals(lowermostExistingInfo.id());
+ IgfsFileInfo lockedInfo = invokeLock(lowermostExistingInfo.id(), false);
IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(lockedInfo, parentId);
@@ -3411,15 +3403,12 @@ public class IgfsMetaManager extends IgfsManager {
assert deletedEntry != null;
- id2InfoPrj.invoke(parentId, new ListingRemove(name, deletedEntry.fileId()));
-
- // Add listing entry into the destination parent listing.
- id2InfoPrj.invoke(trashId,
- new ListingAdd(lowermostExistingInfo.id().toString(), deletedEntry));
+ transferEntry(deletedEntry, parentId, name, trashId,
+ lowermostExistingInfo.id().toString());
// Update a file info of the removed file with a file path,
// which will be used by delete worker for event notifications.
- id2InfoPrj.invoke(lowermostExistingInfo.id(), new UpdatePath(path));
+ invokeUpdatePath(lowermostExistingInfo.id(), path);
// Make a new locked info:
long t = System.currentTimeMillis();
@@ -3429,12 +3418,7 @@ public class IgfsMetaManager extends IgfsManager {
assert newFileInfo.lockId() != null; // locked info should be created.
- boolean put = id2InfoPrj.putIfAbsent(newFileInfo.id(), newFileInfo);
-
- assert put;
-
- id2InfoPrj.invoke(parentId,
- new ListingAdd(name, new IgfsListingEntry(newFileInfo)));
+ createNewEntry(newFileInfo, parentId, name);
IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(newFileInfo, parentId);
@@ -3497,54 +3481,103 @@ public class IgfsMetaManager extends IgfsManager {
/** File chain builder. */
private class DirectoryChainBuilder {
/** The requested path to be created. */
- protected final IgfsPath path;
+ private final IgfsPath path;
/** Full path components. */
- protected final List<String> components;
+ private final List<String> components;
/** The list of ids. */
- protected final List<IgniteUuid> idList;
+ private final List<IgniteUuid> idList;
/** The set of ids. */
- protected final SortedSet<IgniteUuid> idSet;
+ private final SortedSet<IgniteUuid> idSet = new TreeSet<IgniteUuid>(PATH_ID_SORTING_COMPARATOR);
/** The middle node properties. */
- protected final Map<String, String> middleProps;
+ private final Map<String, String> middleProps;
/** The leaf node properties. */
- protected final Map<String, String> leafProps;
+ private final Map<String, String> leafProps;
/** The lowermost exsiting path id. */
- protected final IgniteUuid lowermostExistingId;
+ private final IgniteUuid lowermostExistingId;
/** The existing path. */
- protected final IgfsPath existingPath;
+ private final IgfsPath existingPath;
/** The created leaf info. */
- protected IgfsFileInfo leafInfo;
+ private IgfsFileInfo leafInfo;
/** The leaf parent id. */
- protected IgniteUuid leafParentId;
+ private IgniteUuid leafParentId;
/** The number of existing ids. */
- protected final int existingIdCnt;
+ private final int existingIdCnt;
+
+ /** Whether laef is directory. */
+ private final boolean leafDir;
+
+ /** Block size. */
+ private final int blockSize;
+
+ /** Affinity key. */
+ private final IgniteUuid affKey;
+
+ /** Evict exclude flag. */
+ private final boolean evictExclude;
/**
- * Creates the builder and performa all the initial calculations.
+ * Constructor for directories.
+ *
+ * @param path Path.
+ * @param props Properties.
+ * @throws IgniteCheckedException If failed.
*/
- protected DirectoryChainBuilder(IgfsPath path,
- Map<String,String> middleProps, Map<String,String> leafProps) throws IgniteCheckedException {
- this.path = path;
+ protected DirectoryChainBuilder(IgfsPath path, Map<String, String> props) throws IgniteCheckedException {
+ this(path, props, props, true, 0, null, false);
+ }
- this.components = path.components();
+ /**
+ * Constructor for files.
+ *
+ * @param path Path.
+ * @param dirProps Directory properties.
+ * @param fileProps File properties.
+ * @param blockSize Block size.
+ * @param affKey Affinity key (optional).
+ * @param evictExclude Evict exclude flag.
+ * @throws IgniteCheckedException If failed.
+ */
+ protected DirectoryChainBuilder(IgfsPath path, Map<String, String> dirProps, Map<String, String> fileProps,
+ int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude)
+ throws IgniteCheckedException {
+ this(path, dirProps, fileProps, false, blockSize, affKey, evictExclude);
+ }
+ /**
+ * Constructor.
+ *
+ * @param path Path.
+ * @param middleProps Middle properties.
+ * @param leafProps Leaf properties.
+ * @param leafDir Whether leaf is directory or file.
+ * @param blockSize Block size.
+ * @param affKey Affinity key (optional).
+ * @param evictExclude Evict exclude flag.
+ * @throws IgniteCheckedException If failed.
+ */
+ private DirectoryChainBuilder(IgfsPath path, Map<String,String> middleProps, Map<String,String> leafProps,
+ boolean leafDir, int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude)
+ throws IgniteCheckedException {
+ this.path = path;
+ this.components = path.components();
this.idList = fileIds(path);
-
- this.idSet = new TreeSet<IgniteUuid>(PATH_ID_SORTING_COMPARATOR);
-
this.middleProps = middleProps;
-
this.leafProps = leafProps;
+ this.leafDir = leafDir;
+ this.blockSize = blockSize;
+ this.affKey = affKey;
+ this.evictExclude = evictExclude;
+
// Store all the non-null ids in the set & construct existing path in one loop:
IgfsPath existingPath = path.root();
@@ -3555,7 +3588,7 @@ public class IgfsMetaManager extends IgfsManager {
int idIdx = 0;
- for (IgniteUuid id: idList) {
+ for (IgniteUuid id : idList) {
if (id == null)
break;
@@ -3581,33 +3614,6 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * Builds middle nodes.
- */
- protected IgfsFileInfo buildMiddleNode(String childName, IgfsFileInfo childInfo) {
- return new IgfsFileInfo(Collections.singletonMap(childName,
- new IgfsListingEntry(childInfo)), middleProps);
- }
-
- /**
- * Builds leaf.
- */
- protected IgfsFileInfo buildLeaf() {
- long t = System.currentTimeMillis();
-
- return new IgfsFileInfo(true, leafProps, t, t);
- }
-
- /**
- * Links newly created chain to existing parent.
- */
- final void linkBuiltChainToExistingParent(String childName, IgfsFileInfo childInfo)
- throws IgniteCheckedException {
- assert childInfo != null;
-
- id2InfoPrj.invoke(lowermostExistingId, new ListingAdd(childName, new IgfsListingEntry(childInfo)));
- }
-
- /**
* Does the main portion of job building the renmaining path.
*/
public final void doBuild() throws IgniteCheckedException {
@@ -3615,7 +3621,8 @@ public class IgfsMetaManager extends IgfsManager {
String childName = null;
- IgfsFileInfo newLeafInfo;
+ IgfsFileInfo newInfo;
+
IgniteUuid parentId = null;
// This loop creates the missing directory chain from the bottom to the top:
@@ -3625,28 +3632,29 @@ public class IgfsMetaManager extends IgfsManager {
if (childName == null) {
assert childInfo == null;
- newLeafInfo = buildLeaf();
+ long t = System.currentTimeMillis();
- assert newLeafInfo != null;
+ if (leafDir)
+ newInfo = new IgfsFileInfo(true, leafProps, t, t);
+ else
+ newInfo = new IgfsFileInfo(blockSize, 0L, affKey, createFileLockId(false), evictExclude,
+ leafProps, t, t);
- leafInfo = newLeafInfo;
+ leafInfo = newInfo;
}
else {
assert childInfo != null;
- newLeafInfo = buildMiddleNode(childName, childInfo);
-
- assert newLeafInfo != null;
+ newInfo = new IgfsFileInfo(Collections.singletonMap(childName,
+ new IgfsListingEntry(childInfo)), middleProps);
if (parentId == null)
- parentId = newLeafInfo.id();
+ parentId = newInfo.id();
}
- boolean put = id2InfoPrj.putIfAbsent(newLeafInfo.id(), newLeafInfo);
+ id2InfoPrj.put(newInfo.id(), newInfo);
- assert put; // Because we used a new id that should be unique.
-
- childInfo = newLeafInfo;
+ childInfo = newInfo;
childName = components.get(i);
}
@@ -3657,7 +3665,7 @@ public class IgfsMetaManager extends IgfsManager {
leafParentId = parentId;
// Now link the newly created directory chain to the lowermost existing parent:
- linkBuiltChainToExistingParent(childName, childInfo);
+ id2InfoPrj.invoke(lowermostExistingId, new ListingAdd(childName, new IgfsListingEntry(childInfo)));
}
/**
@@ -3674,7 +3682,7 @@ public class IgfsMetaManager extends IgfsManager {
}
}
- if (leafInfo.isDirectory())
+ if (leafDir)
IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_DIR_CREATED);
else {
IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_FILE_CREATED);
@@ -3684,66 +3692,6 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * Processor closure to locks a file for writing.
- */
- private static class LockFileProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** New lock id to lock the entry. */
- private IgniteUuid newLockId;
-
- /**
- * Constructor.
- */
- public LockFileProcessor(IgniteUuid newLockId) {
- assert newLockId != null;
-
- this.newLockId = newLockId;
- }
-
- /**
- * Empty constructor required for {@link Externalizable}.
- */
- public LockFileProcessor() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override @Nullable public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry,
- Object... arguments) throws EntryProcessorException {
- final IgfsFileInfo info = entry.getValue();
-
- assert info != null;
-
- if (info.lockId() != null)
- return null; // file is already locked.
-
- IgfsFileInfo newInfo = new IgfsFileInfo(info, newLockId, info.modificationTime());
-
- entry.setValue(newInfo);
-
- return newInfo;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeGridUuid(out, newLockId);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- newLockId = U.readGridUuid(in);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(LockFileProcessor.class, this);
- }
- }
-
- /**
* File lock entry processor.
*/
private static class FileLockProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>, Externalizable {
@@ -3902,6 +3850,69 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
+ * Update properties processor.
+ */
+ private static class UpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Properties to be updated. */
+ private Map<String, String> props;
+
+ /**
+ * Constructor.
+ */
+ public UpdatePropertiesProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param props Properties.
+ */
+ public UpdatePropertiesProcessor(Map<String, String> props) {
+ this.props = props;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsFileInfo oldInfo = entry.getValue();
+
+ Map<String, String> tmp = oldInfo.properties();
+
+ tmp = tmp == null ? new GridLeanMap<String, String>(props.size()) : new GridLeanMap<>(tmp);
+
+ for (Map.Entry<String, String> e : props.entrySet()) {
+ if (e.getValue() == null)
+ // Remove properties with 'null' values.
+ tmp.remove(e.getKey());
+ else
+ // Add/overwrite property.
+ tmp.put(e.getKey(), e.getValue());
+ }
+
+ IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, tmp);
+
+ entry.setValue(newInfo);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeStringMap(out, props);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ props = U.readStringMap(in);
+ }
+ }
+
+ /**
* Update times entry processor.
*/
private static class UpdateTimesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f7e3c1c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
index f3d35f4..72a2bee 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
@@ -171,33 +171,30 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
assertNull("Unexpected stored properties: " + info, info.properties().get(key1));
assertNull("Unexpected stored properties: " + info, info.properties().get(key2));
- info = mgr.updateProperties(ROOT_ID, fileId, fileName, F.asMap(key1, "1"));
+ info = mgr.updateProperties(fileId, F.asMap(key1, "1"));
assertEquals("Unexpected stored properties: " + info, "1", info.properties().get(key1));
- info = mgr.updateProperties(ROOT_ID, fileId, fileName, F.asMap(key2, "2"));
+ info = mgr.updateProperties(fileId, F.asMap(key2, "2"));
// assertEquals("Unexpected stored properties: " + info, F.asMap(key1, "1", key2, "2"), info.properties());
assertEquals("Unexpected stored properties: " + info, "1", info.properties().get(key1));
assertEquals("Unexpected stored properties: " + info, "2", info.properties().get(key2));
- info = mgr.updateProperties(ROOT_ID, fileId, fileName, F.<String, String>asMap(key1, null));
+ info = mgr.updateProperties(fileId, F.<String, String>asMap(key1, null));
assertEquals("Unexpected stored properties: " + info, "2", info.properties().get(key2));
- info = mgr.updateProperties(ROOT_ID, fileId, fileName, F.<String, String>asMap(key2, null));
+ info = mgr.updateProperties(fileId, F.<String, String>asMap(key2, null));
assertNull("Unexpected stored properties: " + info, info.properties().get(key1));
assertNull("Unexpected stored properties: " + info, info.properties().get(key2));
-
- assertNull(mgr.updateProperties(ROOT_ID, fileId, "not_exists", F.<String, String>asMap(key2, null)));
}
mgr.softDelete(new IgfsPath("/dir"), true);
mgr.softDelete(new IgfsPath("/file"), false);
- assertNull(mgr.updateProperties(ROOT_ID, dir.id(), "dir", F.asMap("p", "7")));
- assertNull(mgr.updateProperties(ROOT_ID, file.id(), "file", F.asMap("q", "8")));
+ assertNull(mgr.updateProperties(dir.id(), F.asMap("p", "7")));
}
private IgfsFileInfo mkdirsAndGetInfo(String path) throws IgniteCheckedException {
@@ -309,8 +306,8 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
expectsRenameFail("/a/k", "/a/b/", "Failed to perform move because destination already " +
"contains entry with the same name existing file");
- mgr.delete(a.id(), "k", k.id());
- mgr.delete(b.id(), "k", z.id());
+ mgr.delete(a.id(), "k", z.id());
+ mgr.delete(b.id(), "k", k.id());
System.out.println("/: " + mgr.directoryListing(ROOT_ID));
System.out.println("a: " + mgr.directoryListing(a.id()));
@@ -339,9 +336,7 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
assertEquals(F.asMap("a", new IgfsListingEntry(a), "f1", new IgfsListingEntry(f1)),
mgr.directoryListing(ROOT_ID));
- assertEquals(
- F.asMap("b", new IgfsListingEntry(b),
- "f2", new IgfsListingEntry(f2)),
+ assertEquals(F.asMap("b", new IgfsListingEntry(b), "f2", new IgfsListingEntry(f2)),
mgr.directoryListing(a.id()));
assertEmpty(mgr.directoryListing(b.id()));
@@ -423,7 +418,7 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
Class<? extends Throwable> cls, @Nullable String msg) {
assertThrows(log, new Callable() {
@Override public Object call() throws Exception {
- return mgr.updateProperties(null, fileId, "file", props);
+ return mgr.updateProperties(fileId, props);
}
}, cls, msg);
}
[11/50] [abbrv] ignite git commit: IGNITE-2828: IGFS: Introduced
processor for "updateTimes" operation.
Posted by sb...@apache.org.
IGNITE-2828: IGFS: Introduced processor for "updateTimes" operation.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a7c1f444
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a7c1f444
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a7c1f444
Branch: refs/heads/ignite-1837
Commit: a7c1f44420ae96f183abc2e17125f0c9aa0775d5
Parents: 8083391
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Mar 14 15:57:28 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:10 2016 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsMetaManager.java | 73 ++++++++++++++++----
.../ignite/testsuites/IgniteIgfsTestSuite.java | 6 --
2 files changed, 61 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7c1f444/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index 8bb9e92..d3aae58 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -411,7 +411,7 @@ public class IgfsMetaManager extends IgfsManager {
// Force root ID always exist in cache.
if (info == null && IgfsUtils.ROOT_ID.equals(fileId))
- id2InfoPrj.putIfAbsent(IgfsUtils.ROOT_ID, info = new IgfsFileInfo());
+ info = createSystemEntryIfAbsent(fileId);
return info;
}
@@ -443,13 +443,9 @@ public class IgfsMetaManager extends IgfsManager {
// Force root ID always exist in cache.
if (fileIds.contains(IgfsUtils.ROOT_ID) && !map.containsKey(IgfsUtils.ROOT_ID)) {
- IgfsFileInfo info = new IgfsFileInfo();
-
- id2InfoPrj.putIfAbsent(IgfsUtils.ROOT_ID, info);
-
map = new GridLeanMap<>(map);
- map.put(IgfsUtils.ROOT_ID, info);
+ map.put(IgfsUtils.ROOT_ID, createSystemEntryIfAbsent(IgfsUtils.ROOT_ID));
}
return map;
@@ -666,8 +662,6 @@ public class IgfsMetaManager extends IgfsManager {
*/
private IgfsFileInfo createSystemEntryIfAbsent(IgniteUuid id)
throws IgniteCheckedException {
- assert validTxState(true);
-
assert IgfsUtils.isRootOrTrashId(id);
IgfsFileInfo info = new IgfsFileInfo(id);
@@ -2995,11 +2989,10 @@ public class IgfsMetaManager extends IgfsManager {
assert parentInfo.isDirectory();
- IgfsFileInfo updated = new IgfsFileInfo(fileInfo,
+ id2InfoPrj.invoke(fileId, new UpdateTimesProcessor(
accessTime == -1 ? fileInfo.accessTime() : accessTime,
- modificationTime == -1 ? fileInfo.modificationTime() : modificationTime);
-
- id2InfoPrj.put(fileId, updated);
+ modificationTime == -1 ? fileInfo.modificationTime() : modificationTime)
+ );
id2InfoPrj.invoke(parentId, new UpdateListingEntry(fileId, fileName, 0, accessTime,
modificationTime));
@@ -4058,4 +4051,60 @@ public class IgfsMetaManager extends IgfsManager {
affRange = (IgfsFileAffinityRange)in.readObject();
}
}
+
+ /**
+ * Update times entry processor.
+ */
+ private static class UpdateTimesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Access time. */
+ private long accessTime;
+
+ /** Modification time. */
+ private long modificationTime;
+
+ /**
+ * Default constructor.
+ */
+ public UpdateTimesProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param accessTime Access time.
+ * @param modificationTime Modification time.
+ */
+ public UpdateTimesProcessor(long accessTime, long modificationTime) {
+ this.accessTime = accessTime;
+ this.modificationTime = modificationTime;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ throws EntryProcessorException {
+
+ IgfsFileInfo oldInfo = entry.getValue();
+
+ entry.setValue(new IgfsFileInfo(oldInfo, accessTime, modificationTime));
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(accessTime);
+ out.writeLong(modificationTime);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ accessTime = in.readLong();
+ modificationTime = in.readLong();
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a7c1f444/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
index cc5e1ce..489088c 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
@@ -90,12 +90,6 @@ public class IgniteIgfsTestSuite extends TestSuite {
suite.addTest(new TestSuite(IgfsModesSelfTest.class));
suite.addTest(new TestSuite(IgfsMetricsSelfTest.class));
- suite.addTest(new TestSuite(IgfsPrimarySelfTest.class));
- suite.addTest(new TestSuite(IgfsPrimaryOffheapTieredSelfTest.class));
- suite.addTest(new TestSuite(IgfsPrimaryOffheapValuesSelfTest.class));
- suite.addTest(new TestSuite(IgfsDualSyncSelfTest.class));
- suite.addTest(new TestSuite(IgfsDualAsyncSelfTest.class));
-
suite.addTest(new TestSuite(IgfsClientCacheSelfTest.class));
suite.addTest(new TestSuite(IgfsOneClientNodeTest.class));
[14/50] [abbrv] ignite git commit: IGNITE-2842: IGFS: Optimized
create/mkdirs operations with help of entry processors.
Posted by sb...@apache.org.
IGNITE-2842: IGFS: Optimized create/mkdirs operations with help of entry processors.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3e59321e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3e59321e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3e59321e
Branch: refs/heads/ignite-1837
Commit: 3e59321ef0ae1d936d94f8f804db45ceeff55844
Parents: 4f7e3c1
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Mar 16 12:31:37 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:21 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsFileInfo.java | 13 +
.../processors/igfs/IgfsListingEntry.java | 15 +-
.../processors/igfs/IgfsMetaManager.java | 262 ++++++++++++++++---
3 files changed, 251 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3e59321e/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
index ba484bb..13c54ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
@@ -345,6 +345,19 @@ public final class IgfsFileInfo implements Externalizable {
}
/**
+ * Temporal hack to change ID before saving entry to cache. Currently we have too much constructors and adding
+ * more will make things even worse. Instead, we use this method until directories and files are split into
+ * separate entities.
+ *
+ * @param id ID.
+ * @deprecated Use only on not-yet-saved entries.
+ */
+ @Deprecated
+ public void id(IgniteUuid id) {
+ this.id = id;
+ }
+
+ /**
* @return {@code True} if this is a file.
*/
public boolean isFile() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/3e59321e/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
index 61d9265..4fe0dca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
@@ -34,7 +34,7 @@ public class IgfsListingEntry implements Externalizable {
/** */
private static final long serialVersionUID = 0L;
- /** File id. */
+ /** ID. */
private IgniteUuid id;
/** Directory marker. */
@@ -48,6 +48,8 @@ public class IgfsListingEntry implements Externalizable {
}
/**
+ * Constructor.
+ *
* @param fileInfo File info to construct listing entry from.
*/
public IgfsListingEntry(IgfsFileInfo fileInfo) {
@@ -56,6 +58,17 @@ public class IgfsListingEntry implements Externalizable {
}
/**
+ * Constructor.
+ *
+ * @param id File ID.
+ * @param dir Directory marker.
+ */
+ public IgfsListingEntry(IgniteUuid id, boolean dir) {
+ this.id = id;
+ this.dir = dir;
+ }
+
+ /**
* @return Entry file ID.
*/
public IgniteUuid fileId() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/3e59321e/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index df69d49..2a85cf8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -1868,13 +1868,11 @@ public class IgfsMetaManager extends IgfsManager {
* @return New file info.
* @throws IgniteCheckedException If failed.
*/
- private IgfsFileInfo invokeAndGet(IgniteUuid id, EntryProcessor<IgniteUuid, IgfsFileInfo, Void> proc)
+ private IgfsFileInfo invokeAndGet(IgniteUuid id, EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo> proc)
throws IgniteCheckedException {
validTxState(true);
- id2InfoPrj.invoke(id, proc);
-
- return getInfo(id);
+ return id2InfoPrj.invoke(id, proc).get();
}
/**
@@ -3493,7 +3491,7 @@ public class IgfsMetaManager extends IgfsManager {
private final SortedSet<IgniteUuid> idSet = new TreeSet<IgniteUuid>(PATH_ID_SORTING_COMPARATOR);
/** The middle node properties. */
- private final Map<String, String> middleProps;
+ private final Map<String, String> props;
/** The leaf node properties. */
private final Map<String, String> leafProps;
@@ -3557,7 +3555,7 @@ public class IgfsMetaManager extends IgfsManager {
* Constructor.
*
* @param path Path.
- * @param middleProps Middle properties.
+ * @param props Middle properties.
* @param leafProps Leaf properties.
* @param leafDir Whether leaf is directory or file.
* @param blockSize Block size.
@@ -3565,13 +3563,13 @@ public class IgfsMetaManager extends IgfsManager {
* @param evictExclude Evict exclude flag.
* @throws IgniteCheckedException If failed.
*/
- private DirectoryChainBuilder(IgfsPath path, Map<String,String> middleProps, Map<String,String> leafProps,
+ private DirectoryChainBuilder(IgfsPath path, Map<String,String> props, Map<String,String> leafProps,
boolean leafDir, int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude)
throws IgniteCheckedException {
this.path = path;
this.components = path.components();
this.idList = fileIds(path);
- this.middleProps = middleProps;
+ this.props = props;
this.leafProps = leafProps;
this.leafDir = leafDir;
this.blockSize = blockSize;
@@ -3617,44 +3615,46 @@ public class IgfsMetaManager extends IgfsManager {
* Does the main portion of job building the renmaining path.
*/
public final void doBuild() throws IgniteCheckedException {
- IgfsFileInfo childInfo = null;
+ // Fix current time. It will be used in all created entities.
+ long createTime = System.currentTimeMillis();
+ IgfsListingEntry childInfo = null;
String childName = null;
- IgfsFileInfo newInfo;
-
IgniteUuid parentId = null;
// This loop creates the missing directory chain from the bottom to the top:
for (int i = components.size() - 1; i >= existingIdCnt - 1; i--) {
- // Required entry does not exist.
- // Create new directory info:
+ IgniteUuid childId = IgniteUuid.randomUuid();
+ boolean childDir;
+
if (childName == null) {
assert childInfo == null;
- long t = System.currentTimeMillis();
+ if (leafDir) {
+ childDir = true;
- if (leafDir)
- newInfo = new IgfsFileInfo(true, leafProps, t, t);
- else
- newInfo = new IgfsFileInfo(blockSize, 0L, affKey, createFileLockId(false), evictExclude,
- leafProps, t, t);
+ leafInfo = invokeAndGet(childId, new DirectoryCreateProcessor(createTime, leafProps));
+ }
+ else {
+ childDir = false;
- leafInfo = newInfo;
+ leafInfo = invokeAndGet(childId, new FileCreateProcessor(createTime, leafProps, blockSize,
+ affKey, createFileLockId(false), evictExclude));
+ }
}
else {
assert childInfo != null;
- newInfo = new IgfsFileInfo(Collections.singletonMap(childName,
- new IgfsListingEntry(childInfo)), middleProps);
+ childDir = true;
+
+ id2InfoPrj.invoke(childId, new DirectoryCreateProcessor(createTime, props, childName, childInfo));
if (parentId == null)
- parentId = newInfo.id();
+ parentId = childId;
}
- id2InfoPrj.put(newInfo.id(), newInfo);
-
- childInfo = newInfo;
+ childInfo = new IgfsListingEntry(childId, childDir);
childName = components.get(i);
}
@@ -3665,7 +3665,7 @@ public class IgfsMetaManager extends IgfsManager {
leafParentId = parentId;
// Now link the newly created directory chain to the lowermost existing parent:
- id2InfoPrj.invoke(lowermostExistingId, new ListingAdd(childName, new IgfsListingEntry(childInfo)));
+ id2InfoPrj.invoke(lowermostExistingId, new ListingAdd(childName, childInfo));
}
/**
@@ -3692,9 +3692,193 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
+ * File create processor.
+ */
+ private static class FileCreateProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Create time. */
+ private long createTime;
+
+ /** Properties. */
+ private Map<String, String> props;
+
+ /** Block size. */
+ private int blockSize;
+
+ /** Affintiy key. */
+ private IgniteUuid affKey;
+
+ /** Lcok ID. */
+ private IgniteUuid lockId;
+
+ /** Evict exclude flag. */
+ private boolean evictExclude;
+
+ /**
+ * Constructor.
+ */
+ public FileCreateProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param createTime Create time.
+ * @param props Properties.
+ * @param blockSize Block size.
+ * @param affKey Affinity key.
+ * @param lockId Lock ID.
+ * @param evictExclude Evict exclude flag.
+ */
+ public FileCreateProcessor(long createTime, Map<String, String> props, int blockSize,
+ @Nullable IgniteUuid affKey, IgniteUuid lockId, boolean evictExclude) {
+ this.createTime = createTime;
+ this.props = props;
+ this.blockSize = blockSize;
+ this.affKey = affKey;
+ this.lockId = lockId;
+ this.evictExclude = evictExclude;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsFileInfo info = new IgfsFileInfo(blockSize, 0L, affKey, lockId, evictExclude, props,
+ createTime, createTime);
+
+ info.id(entry.getKey());
+
+ entry.setValue(info);
+
+ return info;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(createTime);
+ U.writeStringMap(out, props);
+ out.writeInt(blockSize);
+ out.writeObject(affKey);
+ out.writeObject(lockId);
+ out.writeBoolean(evictExclude);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ createTime = in.readLong();
+ props = U.readStringMap(in);
+ blockSize = in.readInt();
+ affKey = (IgniteUuid)in.readObject();
+ lockId = (IgniteUuid)in.readObject();
+ evictExclude = in.readBoolean();
+ }
+ }
+
+ /**
+ * Directory create processor.
+ */
+ private static class DirectoryCreateProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Create time. */
+ private long createTime;
+
+ /** Properties. */
+ private Map<String, String> props;
+
+ /** Child name (optional). */
+ private String childName;
+
+ /** Child entry (optional. */
+ private IgfsListingEntry childEntry;
+
+ /**
+ * Constructor.
+ */
+ public DirectoryCreateProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param createTime Create time.
+ * @param props Properties.
+ */
+ public DirectoryCreateProcessor(long createTime, Map<String, String> props) {
+ this(createTime, props, null, null);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param createTime Create time.
+ * @param props Properties.
+ * @param childName Child name.
+ * @param childEntry Child entry.
+ */
+ public DirectoryCreateProcessor(long createTime, Map<String, String> props, String childName,
+ IgfsListingEntry childEntry) {
+ this.createTime = createTime;
+ this.props = props;
+ this.childName = childName;
+ this.childEntry = childEntry;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ throws EntryProcessorException {
+
+ IgfsFileInfo info = new IgfsFileInfo(true, props, createTime, createTime);
+
+ if (childName != null)
+ info = new IgfsFileInfo(Collections.singletonMap(childName, childEntry), info);
+
+ info.id(entry.getKey());
+
+ entry.setValue(info);
+
+ return info;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(createTime);
+ U.writeStringMap(out, props);
+
+ if (childName != null) {
+ out.writeBoolean(true);
+
+ U.writeString(out, childName);
+ out.writeObject(childEntry);
+ }
+ else
+ out.writeBoolean(false);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ createTime = in.readLong();
+ props = U.readStringMap(in);
+
+ if (in.readBoolean()) {
+ childName = U.readString(in);
+ childEntry = (IgfsListingEntry)in.readObject();
+ }
+ }
+ }
+
+ /**
* File lock entry processor.
*/
- private static class FileLockProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>, Externalizable {
+ private static class FileLockProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3718,13 +3902,15 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo old = entry.getValue();
+ IgfsFileInfo oldInfo = entry.getValue();
- entry.setValue(new IgfsFileInfo(old, lockId, old.modificationTime()));
+ IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, lockId, oldInfo.modificationTime());
- return null;
+ entry.setValue(newInfo);
+
+ return newInfo;
}
/** {@inheritDoc} */
@@ -3789,7 +3975,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* File reserve space entry processor.
*/
- private static class FileReserveSpaceProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static class FileReserveSpaceProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3819,7 +4005,7 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
throws EntryProcessorException {
IgfsFileInfo oldInfo = entry.getValue();
@@ -3833,7 +4019,7 @@ public class IgfsMetaManager extends IgfsManager {
entry.setValue(newInfo);
- return null;
+ return newInfo;
}
/** {@inheritDoc} */
@@ -3852,7 +4038,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Update properties processor.
*/
- private static class UpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static class UpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3877,7 +4063,7 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
throws EntryProcessorException {
IgfsFileInfo oldInfo = entry.getValue();
@@ -3898,7 +4084,7 @@ public class IgfsMetaManager extends IgfsManager {
entry.setValue(newInfo);
- return null;
+ return newInfo;
}
/** {@inheritDoc} */
[43/50] [abbrv] ignite git commit: gridgain-7.5.11 Increased default
affinity history size.
Posted by sb...@apache.org.
gridgain-7.5.11 Increased default affinity history size.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/87f7522c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/87f7522c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/87f7522c
Branch: refs/heads/ignite-1837
Commit: 87f7522c56b5735442f8d52dbc63756de53f2464
Parents: 2397552
Author: sboikov <sb...@gridgain.com>
Authored: Wed Apr 6 09:46:47 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Apr 6 09:46:47 2016 +0300
----------------------------------------------------------------------
.../processors/cache/GridCachePartitionExchangeManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/87f7522c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index b54116c..14df1aa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -109,7 +109,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
private static final int EXCHANGE_HISTORY_SIZE = 1000;
/** Cleanup history size. */
- public static final int EXCH_FUT_CLEANUP_HISTORY_SIZE = getInteger(IGNITE_AFFINITY_HISTORY_SIZE, 100);
+ public static final int EXCH_FUT_CLEANUP_HISTORY_SIZE = getInteger(IGNITE_AFFINITY_HISTORY_SIZE, 1000);
/** Atomic reference for pending timeout object. */
private AtomicReference<ResendTimeoutObject> pendingResend = new AtomicReference<>();
[27/50] [abbrv] ignite git commit: IGNITE-2869: IGFS: Slightly
improved serialization of IgfsListingEntry.
Posted by sb...@apache.org.
IGNITE-2869: IGFS: Slightly improved serialization of IgfsListingEntry.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ee5ea53b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ee5ea53b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ee5ea53b
Branch: refs/heads/ignite-1837
Commit: ee5ea53bf9c4ad897459466e0b9b5447fc93ec2a
Parents: 76191ff
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Mar 22 09:20:32 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:59 2016 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsDirectoryInfo.java | 30 +++++++++++++++-
.../internal/processors/igfs/IgfsUtils.java | 38 ++++++++++++++++++++
.../meta/IgfsMetaDirectoryCreateProcessor.java | 4 +--
.../IgfsMetaDirectoryListingAddProcessor.java | 7 ++--
4 files changed, 74 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee5ea53b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
index 233c8ee..a426e8c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
@@ -23,7 +23,6 @@ import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.binary.BinaryReader;
import org.apache.ignite.binary.BinaryWriter;
import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -35,6 +34,7 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
/**
@@ -198,6 +198,20 @@ public class IgfsDirectoryInfo extends IgfsEntryInfo implements Binarylizable {
writeBinary(out);
+ if (listing != null) {
+ out.writeBoolean(true);
+
+ out.writeInt(listing.size());
+
+ for (Map.Entry<String, IgfsListingEntry> entry : listing.entrySet()) {
+ out.writeString(entry.getKey());
+
+ IgfsUtils.writeListingEntry(out, entry.getValue());
+ }
+ }
+ else
+ out.writeBoolean(false);
+
out.writeMap(listing);
}
@@ -207,6 +221,20 @@ public class IgfsDirectoryInfo extends IgfsEntryInfo implements Binarylizable {
readBinary(in);
+ if (in.readBoolean()) {
+ int listingSize = in.readInt();
+
+ listing = new HashMap<>(listingSize);
+
+ for (int i = 0; i < listingSize; i++) {
+ String key = in.readString();
+
+ IgfsListingEntry val = IgfsUtils.readListingEntry(in);
+
+ listing.put(key, val);
+ }
+ }
+
listing = in.readMap();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee5ea53b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index 325f636..7063f68 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -20,6 +20,8 @@ package org.apache.ignite.internal.processors.igfs;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.cluster.ClusterTopologyException;
@@ -30,6 +32,7 @@ import org.apache.ignite.events.IgfsEvent;
import org.apache.ignite.igfs.IgfsException;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
@@ -389,4 +392,39 @@ public class IgfsUtils {
return new IgfsFileInfo(id, blockSize, len, affKey, props, null, lockId, accessTime, modificationTime,
evictExclude);
}
+
+ /**
+ * Write listing entry.
+ *
+ * @param out Writer.
+ * @param entry Entry.
+ */
+ public static void writeListingEntry(BinaryRawWriter out, @Nullable IgfsListingEntry entry) {
+ if (entry != null) {
+ out.writeBoolean(true);
+
+ BinaryUtils.writeIgniteUuid(out, entry.fileId());
+
+ out.writeBoolean(entry.isDirectory());
+ }
+ else
+ out.writeBoolean(false);
+ }
+
+ /**
+ * Read listing entry.
+ *
+ * @param in Reader.
+ * @return Entry.
+ */
+ @Nullable public static IgfsListingEntry readListingEntry(BinaryRawReader in) {
+ if (in.readBoolean()) {
+ IgniteUuid id = BinaryUtils.readIgniteUuid(in);
+ boolean dir = in.readBoolean();
+
+ return new IgfsListingEntry(id, dir);
+ }
+ else
+ return null;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee5ea53b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
index dcca298..907019c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
@@ -148,7 +148,7 @@ public class IgfsMetaDirectoryCreateProcessor implements EntryProcessor<IgniteUu
out.writeString(childName);
if (childName != null)
- out.writeObject(childEntry);
+ IgfsUtils.writeListingEntry(out, childEntry);
}
/** {@inheritDoc} */
@@ -160,7 +160,7 @@ public class IgfsMetaDirectoryCreateProcessor implements EntryProcessor<IgniteUu
childName = in.readString();
if (childName != null)
- childEntry = in.readObject();
+ childEntry = IgfsUtils.readListingEntry(in);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee5ea53b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
index f27bdd5..e9fa867 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
@@ -26,6 +26,7 @@ import org.apache.ignite.binary.BinaryWriter;
import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsListingEntry;
+import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -113,7 +114,8 @@ public final class IgfsMetaDirectoryListingAddProcessor implements EntryProcesso
BinaryRawWriter out = writer.rawWriter();
out.writeString(fileName);
- out.writeObject(entry);
+
+ IgfsUtils.writeListingEntry(out, entry);
}
/** {@inheritDoc} */
@@ -121,7 +123,8 @@ public final class IgfsMetaDirectoryListingAddProcessor implements EntryProcesso
BinaryRawReader in = reader.rawReader();
fileName = in.readString();
- entry = in.readObject();
+
+ entry = IgfsUtils.readListingEntry(in);
}
/** {@inheritDoc} */
[35/50] [abbrv] ignite git commit: IGNITE-2883: IGFS: Now IPC
messages are handled in a dedicated thread pool.
Posted by sb...@apache.org.
IGNITE-2883: IGFS: Now IPC messages are handled in a dedicated thread pool.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/59705e00
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/59705e00
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/59705e00
Branch: refs/heads/ignite-1837
Commit: 59705e008267b1d5926410f95c68bb8ffb8cd93c
Parents: 01a6e86
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Mar 24 14:29:35 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:14:32 2016 +0300
----------------------------------------------------------------------
.../igfs/IgfsIpcEndpointConfiguration.java | 28 +++++++
.../processors/igfs/IgfsIpcHandler.java | 81 +++++++++++++++-----
.../internal/processors/igfs/IgfsProcessor.java | 11 ++-
.../internal/processors/igfs/IgfsServer.java | 2 +-
.../igfs/IgfsProcessorValidationSelfTest.java | 16 ++++
5 files changed, 117 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/59705e00/modules/core/src/main/java/org/apache/ignite/igfs/IgfsIpcEndpointConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsIpcEndpointConfiguration.java b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsIpcEndpointConfiguration.java
index 23993a6..1c68d0f 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsIpcEndpointConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsIpcEndpointConfiguration.java
@@ -49,6 +49,9 @@ public class IgfsIpcEndpointConfiguration {
*/
public static final String DFLT_TOKEN_DIR_PATH = "ipc/shmem";
+ /** Default threads count. */
+ public static final int DFLT_THREAD_CNT = IgniteConfiguration.AVAILABLE_PROC_CNT;
+
/** Endpoint type. */
private IgfsIpcEndpointType type = DFLT_TYPE;
@@ -64,6 +67,9 @@ public class IgfsIpcEndpointConfiguration {
/** Token directory path. */
private String tokenDirPath = DFLT_TOKEN_DIR_PATH;
+ /** Thread count. */
+ private int threadCnt = DFLT_THREAD_CNT;
+
/**
* Default constructor.
*/
@@ -236,6 +242,28 @@ public class IgfsIpcEndpointConfiguration {
this.tokenDirPath = tokenDirPath;
}
+ /**
+ * Get number of threads used by this endpoint to process incoming requests.
+ * <p>
+ * Defaults to {@link #DFLT_THREAD_CNT}.
+ *
+ * @return Number of threads used by this endpoint to process incoming requests.
+ */
+ public int getThreadCount() {
+ return threadCnt;
+ }
+
+ /**
+ * Set number of threads used by this endpoint to process incoming requests.
+ * <p>
+ * See {@link #getThreadCount()} for more information.
+ *
+ * @param threadCnt Number of threads used by this endpoint to process incoming requests.
+ */
+ public void setThreadCount(int threadCnt) {
+ this.threadCnt = threadCnt;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsIpcEndpointConfiguration.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/59705e00/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java
index eadbdb2..bf87384 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsIpcHandler.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.igfs;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.igfs.IgfsIpcEndpointConfiguration;
import org.apache.ignite.igfs.IgfsOutOfSpaceException;
import org.apache.ignite.igfs.IgfsOutputStream;
import org.apache.ignite.igfs.IgfsUserContext;
@@ -31,20 +32,22 @@ import org.apache.ignite.internal.igfs.common.IgfsIpcCommand;
import org.apache.ignite.internal.igfs.common.IgfsMessage;
import org.apache.ignite.internal.igfs.common.IgfsPathControlRequest;
import org.apache.ignite.internal.igfs.common.IgfsStreamControlRequest;
-import org.apache.ignite.internal.processors.closure.GridClosurePolicy;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
-import org.apache.ignite.internal.util.lang.GridPlainCallable;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteOutClosure;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.thread.IgniteThreadPoolExecutor;
import org.jetbrains.annotations.Nullable;
import java.io.Closeable;
import java.io.DataInput;
import java.io.IOException;
import java.util.Iterator;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicLong;
/**
@@ -70,6 +73,9 @@ class IgfsIpcHandler implements IgfsServerHandler {
/** Resource ID generator. */
private final AtomicLong rsrcIdGen = new AtomicLong();
+ /** Thread pool. */
+ private volatile IgniteThreadPoolExecutor pool;
+
/** Stopping flag. */
private volatile boolean stopping;
@@ -77,8 +83,10 @@ class IgfsIpcHandler implements IgfsServerHandler {
* Constructs IGFS IPC handler.
*
* @param igfsCtx Context.
+ * @param endpointCfg Endpoint configuration.
+ * @param mgmt Management flag.
*/
- IgfsIpcHandler(IgfsContext igfsCtx) {
+ IgfsIpcHandler(IgfsContext igfsCtx, IgfsIpcEndpointConfiguration endpointCfg, boolean mgmt) {
assert igfsCtx != null;
ctx = igfsCtx.kernalContext();
@@ -87,12 +95,24 @@ class IgfsIpcHandler implements IgfsServerHandler {
// Keep buffer size multiple of block size so no extra byte array copies is performed.
bufSize = igfsCtx.configuration().getBlockSize() * 2;
+ // Create thread pool for request handling.
+ int threadCnt = endpointCfg.getThreadCount();
+
+ String prefix = "igfs-" + igfsCtx.igfs().name() + (mgmt ? "mgmt-" : "") + "-ipc";
+
+ pool = new IgniteThreadPoolExecutor(prefix, igfsCtx.kernalContext().gridName(), threadCnt, threadCnt,
+ Long.MAX_VALUE, new LinkedBlockingQueue<Runnable>());
+
log = ctx.log(IgfsIpcHandler.class);
}
/** {@inheritDoc} */
@Override public void stop() throws IgniteCheckedException {
stopping = true;
+
+ U.shutdownNow(getClass(), pool, log);
+
+ pool = null;
}
/** {@inheritDoc} */
@@ -114,7 +134,7 @@ class IgfsIpcHandler implements IgfsServerHandler {
/** {@inheritDoc} */
@Override public IgniteInternalFuture<IgfsMessage> handleAsync(final IgfsClientSession ses,
- final IgfsMessage msg, DataInput in) {
+ final IgfsMessage msg, final DataInput in) {
try {
// Even if will be closed right after this call, response write error will be ignored.
if (stopping)
@@ -130,21 +150,32 @@ class IgfsIpcHandler implements IgfsServerHandler {
case MAKE_DIRECTORIES:
case LIST_FILES:
case LIST_PATHS: {
- IgfsMessage res = execute(ses, cmd, msg, in);
-
- fut = res == null ? null : new GridFinishedFuture<>(res);
+ fut = executeSynchronously(ses, cmd, msg, in);
break;
}
- // Execute command asynchronously in user's pool.
+ // Execute command asynchronously in pool.
default: {
- fut = ctx.closure().callLocalSafe(new GridPlainCallable<IgfsMessage>() {
- @Override public IgfsMessage call() throws Exception {
- // No need to pass data input for non-write-block commands.
- return execute(ses, cmd, msg, null);
- }
- }, GridClosurePolicy.IGFS_POOL);
+ try {
+ final GridFutureAdapter<IgfsMessage> fut0 = new GridFutureAdapter<>();
+
+ pool.execute(new Runnable() {
+ @Override public void run() {
+ try {
+ fut0.onDone(execute(ses, cmd, msg, in));
+ }
+ catch (Exception e) {
+ fut0.onDone(e);
+ }
+ }
+ });
+
+ fut = fut0;
+ }
+ catch (RejectedExecutionException ignored) {
+ fut = executeSynchronously(ses, cmd, msg, in);
+ }
}
}
@@ -157,6 +188,23 @@ class IgfsIpcHandler implements IgfsServerHandler {
}
/**
+ * Execute operation synchronously.
+ *
+ * @param ses Session.
+ * @param cmd Command.
+ * @param msg Message.
+ * @param in Input.
+ * @return Result.
+ * @throws Exception If failed.
+ */
+ @Nullable private IgniteInternalFuture<IgfsMessage> executeSynchronously(IgfsClientSession ses,
+ IgfsIpcCommand cmd, IgfsMessage msg, DataInput in) throws Exception {
+ IgfsMessage res = execute(ses, cmd, msg, in);
+
+ return res == null ? null : new GridFinishedFuture<>(res);
+ }
+
+ /**
* Execute IGFS command.
*
* @param ses Client connection session.
@@ -167,8 +215,7 @@ class IgfsIpcHandler implements IgfsServerHandler {
* @throws Exception If failed.
*/
private IgfsMessage execute(IgfsClientSession ses, IgfsIpcCommand cmd, IgfsMessage msg,
- @Nullable DataInput in)
- throws Exception {
+ @Nullable DataInput in) throws Exception {
switch (cmd) {
case HANDSHAKE:
return processHandshakeRequest((IgfsHandshakeRequest)msg);
@@ -495,8 +542,6 @@ class IgfsIpcHandler implements IgfsServerHandler {
}
case WRITE_BLOCK: {
- assert rsrcId != null : "Missing stream ID";
-
IgfsOutputStream out = (IgfsOutputStream)resource(ses, rsrcId);
if (out == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/59705e00/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
index 44f6e44..778de99 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
@@ -26,6 +26,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
+import org.apache.ignite.igfs.IgfsIpcEndpointConfiguration;
import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.igfs.mapreduce.IgfsJob;
@@ -316,12 +317,18 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
throw new IgniteCheckedException("Invalid IGFS data cache configuration (key affinity mapper class should be " +
IgfsGroupDataBlocksKeyMapper.class.getSimpleName() + "): " + cfg);
- if (cfg.getIpcEndpointConfiguration() != null) {
- final int tcpPort = cfg.getIpcEndpointConfiguration().getPort();
+ IgfsIpcEndpointConfiguration ipcCfg = cfg.getIpcEndpointConfiguration();
+
+ if (ipcCfg != null) {
+ final int tcpPort = ipcCfg.getPort();
if (!(tcpPort >= MIN_TCP_PORT && tcpPort <= MAX_TCP_PORT))
throw new IgniteCheckedException("IGFS endpoint TCP port is out of range [" + MIN_TCP_PORT +
".." + MAX_TCP_PORT + "]: " + tcpPort);
+
+ if (ipcCfg.getThreadCount() <= 0)
+ throw new IgniteCheckedException("IGFS endpoint thread count must be positive: " +
+ ipcCfg.getThreadCount());
}
long maxSpaceSize = cfg.getMaxSpaceSize();
http://git-wip-us.apache.org/repos/asf/ignite/blob/59705e00/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java
index 314baac..aa4b115 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsServer.java
@@ -139,7 +139,7 @@ public class IgfsServer {
if (srvEndpoint.getPort() >= 0)
igfsCtx.kernalContext().ports().registerPort(srvEndpoint.getPort(), TCP, srvEndpoint.getClass());
- hnd = new IgfsIpcHandler(igfsCtx);
+ hnd = new IgfsIpcHandler(igfsCtx, endpointCfg, mgmt);
// Start client accept worker.
acceptWorker = new AcceptWorker();
http://git-wip-us.apache.org/repos/asf/ignite/blob/59705e00/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java
index 27f47e8..0ce1036 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java
@@ -469,6 +469,22 @@ public class IgfsProcessorValidationSelfTest extends IgfsCommonAbstractTest {
}
/**
+ * @throws Exception If failed.
+ */
+ public void testInvalidEndpointThreadCount() throws Exception {
+ final String failMsg = "IGFS endpoint thread count must be positive";
+ g1Cfg.setCacheConfiguration(concat(dataCaches(1024), metaCaches(), CacheConfiguration.class));
+
+ final String igfsCfgName = "igfs-cfg";
+ final IgfsIpcEndpointConfiguration igfsEndpointCfg = new IgfsIpcEndpointConfiguration();
+ igfsEndpointCfg.setThreadCount(0);
+ g1IgfsCfg1.setName(igfsCfgName);
+ g1IgfsCfg1.setIpcEndpointConfiguration(igfsEndpointCfg);
+
+ checkGridStartFails(g1Cfg, failMsg, true);
+ }
+
+ /**
* Checks that the given grid configuration will lead to {@link IgniteCheckedException} upon grid startup.
*
* @param cfg Grid configuration to check.
[50/50] [abbrv] ignite git commit: ignite-1837
Posted by sb...@apache.org.
ignite-1837
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/08f46583
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/08f46583
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/08f46583
Branch: refs/heads/ignite-1837
Commit: 08f4658375aaab929bc4e093ad3ff571d0bb0bef
Parents: bbe1a7e
Author: sboikov <sb...@gridgain.com>
Authored: Mon Apr 11 18:42:58 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Apr 11 18:42:58 2016 +0300
----------------------------------------------------------------------
.../discovery/GridDiscoveryManager.java | 2 +
.../GridCachePartitionExchangeManager.java | 687 ++++++++---
.../GridDhtPartitionsExchangeFuture.java | 1096 +++++++++---------
.../preloader/GridDhtPartitionsFullMessage.java | 3 +-
.../internal/TestRecordingCommunicationSpi.java | 10 +-
.../IgniteOptimizedPartitionsExchangeTest.java | 207 ++++
6 files changed, 1298 insertions(+), 707 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/08f46583/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index b55ffb0..ed01a88 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -569,6 +569,8 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi> {
}
}, daemonFilter)));
+ ctx.cache().context().exchange().localJoinEvent(discoEvt);
+
locJoinEvt.onDone(discoEvt);
return;
http://git-wip-us.apache.org/repos/asf/ignite/blob/08f46583/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 5e91d01..60b7d5b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -21,17 +21,21 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
import java.util.Queue;
+import java.util.Set;
import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListMap;
-import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.ConcurrentSkipListSet;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
@@ -67,6 +71,7 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
import org.apache.ignite.internal.util.GridListSet;
+import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.IgnitePair;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -153,11 +158,450 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
* discovery event. In case if remote node will retry partition exchange, completed future will indicate
* that full partition map should be sent to requesting node right away.
*/
- private ExchangeFutureSet exchFuts = new ExchangeFutureSet();
+ //private ExchangeFutureSet exchFuts = new ExchangeFutureSet();
/** */
private volatile IgniteCheckedException stopErr;
+ /** */
+ private final ExchangeQueue exchQ = new ExchangeQueue();
+
+ /**
+ * TODO: backward compatibility.
+ */
+ class ExchangeQueue {
+ class Exchange {
+ final GridDhtPartitionExchangeId id;
+
+ final GridDhtPartitionsExchangeFuture fut;
+
+ Set<GridDhtPartitionExchangeId> addedJoins;
+
+ Map<GridDhtPartitionExchangeId, DiscoveryEvent> pendingJoins;
+
+ public Exchange(GridDhtPartitionExchangeId id, GridDhtPartitionsExchangeFuture fut) {
+ assert fut != null;
+
+ this.id = id;
+ this.fut = fut;
+ }
+
+ @Override public String toString() {
+ synchronized (ExchangeQueue.this) {
+ return "Exchange [topVer=" + (id != null ? id.topologyVersion() : null) +
+ ", pendingJoins=" + pendingJoins + ']';
+ }
+ }
+ }
+
+ List<GridDhtPartitionsExchangeFuture> futures() {
+ List<GridDhtPartitionsExchangeFuture> res;
+
+ synchronized (this) {
+ res = new ArrayList<>(exchanges.size());
+
+ for (Exchange exchange : exchanges)
+ res.add(exchange.fut);
+ }
+
+ return res;
+ }
+
+ /** */
+ private AffinityTopologyVersion lastVer = AffinityTopologyVersion.NONE;
+
+ /** */
+ private List<Exchange> exchanges = new ArrayList<>();
+
+ /** */
+ private Map<GridDhtPartitionExchangeId, Map<ClusterNode, GridDhtPartitionsSingleMessage>> singleMsgs = new HashMap<>();
+
+ /** */
+ private Map<GridDhtPartitionExchangeId, Map<ClusterNode, GridDhtPartitionsFullMessage>> fullMsgs = new HashMap<>();
+
+ /** */
+ private final CopyOnWriteArrayList<DiscoveryEventsFuture> discoFuts = new CopyOnWriteArrayList<>();
+
+ /** */
+ private Exchange curExch;
+
+ boolean empty() {
+ synchronized (this) {
+ return exchanges.isEmpty();
+ }
+ }
+
+ void onNodeLeft(ClusterNode node) {
+ List<GridDhtPartitionsExchangeFuture> futs = futures();
+
+ for (GridDhtPartitionsExchangeFuture fut : futs)
+ fut.onNodeLeft(node);
+ }
+
+ void onExchangeDone(GridDhtPartitionsExchangeFuture exchFut, AffinityTopologyVersion topVer) {
+ synchronized (this) {
+ assert curExch == null || curExch.fut == exchFut;
+ assert topVer.compareTo(lastVer) > 0;
+
+ lastVer = topVer;
+
+ for (Iterator<Exchange> it = exchanges.iterator(); it.hasNext();) {
+ Exchange exchange = it.next();
+
+ if (exchange.id != null && topVer.compareTo(exchange.id.topologyVersion()) > 0) {
+ log.info("Remove exchange [lastVer=" + lastVer +
+ ", evtTopVer=" + exchange.id.topologyVersion() + ", evt=" + exchange.fut.discoveryEvent() + ']');
+
+ it.remove();
+ }
+ }
+
+ curExch = null;
+ }
+ }
+
+ GridDhtPartitionsExchangeFuture initialExchangeFuture(DiscoveryEvent e) {
+ synchronized (this) {
+ assert exchanges.size() > 0;
+
+ GridDhtPartitionsExchangeFuture fut = exchanges.get(0).fut;
+
+ assert fut.topologyVersion().equals(affinityTopologyVersion(e));
+
+ return fut;
+ }
+ }
+
+ void onReceive(ClusterNode node, GridDhtPartitionsFullMessage msg) {
+ Exchange msgExch = null;
+
+ synchronized (this) {
+ log.info("Received full message [curExch=" + curExch +
+ ", msgExchId=" + msg.exchangeId() + ", msgTopVer=" + msg.topologyVersion() + ']');
+
+ if (curExch != null && curExch.id != null) {
+ if (curExch.id.equals(msg.exchangeId()))
+ msgExch = curExch;
+ else if (msg.topologyVersion().compareTo(curExch.id.topologyVersion()) >= 0)
+ msgExch = curExch;
+ }
+
+ if (msgExch == null) {
+ Map<ClusterNode, GridDhtPartitionsFullMessage> exchMsgs = fullMsgs.get(msg.exchangeId());
+
+ if (exchMsgs == null)
+ exchMsgs = new HashMap<>();
+
+ exchMsgs.put(node, msg);
+ }
+ }
+
+ if (msgExch != null)
+ msgExch.fut.onReceive(node, msg);
+ }
+
+ /**
+ * @param node Node.
+ * @param msg Message.
+ */
+ void onReceive(final ClusterNode node, final GridDhtPartitionsSingleMessage msg) {
+ Exchange msgExch = null;
+
+ synchronized (this) {
+ log.info("Received single message [curExch=" + curExch +
+ ", msgExchId=" + msg.exchangeId() + ", msgTopVer=" + msg.topologyVersion() + ']');
+
+ if (curExch != null && curExch.id != null) {
+ if (curExch.id.equals(msg.exchangeId()))
+ msgExch = curExch;
+ else if (curExch.addedJoins != null && curExch.addedJoins.contains(msg.exchangeId()))
+ msgExch = curExch;
+ }
+
+ if (msgExch == null) {
+ Map<ClusterNode, GridDhtPartitionsSingleMessage> exchMsgs = singleMsgs.get(msg.exchangeId());
+
+ if (exchMsgs == null)
+ exchMsgs = new HashMap<>();
+
+ exchMsgs.put(node, msg);
+ }
+ }
+
+ if (msgExch != null)
+ msgExch.fut.onReceive(node, msg);
+
+ // TODO IGNITE-1837.
+ if (msg.client()) {
+ final GridDhtPartitionsExchangeFuture exchFut = exchangeFuture(msg.exchangeId(),
+ null,
+ null);
+
+ exchFut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
+ @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> fut) {
+ // Finished future should reply only to sender client node.
+ exchFut.onReceive(node, msg);
+ }
+ });
+ }
+ }
+
+ public GridDhtPartitionsExchangeFuture poll(long timeout) throws InterruptedException {
+ Exchange exch;
+ Map<ClusterNode, GridDhtPartitionsSingleMessage> singleMsgs;
+ Map<ClusterNode, GridDhtPartitionsFullMessage> fullMsgs;
+
+ synchronized (this) {
+ assert curExch == null : curExch;
+
+ while (exchanges.isEmpty())
+ wait(timeout);
+
+ exch = curExch = exchanges.remove(0);
+
+ singleMsgs = this.singleMsgs.remove(exch.id);
+ fullMsgs = this.fullMsgs.remove(exch.id);
+
+ log.info("Poll next exchange: " + exch);
+ }
+
+ if (singleMsgs != null) {
+ for (Map.Entry<ClusterNode, GridDhtPartitionsSingleMessage> e : singleMsgs.entrySet())
+ exch.fut.onReceive(e.getKey(), e.getValue());
+ }
+
+ if (fullMsgs != null) {
+ for (Map.Entry<ClusterNode, GridDhtPartitionsFullMessage> e : fullMsgs.entrySet())
+ exch.fut.onReceive(e.getKey(), e.getValue());
+ }
+
+ return exch.fut;
+ }
+
+ /**
+ * @return
+ */
+ public IgniteInternalFuture<Map<AffinityTopologyVersion, DiscoveryEvent>> discoveryFuture(
+ AffinityTopologyVersion startVer, AffinityTopologyVersion endVer) {
+ assert !startVer.equals(endVer);
+
+ Map<AffinityTopologyVersion, DiscoveryEvent> res = new TreeMap<>();
+
+ synchronized (this) {
+ boolean done = false;
+
+ for (Exchange exchange : exchanges) {
+ if (exchange.id != null) {
+ if (exchange.id.topologyVersion().compareTo(startVer) > 0) {
+ int cmp = endVer.compareTo(exchange.id.topologyVersion());
+
+ if (cmp >= 0)
+ res.put(exchange.id.topologyVersion(), exchange.fut.discoveryEvent());
+
+ if (cmp == 0) {
+ done = true;
+
+ break;
+ }
+ }
+ }
+ }
+
+ if (!done) {
+ DiscoveryEventsFuture fut = new DiscoveryEventsFuture(startVer, endVer);
+
+ discoFuts.add(fut);
+
+ return fut;
+ }
+ }
+
+ return new GridFinishedFuture<>(res);
+ }
+
+ public boolean beforeFinishJoinExchange(GridDhtPartitionsExchangeFuture fut) {
+ Map<ClusterNode, GridDhtPartitionsSingleMessage> pendingMsgs = null;
+ Exchange exch;
+
+ synchronized (this) {
+ assert curExch != null && curExch.fut == fut : curExch;
+
+ log.info("beforeFinishJoinExchange [curExch=" + curExch + ']');
+
+ if (curExch.pendingJoins != null) {
+ Map<GridDhtPartitionExchangeId, DiscoveryEvent> pendingJoins = curExch.pendingJoins;
+
+ curExch.pendingJoins = null;
+
+ if (curExch.addedJoins == null)
+ curExch.addedJoins = new HashSet<>();
+
+ curExch.addedJoins.addAll(pendingJoins.keySet());
+
+ curExch.fut.processJoinExchanges(pendingJoins.values());
+
+ for (GridDhtPartitionExchangeId pendingId : pendingJoins.keySet()) {
+ Map<ClusterNode, GridDhtPartitionsSingleMessage> msgs0 = singleMsgs.remove(pendingId);
+
+ if (msgs0 != null) {
+ if (pendingMsgs == null)
+ pendingMsgs = new HashMap<>();
+
+ pendingMsgs.putAll(msgs0);
+ }
+ }
+
+ exch = curExch;
+ }
+ else {
+ curExch = null;
+
+ return false;
+ }
+ }
+
+ if (pendingMsgs != null) {
+ for (Map.Entry<ClusterNode, GridDhtPartitionsSingleMessage> e : pendingMsgs.entrySet())
+ exch.fut.onReceive(e.getKey(), e.getValue());
+ }
+
+ return true;
+ }
+
+ public void addExchange(DiscoveryEvent e,
+ GridDhtPartitionExchangeId exchId,
+ GridDhtPartitionsExchangeFuture fut) {
+ for (DiscoveryEventsFuture discoFut : discoFuts)
+ discoFut.onEvent(exchId.topologyVersion(), e);
+
+ synchronized (this) {
+ if (e != null) {
+ if (lastVer.compareTo(exchId.topologyVersion()) >= 0) {
+ log.info("Skip exchange [lastVer=" + lastVer +
+ ", evtTopVer=" + exchId.topologyVersion() + ", evt=" + e + ']');
+ }
+
+ if (curExch != null && curExch.id != null) {
+ if (curExch.fut.discoveryEvent().type() == EVT_NODE_JOINED && e.type() == EVT_NODE_JOINED) {
+ log.info("Add join event for current exchange [curExch=" + curExch +
+ ", evtTopVer=" + exchId.topologyVersion() + ", evt=" + e + ']');
+
+ if (curExch.pendingJoins == null)
+ curExch.pendingJoins = new TreeMap<>();
+
+ curExch.pendingJoins.put(fut.exchangeId(), e);
+
+ return;
+ }
+ }
+
+ if (!exchanges.isEmpty()) {
+ Exchange last = exchanges.get(exchanges.size() - 1);
+
+ if (last.id != null && last.fut.discoveryEvent().type() == EVT_NODE_JOINED && e.type() == EVT_NODE_JOINED) {
+ log.info("Add join event for last exchange [curExch=" + curExch +
+ ", evtTopVer=" + exchId.topologyVersion() + ", evt=" + e + ']');
+
+ last.pendingJoins.put(fut.exchangeId(), e);
+
+ return;
+ }
+ }
+ }
+
+ log.info("Add new exchange [curExch=" + curExch +
+ ", evtTopVer=" + exchId.topologyVersion() + ", evt=" + e + ']');
+
+ exchanges.add(new Exchange(exchId, fut));
+
+ notifyAll();
+ }
+
+ // Event callback - without this callback future will never complete.
+ if (e != null)
+ fut.onEvent(exchId, e);
+
+ if (stopErr != null)
+ fut.onDone(stopErr);
+ }
+
+ /**
+ *
+ */
+ class DiscoveryEventsFuture extends GridFutureAdapter<Map<AffinityTopologyVersion, DiscoveryEvent>> {
+ /** */
+ final Map<AffinityTopologyVersion, DiscoveryEvent> res = new TreeMap<>();
+
+ /** */
+ final AffinityTopologyVersion startVer;
+
+ /** */
+ final AffinityTopologyVersion endVer;
+
+ /**
+ * @param startVer
+ * @param endVer
+ */
+ public DiscoveryEventsFuture(AffinityTopologyVersion startVer, AffinityTopologyVersion endVer) {
+ this.startVer = startVer;
+ this.endVer = endVer;
+ }
+
+ /**
+ * @param topVer
+ * @param evt
+ */
+ void onEvent(AffinityTopologyVersion topVer, DiscoveryEvent evt) {
+ boolean done = false;
+
+ synchronized (this) {
+ if (topVer.compareTo(startVer) > 0) {
+ int cmp = endVer.compareTo(topVer);
+
+ if (cmp >= 0)
+ res.put(topVer, evt);
+
+ done = cmp == 0;
+ }
+ }
+
+ if (done)
+ onDone(res);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean onDone(Map<AffinityTopologyVersion, DiscoveryEvent> res, Throwable err) {
+ if (super.onDone(res, err)) {
+ discoFuts.remove(this);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ synchronized (this) {
+ return S.toString(DiscoveryEventsFuture.class, this);
+ }
+ }
+ }
+ }
+
+ public IgniteInternalFuture<Map<AffinityTopologyVersion, DiscoveryEvent>> discoveryFuture(
+ AffinityTopologyVersion startVer, AffinityTopologyVersion endVer) {
+ return exchQ.discoveryFuture(startVer, endVer);
+ }
+
+ public boolean beforeFinishJoinExchange(GridDhtPartitionsExchangeFuture fut) {
+ return exchQ.beforeFinishJoinExchange(fut);
+ }
+
+ public void localJoinEvent(DiscoveryEvent e) {
+ discoLsnr.onEvent(e);
+ }
+
/** Discovery listener. */
private final GridLocalEventListener discoLsnr = new GridLocalEventListener() {
@Override public void onEvent(Event evt) {
@@ -178,17 +622,14 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
GridDhtPartitionsExchangeFuture exchFut = null;
if (e.type() != EVT_DISCOVERY_CUSTOM_EVT) {
- assert !loc.id().equals(n.id());
-
if (e.type() == EVT_NODE_LEFT || e.type() == EVT_NODE_FAILED) {
assert cctx.discovery().node(n.id()) == null;
- for (GridDhtPartitionsExchangeFuture f : exchFuts.values())
- f.onNodeLeft(n.id());
+ exchQ.onNodeLeft(n);
}
assert
- e.type() != EVT_NODE_JOINED || n.order() > loc.order() :
+ e.type() != EVT_NODE_JOINED || n.order() > loc.order() || n.isLocal() :
"Node joined with smaller-than-local " +
"order [newOrder=" + n.order() + ", locOrder=" + loc.order() + ']';
@@ -196,7 +637,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
affinityTopologyVersion(e),
e.type());
- exchFut = exchangeFuture(exchId, e, null);
+ exchFut = new GridDhtPartitionsExchangeFuture(cctx, busyLock, exchId, null);
}
else {
DiscoveryCustomEvent customEvt = (DiscoveryCustomEvent)e;
@@ -231,7 +672,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
if (!F.isEmpty(valid)) {
exchId = exchangeId(n.id(), affinityTopologyVersion(e), e.type());
- exchFut = exchangeFuture(exchId, e, valid);
+ exchFut = new GridDhtPartitionsExchangeFuture(cctx, busyLock, exchId, valid);
}
}
}
@@ -240,11 +681,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
if (log.isDebugEnabled())
log.debug("Discovery event (will start exchange): " + exchId);
- // Event callback - without this callback future will never complete.
- exchFut.onEvent(exchId, e);
-
- // Start exchange process.
- addFuture(exchFut);
+ exchQ.addExchange(e, exchId, exchFut);
}
else {
if (log.isDebugEnabled())
@@ -305,24 +742,14 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
assert startTime > 0;
- // Generate dummy discovery event for local node joining.
+ // Discovery event for local node joining.
DiscoveryEvent discoEvt = cctx.discovery().localJoinEvent();
- final AffinityTopologyVersion startTopVer = affinityTopologyVersion(discoEvt);
-
- GridDhtPartitionExchangeId exchId = exchangeId(loc.id(), startTopVer, EVT_NODE_JOINED);
-
- assert discoEvt != null;
-
- assert discoEvt.topologyVersion() == startTopVer.topologyVersion();
-
- GridDhtPartitionsExchangeFuture fut = exchangeFuture(exchId, discoEvt, null);
+ GridDhtPartitionsExchangeFuture fut = exchQ.initialExchangeFuture(discoEvt);
if (reconnect)
reconnectExchangeFut = new GridFutureAdapter<>();
- exchWorker.futQ.addFirst(fut);
-
if (!cctx.kernalContext().clientNode()) {
for (int cnt = 0; cnt < cctx.gridConfig().getRebalanceThreadPoolSize(); cnt++) {
final int idx = cnt;
@@ -431,12 +858,8 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
new IgniteInterruptedCheckedException("Node is stopping: " + cctx.gridName());
// Finish all exchange futures.
- ExchangeFutureSet exchFuts0 = exchFuts;
-
- if (exchFuts0 != null) {
- for (GridDhtPartitionsExchangeFuture f : exchFuts.values())
- f.onDone(stopErr);
- }
+ for (GridDhtPartitionsExchangeFuture fut : exchangeFutures())
+ fut.onDone(stopErr);
for (AffinityReadyFuture f : readyFuts.values())
f.onDone(stopErr);
@@ -467,7 +890,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
// Do not allow any activity in exchange manager after stop.
busyLock.writeLock().lock();
- exchFuts = null;
+ //exchFuts = null;
}
/**
@@ -610,14 +1033,15 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
* @return Exchange futures.
*/
public List<GridDhtPartitionsExchangeFuture> exchangeFutures() {
- return exchFuts.values();
+ // TODO: need history here.
+ return exchQ.futures();
}
/**
* @return {@code True} if pending future queue is empty.
*/
public boolean hasPendingExchange() {
- return !exchWorker.futQ.isEmpty();
+ return !exchQ.empty();
}
/**
@@ -836,37 +1260,45 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
*/
GridDhtPartitionsExchangeFuture exchangeFuture(GridDhtPartitionExchangeId exchId,
@Nullable DiscoveryEvent discoEvt, @Nullable Collection<DynamicCacheChangeRequest> reqs) {
- GridDhtPartitionsExchangeFuture fut;
-
- GridDhtPartitionsExchangeFuture old = exchFuts.addx(
- fut = new GridDhtPartitionsExchangeFuture(cctx, busyLock, exchId, reqs));
-
- if (old != null) {
- fut = old;
-
- if (reqs != null)
- fut.cacheChangeRequests(reqs);
- }
-
- if (discoEvt != null)
- fut.onEvent(exchId, discoEvt);
-
- if (stopErr != null)
- fut.onDone(stopErr);
-
- return fut;
+// GridDhtPartitionsExchangeFuture fut;
+//
+// GridDhtPartitionsExchangeFuture old = exchFuts.addx(
+// fut = new GridDhtPartitionsExchangeFuture(cctx, busyLock, exchId, reqs));
+//
+// if (old != null) {
+// fut = old;
+//
+// if (reqs != null)
+// fut.cacheChangeRequests(reqs);
+// }
+//
+// if (discoEvt != null)
+// fut.onEvent(exchId, discoEvt);
+//
+// if (stopErr != null)
+// fut.onDone(stopErr);
+//
+// return fut;
+ return null;
}
/**
* @param exchFut Exchange.
* @param err Error.
*/
- public void onExchangeDone(GridDhtPartitionsExchangeFuture exchFut, @Nullable Throwable err) {
+ public void onExchangeDone(GridDhtPartitionsExchangeFuture exchFut,
+ AffinityTopologyVersion resTopVer,
+ @Nullable Throwable err) {
AffinityTopologyVersion topVer = exchFut.topologyVersion();
if (log.isDebugEnabled())
log.debug("Exchange done [topVer=" + topVer + ", fut=" + exchFut + ", err=" + err + ']');
+ if (resTopVer != null)
+ exchQ.onExchangeDone(exchFut, resTopVer);
+ else
+ assert err != null : exchFut;
+
IgniteProductVersion minVer = cctx.localNode().version();
IgniteProductVersion maxVer = cctx.localNode().version();
@@ -922,36 +1354,37 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
}
}
- ExchangeFutureSet exchFuts0 = exchFuts;
-
- if (exchFuts0 != null) {
- int skipped = 0;
-
- for (GridDhtPartitionsExchangeFuture fut : exchFuts0.values()) {
- if (exchFut.exchangeId().topologyVersion().compareTo(fut.exchangeId().topologyVersion()) < 0)
- continue;
-
- skipped++;
-
- if (skipped > 10)
- fut.cleanUp();
- }
- }
+ // TODO IGNITE-1837.
+// ExchangeFutureSet exchFuts0 = exchFuts;
+//
+// if (exchFuts0 != null) {
+// int skipped = 0;
+//
+// for (GridDhtPartitionsExchangeFuture fut : exchFuts0.values()) {
+// if (exchFut.exchangeId().topologyVersion().compareTo(fut.exchangeId().topologyVersion()) < 0)
+// continue;
+//
+// skipped++;
+//
+// if (skipped > 10)
+// fut.cleanUp();
+// }
+// }
}
/**
* @param fut Future.
* @return {@code True} if added.
*/
- private boolean addFuture(GridDhtPartitionsExchangeFuture fut) {
- if (fut.onAdded()) {
- exchWorker.addFuture(fut);
-
- return true;
- }
-
- return false;
- }
+// private boolean addFuture(GridDhtPartitionsExchangeFuture fut) {
+// if (fut.onAdded()) {
+// exchWorker.addFuture(fut);
+//
+// return true;
+// }
+//
+// return false;
+// }
/**
* @param node Node.
@@ -991,7 +1424,8 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
refreshPartitions();
}
else
- exchangeFuture(msg.exchangeId(), null, null).onReceive(node.id(), msg);
+ exchQ.onReceive(node, msg);
+ //exchangeFuture(msg.exchangeId(), null, null).onReceive(node.id(), msg);
}
finally {
leaveBusy();
@@ -1039,22 +1473,8 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
if (updated)
scheduleResendPartitions();
}
- else {
- if (msg.client()) {
- final GridDhtPartitionsExchangeFuture exchFut = exchangeFuture(msg.exchangeId(),
- null,
- null);
-
- exchFut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
- @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> fut) {
- // Finished future should reply only to sender client node.
- exchFut.onReceive(node.id(), msg);
- }
- });
- }
- else
- exchangeFuture(msg.exchangeId(), null, null).onReceive(node.id(), msg);
- }
+ else
+ exchQ.onReceive(node, msg);
}
finally {
leaveBusy();
@@ -1087,7 +1507,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
U.warn(log, "Pending exchange futures:");
- for (GridDhtPartitionsExchangeFuture fut : exchWorker.futQ)
+ for (GridDhtPartitionsExchangeFuture fut : exchQ.futures())
U.warn(log, ">>> " + fut);
if (!readyFuts.isEmpty()) {
@@ -1097,20 +1517,21 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
U.warn(log, ">>> " + fut);
}
- ExchangeFutureSet exchFuts = this.exchFuts;
-
- if (exchFuts != null) {
- U.warn(log, "Last 10 exchange futures (total: " + exchFuts.size() + "):");
-
- int cnt = 0;
-
- for (GridDhtPartitionsExchangeFuture fut : exchFuts.values()) {
- U.warn(log, ">>> " + fut);
-
- if (++cnt == 10)
- break;
- }
- }
+ // TODO IGNITE-1837.
+// ExchangeFutureSet exchFuts = this.exchFuts;
+//
+// if (exchFuts != null) {
+// U.warn(log, "Last 10 exchange futures (total: " + exchFuts.size() + "):");
+//
+// int cnt = 0;
+//
+// for (GridDhtPartitionsExchangeFuture fut : exchFuts.values()) {
+// U.warn(log, ">>> " + fut);
+//
+// if (++cnt == 10)
+// break;
+// }
+// }
dumpPendingObjects();
@@ -1172,36 +1593,10 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
}
/**
- * @param deque Deque to poll from.
- * @param time Time to wait.
- * @param w Worker.
- * @return Polled item.
- * @throws InterruptedException If interrupted.
- */
- @Nullable private <T> T poll(BlockingQueue<T> deque, long time, GridWorker w) throws InterruptedException {
- assert w != null;
-
- // There is currently a case where {@code interrupted}
- // flag on a thread gets flipped during stop which causes the pool to hang. This check
- // will always make sure that interrupted flag gets reset before going into wait conditions.
- // The true fix should actually make sure that interrupted flag does not get reset or that
- // interrupted exception gets propagated. Until we find a real fix, this method should
- // always work to make sure that there is no hanging during stop.
- if (w.isCancelled())
- Thread.currentThread().interrupt();
-
- return deque.poll(time, MILLISECONDS);
- }
-
- /**
* Exchange future thread. All exchanges happen only by one thread and next
* exchange will not start until previous one completes.
*/
private class ExchangeWorker extends GridWorker {
- /** Future queue. */
- private final LinkedBlockingDeque<GridDhtPartitionsExchangeFuture> futQ =
- new LinkedBlockingDeque<>();
-
/** Busy flag used as performance optimization to stop current preloading. */
private volatile boolean busy;
@@ -1218,8 +1613,8 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
void addFuture(GridDhtPartitionsExchangeFuture exchFut) {
assert exchFut != null;
- if (!exchFut.dummy() || (futQ.isEmpty() && !busy))
- futQ.offer(exchFut);
+ if (!exchFut.dummy() || (exchQ.empty() && !busy))
+ exchQ.addExchange(null, null, exchFut);
if (log.isDebugEnabled())
log.debug("Added exchange future to exchange worker: " + exchFut);
@@ -1251,16 +1646,16 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
}
// If not first preloading and no more topology events present.
- if (!cctx.kernalContext().clientNode() && futQ.isEmpty() && preloadFinished)
+ if (!cctx.kernalContext().clientNode() && exchQ.empty() && preloadFinished)
timeout = cctx.gridConfig().getNetworkTimeout();
// After workers line up and before preloading starts we initialize all futures.
- if (log.isDebugEnabled())
- log.debug("Before waiting for exchange futures [futs" +
- F.view(exchFuts.values(), F.unfinishedFutures()) + ", worker=" + this + ']');
+// if (log.isDebugEnabled())
+// log.debug("Before waiting for exchange futures [futs" +
+// F.view(exchFuts.values(), F.unfinishedFutures()) + ", worker=" + this + ']');
// Take next exchange future.
- exchFut = poll(futQ, timeout, this);
+ exchFut = exchQ.poll(timeout);
if (exchFut == null)
continue; // Main while loop.
@@ -1314,7 +1709,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
startEvtFired = true;
- if (!cctx.kernalContext().clientNode() && changed && futQ.isEmpty())
+ if (!cctx.kernalContext().clientNode() && changed && exchQ.empty())
refreshPartitions();
}
else {
@@ -1407,7 +1802,7 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
rebalanceQ.addAll(orderedRs);
if (marshR != null || !rebalanceQ.isEmpty()) {
- if (futQ.isEmpty()) {
+ if (exchQ.empty()) {
U.log(log, "Rebalancing required" +
"[top=" + exchFut.topologyVersion() + ", evt=" + exchFut.discoveryEvent().name() +
", node=" + exchFut.discoveryEvent().eventNode().id() + ']');
[25/50] [abbrv] ignite git commit: IGNITE-2836: IGFS: Ensured that
metadata can be serialized through BinaryMarshaller in the most efficient
way.
Posted by sb...@apache.org.
IGNITE-2836: IGFS: Ensured that metadata can be serialized through BinaryMarshaller in the most efficient way.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2cd0dcb3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2cd0dcb3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2cd0dcb3
Branch: refs/heads/ignite-1837
Commit: 2cd0dcb37ce43a4cb07885ddfb2e72392fc814a7
Parents: 9a4b5bd
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Mar 21 10:29:20 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:49 2016 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/igfs/IgfsPath.java | 23 ++++++++++-
.../ignite/internal/binary/BinaryContext.java | 43 ++++++++++++++++++++
.../ignite/internal/binary/BinaryUtils.java | 37 +++++++++++++++++
.../processors/igfs/IgfsDirectoryInfo.java | 27 +++++++++++-
.../internal/processors/igfs/IgfsEntryInfo.java | 35 ++++++++++++++++
.../processors/igfs/IgfsFileAffinityRange.java | 32 +++++++++++++--
.../internal/processors/igfs/IgfsFileInfo.java | 37 ++++++++++++++++-
.../internal/processors/igfs/IgfsFileMap.java | 41 +++++++++++++++++--
.../processors/igfs/IgfsListingEntry.java | 25 +++++++++++-
.../meta/IgfsMetaDirectoryCreateProcessor.java | 38 ++++++++++++++++-
.../IgfsMetaDirectoryListingAddProcessor.java | 24 ++++++++++-
...IgfsMetaDirectoryListingRemoveProcessor.java | 32 ++++++++++++++-
...gfsMetaDirectoryListingReplaceProcessor.java | 31 +++++++++++++-
.../igfs/meta/IgfsMetaFileCreateProcessor.java | 39 +++++++++++++++++-
.../igfs/meta/IgfsMetaFileLockProcessor.java | 29 ++++++++++++-
.../meta/IgfsMetaFileRangeDeleteProcessor.java | 22 +++++++++-
.../meta/IgfsMetaFileRangeUpdateProcessor.java | 24 ++++++++++-
.../meta/IgfsMetaFileReserveSpaceProcessor.java | 32 ++++++++++++++-
.../igfs/meta/IgfsMetaFileUnlockProcessor.java | 28 ++++++++++++-
.../igfs/meta/IgfsMetaUpdatePathProcessor.java | 23 ++++++++++-
.../meta/IgfsMetaUpdatePropertiesProcessor.java | 28 ++++++++++++-
.../igfs/meta/IgfsMetaUpdateTimesProcessor.java | 30 +++++++++++++-
22 files changed, 653 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java
index bbb4efb..f1ceb2e 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java
@@ -25,6 +25,13 @@ import java.net.URI;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.util.io.GridFilenameUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.A;
@@ -42,7 +49,7 @@ import org.jetbrains.annotations.Nullable;
* IgfsFile file = igfs.info(filePath);
* </pre>
*/
-public final class IgfsPath implements Comparable<IgfsPath>, Externalizable {
+public final class IgfsPath implements Comparable<IgfsPath>, Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -260,6 +267,20 @@ public final class IgfsPath implements Comparable<IgfsPath>, Externalizable {
}
/** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeString(path);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ path = in.readString();
+ }
+
+ /** {@inheritDoc} */
@Override public int hashCode() {
return path.hashCode();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/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 b9b633f..c9ad1e9 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
@@ -60,10 +60,29 @@ import org.apache.ignite.cache.affinity.AffinityKey;
import org.apache.ignite.cache.affinity.AffinityKeyMapped;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.cache.binary.BinaryMetadataKey;
import org.apache.ignite.internal.processors.closure.GridClosureProcessor;
import org.apache.ignite.internal.processors.datastructures.CollocatedQueueItemKey;
import org.apache.ignite.internal.processors.datastructures.CollocatedSetItemKey;
+import org.apache.ignite.internal.processors.igfs.IgfsDirectoryInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange;
+import org.apache.ignite.internal.processors.igfs.IgfsFileInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsFileMap;
+import org.apache.ignite.internal.processors.igfs.IgfsListingEntry;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryCreateProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingAddProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingRemoveProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaDirectoryListingReplaceProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileCreateProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileLockProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileRangeDeleteProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileRangeUpdateProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileReserveSpaceProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaFileUnlockProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdatePathProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdatePropertiesProcessor;
+import org.apache.ignite.internal.processors.igfs.meta.IgfsMetaUpdateTimesProcessor;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.lang.GridMapEntry;
import org.apache.ignite.internal.util.typedef.F;
@@ -97,6 +116,30 @@ public class BinaryContext {
static {
Set<String> sysClss = new HashSet<>();
+ // IGFS classes.
+ sysClss.add(IgfsPath.class.getName());
+
+ sysClss.add(IgfsDirectoryInfo.class.getName());
+ sysClss.add(IgfsFileAffinityRange.class.getName());
+ sysClss.add(IgfsFileInfo.class.getName());
+ sysClss.add(IgfsFileMap.class.getName());
+ sysClss.add(IgfsListingEntry.class.getName());
+
+ sysClss.add(IgfsMetaDirectoryCreateProcessor.class.getName());
+ sysClss.add(IgfsMetaDirectoryListingAddProcessor.class.getName());
+ sysClss.add(IgfsMetaDirectoryListingRemoveProcessor.class.getName());
+ sysClss.add(IgfsMetaDirectoryListingReplaceProcessor.class.getName());
+ sysClss.add(IgfsMetaFileCreateProcessor.class.getName());
+ sysClss.add(IgfsMetaFileLockProcessor.class.getName());
+ sysClss.add(IgfsMetaFileRangeDeleteProcessor.class.getName());
+ sysClss.add(IgfsMetaFileRangeUpdateProcessor.class.getName());
+ sysClss.add(IgfsMetaFileReserveSpaceProcessor.class.getName());
+ sysClss.add(IgfsMetaFileUnlockProcessor.class.getName());
+ sysClss.add(IgfsMetaUpdatePathProcessor.class.getName());
+ sysClss.add(IgfsMetaUpdatePropertiesProcessor.class.getName());
+ sysClss.add(IgfsMetaUpdateTimesProcessor.class.getName());
+
+ // Closure processor classes.
sysClss.add(GridClosureProcessor.C1V2.class.getName());
sysClss.add(GridClosureProcessor.C1MLAV2.class.getName());
sysClss.add(GridClosureProcessor.C2V2.class.getName());
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index eefdc3f..37f1d6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -51,12 +51,15 @@ import org.apache.ignite.binary.BinaryInvalidTypeException;
import org.apache.ignite.binary.BinaryMapFactory;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.binary.builder.BinaryLazyValue;
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
@@ -1976,6 +1979,40 @@ public class BinaryUtils {
}
/**
+ * Write {@code IgniteUuid} instance.
+ *
+ * @param out Writer.
+ * @param val Value.
+ */
+ public static void writeIgniteUuid(BinaryRawWriter out, @Nullable IgniteUuid val) {
+ if (val != null) {
+ out.writeBoolean(true);
+
+ out.writeLong(val.globalId().getMostSignificantBits());
+ out.writeLong(val.globalId().getLeastSignificantBits());
+ out.writeLong(val.localId());
+ }
+ else
+ out.writeBoolean(false);
+ }
+
+ /**
+ * Read {@code IgniteUuid} instance.
+ *
+ * @param in Reader.
+ * @return Value.
+ */
+ @Nullable public static IgniteUuid readIgniteUuid(BinaryRawReader in) {
+ if (in.readBoolean()) {
+ UUID globalId = new UUID(in.readLong(), in.readLong());
+
+ return new IgniteUuid(globalId, in.readLong());
+ }
+ else
+ return null;
+ }
+
+ /**
* Enum type.
*/
private static class EnumType {
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
index 01c8ff9..233c8ee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
@@ -17,6 +17,13 @@
package org.apache.ignite.internal.processors.igfs;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -33,7 +40,7 @@ import java.util.Map;
/**
* IGFS directory info.
*/
-public class IgfsDirectoryInfo extends IgfsEntryInfo {
+public class IgfsDirectoryInfo extends IgfsEntryInfo implements Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -186,6 +193,24 @@ public class IgfsDirectoryInfo extends IgfsEntryInfo {
}
/** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ writeBinary(out);
+
+ out.writeMap(listing);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ readBinary(in);
+
+ listing = in.readMap();
+ }
+
+ /** {@inheritDoc} */
@Override public int hashCode() {
return id.hashCode() ^ (props == null ? 0 : props.hashCode());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
index c5b1111..d31ef72 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
@@ -17,7 +17,11 @@
package org.apache.ignite.internal.processors.igfs;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
@@ -302,4 +306,35 @@ public abstract class IgfsEntryInfo implements Externalizable {
modificationTime = in.readLong();
path = (IgfsPath)in.readObject();
}
+
+ /**
+ * Write binary content.
+ *
+ * @param out Writer.
+ */
+ protected void writeBinary(BinaryRawWriter out) {
+ BinaryUtils.writeIgniteUuid(out, id);
+ out.writeMap(props);
+ out.writeLong(accessTime);
+ out.writeLong(modificationTime);
+ out.writeObject(path);
+ }
+
+ /**
+ * Read binary content.
+ *
+ * @param in Reader.
+ */
+ protected void readBinary(BinaryRawReader in) {
+ id = BinaryUtils.readIgniteUuid(in);
+ props = in.readMap();
+ accessTime = in.readLong();
+ modificationTime = in.readLong();
+ path = in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsEntryInfo.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
index 9ac914f..953461c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileAffinityRange.java
@@ -25,6 +25,14 @@ import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -37,7 +45,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Affinity range.
*/
-public class IgfsFileAffinityRange implements Message, Externalizable {
+public class IgfsFileAffinityRange implements Message, Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -243,9 +251,7 @@ public class IgfsFileAffinityRange implements Message, Externalizable {
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
U.writeGridUuid(out, affKey);
-
out.writeInt(status);
-
out.writeLong(startOff);
out.writeLong(endOff);
}
@@ -253,9 +259,27 @@ public class IgfsFileAffinityRange implements Message, Externalizable {
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
affKey = U.readGridUuid(in);
-
status = in.readInt();
+ startOff = in.readLong();
+ endOff = in.readLong();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+ BinaryUtils.writeIgniteUuid(out, affKey);
+ out.writeInt(status);
+ out.writeLong(startOff);
+ out.writeLong(endOff);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ affKey = BinaryUtils.readIgniteUuid(in);
+ status = in.readInt();
startOff = in.readLong();
endOff = in.readLong();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
index 30f505e..337f281 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileInfo.java
@@ -17,6 +17,13 @@
package org.apache.ignite.internal.processors.igfs;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -33,7 +40,7 @@ import java.util.Map;
/**
* IGFS file info.
*/
-public final class IgfsFileInfo extends IgfsEntryInfo {
+public final class IgfsFileInfo extends IgfsEntryInfo implements Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -230,6 +237,34 @@ public final class IgfsFileInfo extends IgfsEntryInfo {
}
/** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ writeBinary(out);
+
+ out.writeInt(blockSize);
+ out.writeLong(len);
+ BinaryUtils.writeIgniteUuid(out, lockId);
+ BinaryUtils.writeIgniteUuid(out, affKey);
+ out.writeObject(fileMap);
+ out.writeBoolean(evictExclude);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ readBinary(in);
+
+ blockSize = in.readInt();
+ len = in.readLong();
+ lockId = BinaryUtils.readIgniteUuid(in);
+ affKey = BinaryUtils.readIgniteUuid(in);
+ fileMap = in.readObject();
+ evictExclude = in.readBoolean();
+ }
+
+ /** {@inheritDoc} */
@Override public int hashCode() {
return id.hashCode() ^ blockSize ^ (int)(len ^ (len >>> 32)) ^ (props == null ? 0 : props.hashCode()) ^
(lockId == null ? 0 : lockId.hashCode());
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java
index 9ea69ea..2890e2a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java
@@ -24,7 +24,12 @@ import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -36,12 +41,12 @@ import static org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange.R
/**
* Auxiliary class that is responsible for managing file affinity keys allocation by ranges.
*/
-public class IgfsFileMap implements Externalizable {
+public class IgfsFileMap implements Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
- @GridToStringInclude
/** Sorted list of ranges in ascending order. */
+ @GridToStringInclude
private List<IgfsFileAffinityRange> ranges;
/**
@@ -358,6 +363,36 @@ public class IgfsFileMap implements Externalizable {
}
/** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ if (ranges == null)
+ out.writeInt(-1);
+ else {
+ assert !ranges.isEmpty();
+
+ out.writeInt(ranges.size());
+
+ for (IgfsFileAffinityRange range : ranges)
+ out.writeObject(range);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ int size = in.readInt();
+
+ if (size > 0) {
+ ranges = new ArrayList<>(size);
+
+ for (int i = 0; i < size; i++)
+ ranges.add((IgfsFileAffinityRange)in.readObject());
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsFileMap.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
index ea05ca3..2401656 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsListingEntry.java
@@ -17,6 +17,13 @@
package org.apache.ignite.internal.processors.igfs;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -30,7 +37,7 @@ import java.io.ObjectOutput;
/**
* Directory listing entry.
*/
-public class IgfsListingEntry implements Externalizable {
+public class IgfsListingEntry implements Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -102,6 +109,22 @@ public class IgfsListingEntry implements Externalizable {
}
/** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ BinaryUtils.writeIgniteUuid(out, id);
+ out.writeBoolean(dir);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ id = BinaryUtils.readIgniteUuid(in);
+ dir = in.readBoolean();
+ }
+
+ /** {@inheritDoc} */
@Override public boolean equals(Object other) {
return this == other || other instanceof IgfsListingEntry && F.eq(id, ((IgfsListingEntry)other).id);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
index ffba042..ded66bf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
@@ -1,8 +1,15 @@
package org.apache.ignite.internal.processors.igfs.meta;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsListingEntry;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -20,7 +27,7 @@ import java.util.Map;
* Directory create processor.
*/
public class IgfsMetaDirectoryCreateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -114,4 +121,33 @@ public class IgfsMetaDirectoryCreateProcessor implements EntryProcessor<IgniteUu
childEntry = (IgfsListingEntry)in.readObject();
}
}
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeLong(createTime);
+ out.writeMap(props);
+ out.writeString(childName);
+
+ if (childName != null)
+ out.writeObject(childEntry);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ createTime = in.readLong();
+ props = in.readMap();
+ childName = in.readString();
+
+ if (childName != null)
+ childEntry = in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaDirectoryCreateProcessor.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
index ab5cd5d..d45dea1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
@@ -1,6 +1,12 @@
package org.apache.ignite.internal.processors.igfs.meta;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsListingEntry;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -20,7 +26,7 @@ import java.util.Map;
* Update directory listing closure.
*/
public final class IgfsMetaDirectoryListingAddProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -86,6 +92,22 @@ public final class IgfsMetaDirectoryListingAddProcessor implements EntryProcesso
}
/** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeString(fileName);
+ out.writeObject(entry);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ fileName = in.readString();
+ entry = in.readObject();
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsMetaDirectoryListingAddProcessor.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java
index 181a73e..d5da117 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java
@@ -1,9 +1,16 @@
package org.apache.ignite.internal.processors.igfs.meta;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsListingEntry;
-import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -21,7 +28,7 @@ import java.util.Map;
* Remove entry from directory listing.
*/
public class IgfsMetaDirectoryListingRemoveProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -86,4 +93,25 @@ public class IgfsMetaDirectoryListingRemoveProcessor implements EntryProcessor<I
fileName = U.readString(in);
fileId = U.readGridUuid(in);
}
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeString(fileName);
+ BinaryUtils.writeIgniteUuid(out, fileId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ fileName = in.readString();
+ fileId = BinaryUtils.readIgniteUuid(in);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaDirectoryListingRemoveProcessor.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
index 4c4888c..bf3c288 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
@@ -1,8 +1,16 @@
package org.apache.ignite.internal.processors.igfs.meta;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsListingEntry;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -20,7 +28,7 @@ import java.util.Map;
* Listing replace processor.
*/
public final class IgfsMetaDirectoryListingReplaceProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -81,4 +89,25 @@ public final class IgfsMetaDirectoryListingReplaceProcessor implements EntryProc
name = U.readString(in);
id = (IgniteUuid)in.readObject();
}
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeString(name);
+ BinaryUtils.writeIgniteUuid(out, id);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ name = in.readString();
+ id = BinaryUtils.readIgniteUuid(in);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaDirectoryListingReplaceProcessor.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
index a07d764..418227a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
@@ -1,7 +1,15 @@
package org.apache.ignite.internal.processors.igfs.meta;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
@@ -19,7 +27,7 @@ import java.util.Map;
* File create processor.
*/
public class IgfsMetaFileCreateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -107,4 +115,33 @@ public class IgfsMetaFileCreateProcessor implements EntryProcessor<IgniteUuid, I
lockId = (IgniteUuid)in.readObject();
evictExclude = in.readBoolean();
}
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeLong(createTime);
+ out.writeMap(props);
+ out.writeInt(blockSize);
+ BinaryUtils.writeIgniteUuid(out, affKey);
+ BinaryUtils.writeIgniteUuid(out, lockId);
+ out.writeBoolean(evictExclude);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ createTime = in.readLong();
+ props = in.readMap();
+ blockSize = in.readInt();
+ affKey = BinaryUtils.readIgniteUuid(in);
+ lockId = BinaryUtils.readIgniteUuid(in);
+ evictExclude = in.readBoolean();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaFileCreateProcessor.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java
index 43a5d7d..ff71f13 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java
@@ -1,6 +1,14 @@
package org.apache.ignite.internal.processors.igfs.meta;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -16,7 +24,7 @@ import java.io.ObjectOutput;
* File lock entry processor.
*/
public class IgfsMetaFileLockProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -60,4 +68,23 @@ public class IgfsMetaFileLockProcessor implements EntryProcessor<IgniteUuid, Igf
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
lockId = U.readGridUuid(in);
}
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ BinaryUtils.writeIgniteUuid(out, lockId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ lockId = BinaryUtils.readIgniteUuid(in);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaFileLockProcessor.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java
index 5af09e5..cdf07d1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java
@@ -1,5 +1,11 @@
package org.apache.ignite.internal.processors.igfs.meta;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange;
import org.apache.ignite.internal.processors.igfs.IgfsFileMap;
@@ -18,7 +24,7 @@ import java.io.ObjectOutput;
* Delete range processor.
*/
public class IgfsMetaFileRangeDeleteProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -68,6 +74,20 @@ public class IgfsMetaFileRangeDeleteProcessor implements EntryProcessor<IgniteUu
}
/** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeObject(range);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ range = in.readObject();
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsMetaFileRangeDeleteProcessor.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java
index ae886c8..e1224de 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java
@@ -1,5 +1,11 @@
package org.apache.ignite.internal.processors.igfs.meta;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange;
import org.apache.ignite.internal.processors.igfs.IgfsFileMap;
@@ -18,7 +24,7 @@ import java.io.ObjectOutput;
* Update range processor.
*/
public class IgfsMetaFileRangeUpdateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -75,6 +81,22 @@ public class IgfsMetaFileRangeUpdateProcessor implements EntryProcessor<IgniteUu
}
/** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeObject(range);
+ out.writeInt(status);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ range = in.readObject();
+ status = in.readInt();
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsMetaFileRangeUpdateProcessor.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java
index 30f8e22..a54ddcc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java
@@ -1,8 +1,15 @@
package org.apache.ignite.internal.processors.igfs.meta;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange;
import org.apache.ignite.internal.processors.igfs.IgfsFileMap;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.lang.IgniteUuid;
import javax.cache.processor.EntryProcessor;
@@ -17,7 +24,7 @@ import java.io.ObjectOutput;
* File reserve space entry processor.
*/
public class IgfsMetaFileReserveSpaceProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -38,7 +45,7 @@ public class IgfsMetaFileReserveSpaceProcessor implements EntryProcessor<IgniteU
* Constructor.
*
* @param space Space.
- * @param affRange
+ * @param affRange Affinity range.
*/
public IgfsMetaFileReserveSpaceProcessor(long space, IgfsFileAffinityRange affRange) {
this.space = space;
@@ -72,4 +79,25 @@ public class IgfsMetaFileReserveSpaceProcessor implements EntryProcessor<IgniteU
space = in.readLong();
affRange = (IgfsFileAffinityRange)in.readObject();
}
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeLong(space);
+ out.writeObject(affRange);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ space = in.readLong();
+ affRange = in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaFileReserveSpaceProcessor.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java
index d535a1d..0d06c92 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java
@@ -1,6 +1,13 @@
package org.apache.ignite.internal.processors.igfs.meta;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.lang.IgniteUuid;
import javax.cache.processor.EntryProcessor;
@@ -15,7 +22,7 @@ import java.io.ObjectOutput;
* File unlock entry processor.
*/
public class IgfsMetaFileUnlockProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -57,4 +64,23 @@ public class IgfsMetaFileUnlockProcessor implements EntryProcessor<IgniteUuid, I
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
modificationTime = in.readLong();
}
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeLong(modificationTime);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ modificationTime = in.readLong();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaFileUnlockProcessor.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
index 32e5512..81c1806 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
@@ -1,8 +1,13 @@
package org.apache.ignite.internal.processors.igfs.meta;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
-import org.apache.ignite.internal.processors.igfs.IgfsMetaManager;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.lang.IgniteUuid;
@@ -17,7 +22,7 @@ import java.io.ObjectOutput;
* Update path closure.
*/
public final class IgfsMetaUpdatePathProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -60,6 +65,20 @@ public final class IgfsMetaUpdatePathProcessor implements EntryProcessor<IgniteU
}
/** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeObject(path);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ path = in.readObject();
+ }
+
+ /** {@inheritDoc} */
@Override public String toString() {
return S.toString(IgfsMetaUpdatePathProcessor.class, this);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
index a97c186..a9751c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
@@ -1,7 +1,14 @@
package org.apache.ignite.internal.processors.igfs.meta;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.util.GridLeanMap;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -18,7 +25,7 @@ import java.util.Map;
* Update properties processor.
*/
public class IgfsMetaUpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -75,4 +82,23 @@ public class IgfsMetaUpdatePropertiesProcessor implements EntryProcessor<IgniteU
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
props = U.readStringMap(in);
}
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeMap(props);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ props = in.readMap();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaUpdatePropertiesProcessor.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2cd0dcb3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java
index 8acd289..b754f19 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java
@@ -1,6 +1,13 @@
package org.apache.ignite.internal.processors.igfs.meta;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.lang.IgniteUuid;
import javax.cache.processor.EntryProcessor;
@@ -15,7 +22,7 @@ import java.io.ObjectOutput;
* Update times entry processor.
*/
public class IgfsMetaUpdateTimesProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
- Externalizable {
+ Externalizable, Binarylizable {
/** */
private static final long serialVersionUID = 0L;
@@ -65,4 +72,25 @@ public class IgfsMetaUpdateTimesProcessor implements EntryProcessor<IgniteUuid,
accessTime = in.readLong();
modificationTime = in.readLong();
}
+
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ out.writeLong(accessTime);
+ out.writeLong(modificationTime);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ accessTime = in.readLong();
+ modificationTime = in.readLong();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaUpdateTimesProcessor.class, this);
+ }
}
[33/50] [abbrv] ignite git commit: IGNITE-2878: IGFS: Optimzied
serialization of IgfsListingEntry and properties map.
Posted by sb...@apache.org.
IGNITE-2878: IGFS: Optimzied serialization of IgfsListingEntry and properties map.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/00a0e4b5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/00a0e4b5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/00a0e4b5
Branch: refs/heads/ignite-1837
Commit: 00a0e4b51c299871ff690bbe6d462cf80dae045e
Parents: 26f1157
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Mar 24 10:35:43 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:14:24 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/binary/BinaryContext.java | 2 +
.../internal/processors/igfs/IgfsBlockKey.java | 30 ++++-
.../processors/igfs/IgfsDirectoryInfo.java | 33 ++++-
.../internal/processors/igfs/IgfsEntryInfo.java | 8 +-
.../internal/processors/igfs/IgfsUtils.java | 127 +++++++++++++++++++
.../meta/IgfsMetaDirectoryCreateProcessor.java | 24 ++--
.../IgfsMetaDirectoryListingAddProcessor.java | 6 +-
...gfsMetaDirectoryListingReplaceProcessor.java | 4 +-
.../igfs/meta/IgfsMetaFileCreateProcessor.java | 16 ++-
.../meta/IgfsMetaUpdatePropertiesProcessor.java | 5 +-
.../processors/igfs/IgfsAbstractSelfTest.java | 11 ++
.../IgfsPrimaryOptimziedMarshallerSelfTest.java | 28 ++++
.../ignite/testsuites/IgniteIgfsTestSuite.java | 2 +
13 files changed, 261 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/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 b357345..4d8c293 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
@@ -65,6 +65,7 @@ import org.apache.ignite.internal.processors.cache.binary.BinaryMetadataKey;
import org.apache.ignite.internal.processors.closure.GridClosureProcessor;
import org.apache.ignite.internal.processors.datastructures.CollocatedQueueItemKey;
import org.apache.ignite.internal.processors.datastructures.CollocatedSetItemKey;
+import org.apache.ignite.internal.processors.igfs.IgfsBlockKey;
import org.apache.ignite.internal.processors.igfs.IgfsDirectoryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange;
import org.apache.ignite.internal.processors.igfs.IgfsFileInfo;
@@ -118,6 +119,7 @@ public class BinaryContext {
// IGFS classes.
sysClss.add(IgfsPath.class.getName());
+ sysClss.add(IgfsBlockKey.class.getName());
sysClss.add(IgfsDirectoryInfo.class.getName());
sysClss.add(IgfsFileAffinityRange.class.getName());
sysClss.add(IgfsFileInfo.class.getName());
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java
index 06a2e1c..c366ae3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsBlockKey.java
@@ -22,6 +22,14 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.nio.ByteBuffer;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.processors.task.GridInternal;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -37,7 +45,7 @@ import org.jetbrains.annotations.Nullable;
* File's binary data block key.
*/
@GridInternal
-public final class IgfsBlockKey implements Message, Externalizable, Comparable<IgfsBlockKey> {
+public final class IgfsBlockKey implements Message, Externalizable, Binarylizable, Comparable<IgfsBlockKey> {
/** */
private static final long serialVersionUID = 0L;
@@ -150,6 +158,26 @@ public final class IgfsBlockKey implements Message, Externalizable, Comparable<I
}
/** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ BinaryRawWriter out = writer.rawWriter();
+
+ BinaryUtils.writeIgniteUuid(out, fileId);
+ BinaryUtils.writeIgniteUuid(out, affKey);
+ out.writeBoolean(evictExclude);
+ out.writeLong(blockId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ BinaryRawReader in = reader.rawReader();
+
+ fileId = BinaryUtils.readIgniteUuid(in);
+ affKey = BinaryUtils.readIgniteUuid(in);
+ evictExclude = in.readBoolean();
+ blockId = in.readLong();
+ }
+
+ /** {@inheritDoc} */
@Override public int hashCode() {
return fileId.hashCode() + (int)(blockId ^ (blockId >>> 32));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
index a426e8c..269098b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDirectoryInfo.java
@@ -26,6 +26,7 @@ import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
@@ -181,7 +182,19 @@ public class IgfsDirectoryInfo extends IgfsEntryInfo implements Binarylizable {
@Override public void writeExternal(ObjectOutput out) throws IOException {
super.writeExternal(out);
- out.writeObject(listing);
+ if (listing != null) {
+ out.writeBoolean(true);
+
+ out.writeInt(listing.size());
+
+ for (Map.Entry<String, IgfsListingEntry> entry : listing.entrySet()) {
+ U.writeString(out, entry.getKey());
+
+ IgfsUtils.writeListingEntry(out, entry.getValue());
+ }
+ }
+ else
+ out.writeBoolean(false);
}
/** {@inheritDoc} */
@@ -189,7 +202,19 @@ public class IgfsDirectoryInfo extends IgfsEntryInfo implements Binarylizable {
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
super.readExternal(in);
- listing = (Map<String, IgfsListingEntry>)in.readObject();
+ if (in.readBoolean()) {
+ int listingSize = in.readInt();
+
+ listing = new HashMap<>(listingSize);
+
+ for (int i = 0; i < listingSize; i++) {
+ String key = U.readString(in);
+
+ IgfsListingEntry val = IgfsUtils.readListingEntry(in);
+
+ listing.put(key, val);
+ }
+ }
}
/** {@inheritDoc} */
@@ -211,8 +236,6 @@ public class IgfsDirectoryInfo extends IgfsEntryInfo implements Binarylizable {
}
else
out.writeBoolean(false);
-
- out.writeMap(listing);
}
/** {@inheritDoc} */
@@ -234,8 +257,6 @@ public class IgfsDirectoryInfo extends IgfsEntryInfo implements Binarylizable {
listing.put(key, val);
}
}
-
- listing = in.readMap();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
index 9ff65da..4df8b34 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsEntryInfo.java
@@ -267,7 +267,9 @@ public abstract class IgfsEntryInfo implements Externalizable {
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
U.writeGridUuid(out, id);
- U.writeStringMap(out, props);
+
+ IgfsUtils.writeProperties(out, props);
+
out.writeLong(accessTime);
out.writeLong(modificationTime);
}
@@ -275,7 +277,9 @@ public abstract class IgfsEntryInfo implements Externalizable {
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
id = U.readGridUuid(in);
- props = U.readStringMap(in);
+
+ props = IgfsUtils.readProperties(in);
+
accessTime = in.readLong();
modificationTime = in.readLong();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index c6b7ad3..1b97565 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -36,6 +36,7 @@ import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException;
import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
import org.apache.ignite.internal.util.typedef.F;
@@ -45,6 +46,9 @@ import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.transactions.Transaction;
import org.jetbrains.annotations.Nullable;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Map;
@@ -471,6 +475,42 @@ public class IgfsUtils {
}
/**
+ * Write listing entry.
+ *
+ * @param out Writer.
+ * @param entry Entry.
+ * @throws IOException If failed.
+ */
+ public static void writeListingEntry(DataOutput out, @Nullable IgfsListingEntry entry) throws IOException {
+ if (entry != null) {
+ out.writeBoolean(true);
+
+ IgniteUtils.writeGridUuid(out, entry.fileId());
+
+ out.writeBoolean(entry.isDirectory());
+ }
+ else
+ out.writeBoolean(false);
+ }
+
+ /**
+ * Read listing entry.
+ *
+ * @param in Reader.
+ * @return Entry.
+ */
+ @Nullable public static IgfsListingEntry readListingEntry(DataInput in) throws IOException {
+ if (in.readBoolean()) {
+ IgniteUuid id = IgniteUtils.readGridUuid(in);
+ boolean dir = in.readBoolean();
+
+ return new IgfsListingEntry(id, dir);
+ }
+ else
+ return null;
+ }
+
+ /**
* Write entry properties. Rely on reference equality for well-known properties.
*
* @param out Writer.
@@ -554,4 +594,91 @@ public class IgfsUtils {
else
return null;
}
+
+ /**
+ * Write entry properties. Rely on reference equality for well-known properties.
+ *
+ * @param out Writer.
+ * @param props Properties.
+ * @throws IOException If failed.
+ */
+ @SuppressWarnings("StringEquality")
+ public static void writeProperties(DataOutput out, @Nullable Map<String, String> props) throws IOException {
+ if (props != null) {
+ out.writeInt(props.size());
+
+ for (Map.Entry<String, String> entry : props.entrySet()) {
+ String key = entry.getKey();
+
+ if (key == PROP_PERMISSION)
+ out.writeByte(PROP_PERMISSION_IDX);
+ else if (key == PROP_PREFER_LOCAL_WRITES)
+ out.writeByte(PROP_PREFER_LOCAL_WRITES_IDX);
+ else if (key == PROP_USER_NAME)
+ out.writeByte(PROP_USER_NAME_IDX);
+ else if (key == PROP_GROUP_NAME)
+ out.writeByte(PROP_GROUP_NAME_IDX);
+ else {
+ out.writeByte(PROP_IDX);
+ U.writeString(out, key);
+ }
+
+ U.writeString(out, entry.getValue());
+ }
+ }
+ else
+ out.writeInt(-1);
+ }
+
+ /**
+ * Read entry properties.
+ *
+ * @param in Reader.
+ * @return Properties.
+ * @throws IOException If failed.
+ */
+ @Nullable public static Map<String, String> readProperties(DataInput in) throws IOException {
+ int size = in.readInt();
+
+ if (size >= 0) {
+ Map<String, String> props = new HashMap<>(size);
+
+ for (int i = 0; i < size; i++) {
+ byte idx = in.readByte();
+
+ String key;
+
+ switch (idx) {
+ case PROP_PERMISSION_IDX:
+ key = PROP_PERMISSION;
+
+ break;
+
+ case PROP_PREFER_LOCAL_WRITES_IDX:
+ key = PROP_PREFER_LOCAL_WRITES;
+
+ break;
+
+ case PROP_USER_NAME_IDX:
+ key = PROP_USER_NAME;
+
+ break;
+
+ case PROP_GROUP_NAME_IDX:
+ key = PROP_GROUP_NAME;
+
+ break;
+
+ default:
+ key = U.readString(in);
+ }
+
+ props.put(key, U.readString(in));
+ }
+
+ return props;
+ }
+ else
+ return null;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
index 5f4fe73..eee9300 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
@@ -116,27 +116,25 @@ public class IgfsMetaDirectoryCreateProcessor implements EntryProcessor<IgniteUu
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
out.writeLong(createTime);
- U.writeStringMap(out, props);
- if (childName != null) {
- out.writeBoolean(true);
+ IgfsUtils.writeProperties(out, props);
+
+ U.writeString(out, childName);
- U.writeString(out, childName);
- out.writeObject(childEntry);
- }
- else
- out.writeBoolean(false);
+ if (childName != null)
+ IgfsUtils.writeListingEntry(out, childEntry);
}
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
createTime = in.readLong();
- props = U.readStringMap(in);
- if (in.readBoolean()) {
- childName = U.readString(in);
- childEntry = (IgfsListingEntry)in.readObject();
- }
+ props = IgfsUtils.readProperties(in);
+
+ childName = U.readString(in);
+
+ if (childName != null)
+ childEntry = IgfsUtils.readListingEntry(in);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
index e9fa867..380d997 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
@@ -100,13 +100,15 @@ public final class IgfsMetaDirectoryListingAddProcessor implements EntryProcesso
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
U.writeString(out, fileName);
- out.writeObject(entry);
+
+ IgfsUtils.writeListingEntry(out, entry);
}
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
fileName = U.readString(in);
- entry = (IgfsListingEntry)in.readObject();
+
+ entry = IgfsUtils.readListingEntry(in);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
index dfc9bfc..e230f05 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
@@ -98,13 +98,13 @@ public final class IgfsMetaDirectoryListingReplaceProcessor implements EntryProc
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
U.writeString(out, name);
- out.writeObject(id);
+ U.writeGridUuid(out, id);
}
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
name = U.readString(in);
- id = (IgniteUuid)in.readObject();
+ id = U.readGridUuid(in);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
index 9fd16aa..8c4c296 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
@@ -116,20 +116,24 @@ public class IgfsMetaFileCreateProcessor implements EntryProcessor<IgniteUuid, I
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
out.writeLong(createTime);
- U.writeStringMap(out, props);
+
+ IgfsUtils.writeProperties(out, props);
+
out.writeInt(blockSize);
- out.writeObject(affKey);
- out.writeObject(lockId);
+ U.writeGridUuid(out, affKey);
+ U.writeGridUuid(out, lockId);
out.writeBoolean(evictExclude);
}
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
createTime = in.readLong();
- props = U.readStringMap(in);
+
+ props = IgfsUtils.readProperties(in);
+
blockSize = in.readInt();
- affKey = (IgniteUuid)in.readObject();
- lockId = (IgniteUuid)in.readObject();
+ affKey = U.readGridUuid(in);
+ lockId = U.readGridUuid(in);
evictExclude = in.readBoolean();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
index e0d5b8b..af79332 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
@@ -27,7 +27,6 @@ import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsUtils;
import org.apache.ignite.internal.util.GridLeanMap;
import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import javax.cache.processor.EntryProcessor;
@@ -93,12 +92,12 @@ public class IgfsMetaUpdatePropertiesProcessor implements EntryProcessor<IgniteU
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeStringMap(out, props);
+ IgfsUtils.writeProperties(out, props);
}
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- props = U.readStringMap(in);
+ props = IgfsUtils.readProperties(in);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
index ec3878c..2f6c7bf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
@@ -53,6 +53,7 @@ import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
@@ -232,6 +233,13 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
}
/**
+ * @return Use optimzied marshaller flag.
+ */
+ protected boolean useOptimizedMarshaller() {
+ return false;
+ }
+
+ /**
* Data chunk.
*
* @param len Length.
@@ -332,6 +340,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
IgniteConfiguration cfg = new IgniteConfiguration();
+ if (useOptimizedMarshaller())
+ cfg.setMarshaller(new OptimizedMarshaller());
+
cfg.setGridName(gridName);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryOptimziedMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryOptimziedMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryOptimziedMarshallerSelfTest.java
new file mode 100644
index 0000000..e4ad1f4
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryOptimziedMarshallerSelfTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+/**
+ * Tests for PRIMARY mode with optimized marshaller.
+ */
+public class IgfsPrimaryOptimziedMarshallerSelfTest extends IgfsPrimarySelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean useOptimizedMarshaller() {
+ return true;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/00a0e4b5/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
index 038cb54..aff3ad7 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
@@ -40,6 +40,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsModesSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsOneClientNodeTest;
import org.apache.ignite.internal.processors.igfs.IgfsPrimaryOffheapTieredSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsPrimaryOffheapValuesSelfTest;
+import org.apache.ignite.internal.processors.igfs.IgfsPrimaryOptimziedMarshallerSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsPrimaryRelaxedSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsPrimarySelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsProcessorSelfTest;
@@ -69,6 +70,7 @@ public class IgniteIgfsTestSuite extends TestSuite {
suite.addTest(new TestSuite(IgfsPrimarySelfTest.class));
suite.addTest(new TestSuite(IgfsPrimaryRelaxedSelfTest.class));
+ suite.addTest(new TestSuite(IgfsPrimaryOptimziedMarshallerSelfTest.class));
suite.addTest(new TestSuite(IgfsPrimaryOffheapTieredSelfTest.class));
suite.addTest(new TestSuite(IgfsPrimaryOffheapValuesSelfTest.class));
suite.addTest(new TestSuite(IgfsDualSyncSelfTest.class));
[15/50] [abbrv] ignite git commit: IGNITE-2846: IGFS: Reworked
IgfsMetaManager.updateInfo() operation to use "invoke" instead of "put".
Posted by sb...@apache.org.
IGNITE-2846: IGFS: Reworked IgfsMetaManager.updateInfo() operation to use "invoke" instead of "put".
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f57f3657
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f57f3657
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f57f3657
Branch: refs/heads/ignite-1837
Commit: f57f3657b1da33abf28f885cd405780dabfd57e3
Parents: 3e59321
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Mar 16 13:22:07 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:24 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsFileMap.java | 9 +-
.../igfs/IgfsFragmentizerManager.java | 166 ++++++++++++++-----
.../igfs/IgfsInvalidRangeException.java | 4 +-
.../processors/igfs/IgfsMetaManager.java | 67 ++++----
.../igfs/IgfsMetaManagerSelfTest.java | 11 --
5 files changed, 161 insertions(+), 96 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f57f3657/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java
index 2c0358b..9ea69ea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFileMap.java
@@ -128,12 +128,11 @@ public class IgfsFileMap implements Externalizable {
*
* @param range Range to update status.
* @param status New range status.
- * @throws IgniteCheckedException If range was not found.
*/
- public void updateRangeStatus(IgfsFileAffinityRange range, int status) throws IgniteCheckedException {
+ public void updateRangeStatus(IgfsFileAffinityRange range, int status) {
if (ranges == null)
throw new IgfsInvalidRangeException("Failed to update range status (file map is empty) " +
- "[range=" + range + ", ranges=" + ranges + ']');
+ "[range=" + range + ", ranges=null]");
assert !ranges.isEmpty();
@@ -190,10 +189,10 @@ public class IgfsFileMap implements Externalizable {
*
* @param range Range to delete.
*/
- public void deleteRange(IgfsFileAffinityRange range) throws IgniteCheckedException {
+ public void deleteRange(IgfsFileAffinityRange range) {
if (ranges == null)
throw new IgfsInvalidRangeException("Failed to remove range (file map is empty) " +
- "[range=" + range + ", ranges=" + ranges + ']');
+ "[range=" + range + ", ranges=null]");
assert !ranges.isEmpty();
http://git-wip-us.apache.org/repos/asf/ignite/blob/f57f3657/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
index 899730d..7cc5cb6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsFragmentizerManager.java
@@ -17,6 +17,10 @@
package org.apache.ignite.internal.processors.igfs;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
@@ -41,19 +45,22 @@ import org.apache.ignite.internal.managers.communication.GridMessageListener;
import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.GridSpinReadWriteLock;
-import org.apache.ignite.internal.util.typedef.CX1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.P1;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.LT;
+import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.util.worker.GridWorker;
import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.thread.IgniteThread;
import org.jetbrains.annotations.Nullable;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
@@ -286,7 +293,8 @@ public class IgfsFragmentizerManager extends IgfsManager {
switch (range.status()) {
case RANGE_STATUS_INITIAL: {
// Mark range as moving.
- updated = igfsCtx.meta().updateInfo(fileId, updateRange(range, RANGE_STATUS_MOVING));
+ updated = igfsCtx.meta().updateInfo(
+ fileId, new RangeUpdateProcessor(range, RANGE_STATUS_MOVING));
if (updated == null) {
igfsCtx.data().cleanBlocks(fileInfo, range, true);
@@ -302,7 +310,8 @@ public class IgfsFragmentizerManager extends IgfsManager {
igfsCtx.data().spreadBlocks(fileInfo, range);
// Mark range as moved.
- updated = igfsCtx.meta().updateInfo(fileId, updateRange(range, RANGE_STATUS_MOVED));
+ updated = igfsCtx.meta().updateInfo(
+ fileId, new RangeUpdateProcessor(range, RANGE_STATUS_MOVED));
if (updated == null) {
igfsCtx.data().cleanBlocks(fileInfo, range, true);
@@ -318,7 +327,7 @@ public class IgfsFragmentizerManager extends IgfsManager {
igfsCtx.data().cleanBlocks(fileInfo, range, false);
// Remove range from map.
- updated = igfsCtx.meta().updateInfo(fileId, deleteRange(range));
+ updated = igfsCtx.meta().updateInfo(fileId, new RangeDeleteProcessor(range));
if (updated == null)
igfsCtx.data().cleanBlocks(fileInfo, range, true);
@@ -334,57 +343,132 @@ public class IgfsFragmentizerManager extends IgfsManager {
}
/**
- * Creates update info closure that will mark given range as moving.
- *
- * @param range Range to mark as moving.
- * @param status Status.
- * @return Update closure.
+ * Update range processor.
*/
- private IgniteClosure<IgfsFileInfo, IgfsFileInfo> updateRange(final IgfsFileAffinityRange range,
- final int status) {
- return new CX1<IgfsFileInfo, IgfsFileInfo>() {
- @Override public IgfsFileInfo applyx(IgfsFileInfo info) throws IgniteCheckedException {
- IgfsFileMap map = new IgfsFileMap(info.fileMap());
+ private static class RangeUpdateProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
- map.updateRangeStatus(range, status);
+ /** Range. */
+ private IgfsFileAffinityRange range;
- if (log.isDebugEnabled())
- log.debug("Updated file map for range [fileId=" + info.id() + ", range=" + range +
- ", status=" + status + ", oldMap=" + info.fileMap() + ", newMap=" + map + ']');
+ /** Status. */
+ private int status;
- IgfsFileInfo updated = new IgfsFileInfo(info, info.length());
+ /**
+ * Constructor.
+ */
+ public RangeUpdateProcessor() {
+ // No-op.
+ }
- updated.fileMap(map);
+ /**
+ * Constructor.
+ *
+ * @param range Range.
+ * @param status Status.
+ */
+ public RangeUpdateProcessor(IgfsFileAffinityRange range, int status) {
+ this.range = range;
+ this.status = status;
+ }
- return updated;
- }
- };
+ /** {@inheritDoc} */
+ @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsFileInfo oldInfo = entry.getValue();
+
+ IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
+
+ newMap.updateRangeStatus(range, status);
+
+ IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, oldInfo.length());
+
+ newInfo.fileMap(newMap);
+
+ entry.setValue(newInfo);
+
+ return newInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(range);
+ out.writeInt(status);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ range = (IgfsFileAffinityRange)in.readObject();
+ status = in.readInt();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(RangeUpdateProcessor.class, this);
+ }
}
/**
- * Creates update info closure that will mark given range as moving.
- *
- * @param range Range to mark as moving.
- * @return Update closure.
+ * Delete range processor.
*/
- private IgniteClosure<IgfsFileInfo, IgfsFileInfo> deleteRange(final IgfsFileAffinityRange range) {
- return new CX1<IgfsFileInfo, IgfsFileInfo>() {
- @Override public IgfsFileInfo applyx(IgfsFileInfo info) throws IgniteCheckedException {
- IgfsFileMap map = new IgfsFileMap(info.fileMap());
+ private static class RangeDeleteProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
- map.deleteRange(range);
+ /** Range. */
+ private IgfsFileAffinityRange range;
- if (log.isDebugEnabled())
- log.debug("Deleted range from file map [fileId=" + info.id() + ", range=" + range +
- ", oldMap=" + info.fileMap() + ", newMap=" + map + ']');
+ /**
+ * Constructor.
+ */
+ public RangeDeleteProcessor() {
+ // No-op.
+ }
- IgfsFileInfo updated = new IgfsFileInfo(info, info.length());
+ /**
+ * Constructor.
+ *
+ * @param range Range.
+ */
+ public RangeDeleteProcessor(IgfsFileAffinityRange range) {
+ this.range = range;
+ }
- updated.fileMap(map);
+ /** {@inheritDoc} */
+ @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsFileInfo oldInfo = entry.getValue();
- return updated;
- }
- };
+ IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
+
+ newMap.deleteRange(range);
+
+ IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, oldInfo.length());
+
+ newInfo.fileMap(newMap);
+
+ entry.setValue(newInfo);
+
+ return newInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(range);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ range = (IgfsFileAffinityRange)in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(RangeDeleteProcessor.class, this);
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/f57f3657/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInvalidRangeException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInvalidRangeException.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInvalidRangeException.java
index cd93278..d6ad2b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInvalidRangeException.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsInvalidRangeException.java
@@ -17,13 +17,13 @@
package org.apache.ignite.internal.processors.igfs;
-import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
/**
* Internal exception thrown when attempted to update range that is no longer present
* in file affinity map.
*/
-public class IgfsInvalidRangeException extends IgniteCheckedException {
+public class IgfsInvalidRangeException extends IgniteException {
/** */
private static final long serialVersionUID = 0L;
http://git-wip-us.apache.org/repos/asf/ignite/blob/f57f3657/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index 2a85cf8..b4774f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -1257,7 +1257,7 @@ public class IgfsMetaManager extends IgfsManager {
// Remove listing entries from root.
for (Map.Entry<String, IgfsListingEntry> entry : transferListing.entrySet())
- id2InfoPrj.invoke(IgfsUtils.ROOT_ID, new ListingRemove(entry.getKey(), entry.getValue().fileId()));
+ id2InfoPrj.invoke(IgfsUtils.ROOT_ID, new ListingRemoveProcessor(entry.getKey(), entry.getValue().fileId()));
resId = newInfo.id();
}
@@ -1408,7 +1408,7 @@ public class IgfsMetaManager extends IgfsManager {
IgfsListingEntry childEntry = parentInfo.listing().get(name);
if (childEntry != null)
- id2InfoPrj.invoke(parentId, new ListingRemove(name, id));
+ id2InfoPrj.invoke(parentId, new ListingRemoveProcessor(name, id));
id2InfoPrj.remove(id);
@@ -1584,20 +1584,20 @@ public class IgfsMetaManager extends IgfsManager {
* Update file info in cache.
*
* @param fileId File ID to update information for.
- * @param c Closure to update file's info inside transaction.
+ * @param proc Entry processor to invoke.
* @return Updated file info or {@code null} if such file ID not found.
* @throws IgniteCheckedException If failed.
*/
- @Nullable public IgfsFileInfo updateInfo(IgniteUuid fileId, IgniteClosure<IgfsFileInfo, IgfsFileInfo> c)
- throws IgniteCheckedException {
+ @Nullable public IgfsFileInfo updateInfo(IgniteUuid fileId,
+ EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo> proc) throws IgniteCheckedException {
validTxState(false);
assert fileId != null;
- assert c != null;
+ assert proc != null;
if (busyLock.enterBusy()) {
try {
if (log.isDebugEnabled())
- log.debug("Update file info [fileId=" + fileId + ", c=" + c + ']');
+ log.debug("Update file info [fileId=" + fileId + ", proc=" + proc + ']');
IgniteInternalTx tx = startTx();
@@ -1608,27 +1608,21 @@ public class IgfsMetaManager extends IgfsManager {
if (oldInfo == null)
return null; // File not found.
- IgfsFileInfo newInfo = c.apply(oldInfo);
+ IgfsFileInfo newInfo = invokeAndGet(fileId, proc);
if (newInfo == null)
throw fsException("Failed to update file info with null value" +
- " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", c=" + c + ']');
+ " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", proc=" + proc + ']');
if (!oldInfo.id().equals(newInfo.id()))
throw fsException("Failed to update file info (file IDs differ)" +
- " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", c=" + c + ']');
+ " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", proc=" + proc + ']');
if (oldInfo.isDirectory() != newInfo.isDirectory())
throw fsException("Failed to update file info (file types differ)" +
- " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", c=" + c + ']');
-
- boolean b = id2InfoPrj.replace(fileId, oldInfo, newInfo);
-
- assert b : "Inconsistent transaction state [oldInfo=" + oldInfo + ", newInfo=" + newInfo +
- ", c=" + c + ']';
+ " [oldInfo=" + oldInfo + ", newInfo=" + newInfo + ", proc=" + proc + ']');
- if (tx != null)
- tx.commit();
+ tx.commit();
return newInfo;
}
@@ -1636,8 +1630,7 @@ public class IgfsMetaManager extends IgfsManager {
throw U.cast(e);
}
finally {
- if (tx != null)
- tx.close();
+ tx.close();
}
}
finally {
@@ -1814,7 +1807,7 @@ public class IgfsMetaManager extends IgfsManager {
throw fsException("Failed to create new metadata entry due to ID conflict: " + info.id());
if (parentId != null)
- id2InfoPrj.invoke(parentId, new ListingAdd(name, new IgfsListingEntry(info)));
+ id2InfoPrj.invoke(parentId, new ListingAddProcessor(name, new IgfsListingEntry(info)));
}
/**
@@ -1831,8 +1824,8 @@ public class IgfsMetaManager extends IgfsManager {
IgniteUuid destId, String destName) throws IgniteCheckedException {
validTxState(true);
- id2InfoPrj.invoke(srcId, new ListingRemove(srcName, entry.fileId()));
- id2InfoPrj.invoke(destId, new ListingAdd(destName, entry));
+ id2InfoPrj.invoke(srcId, new ListingRemoveProcessor(srcName, entry.fileId()));
+ id2InfoPrj.invoke(destId, new ListingAddProcessor(destName, entry));
}
/**
@@ -1857,7 +1850,7 @@ public class IgfsMetaManager extends IgfsManager {
private void invokeUpdatePath(IgniteUuid id, IgfsPath path) throws IgniteCheckedException {
validTxState(true);
- id2InfoPrj.invoke(id, new UpdatePath(path));
+ id2InfoPrj.invoke(id, new UpdatePathProcessor(path));
}
/**
@@ -2009,7 +2002,7 @@ public class IgfsMetaManager extends IgfsManager {
id2InfoPrj.remove(oldId); // Remove the old one.
id2InfoPrj.invoke(parentInfo.id(),
- new ListingRemove(path.name(), parentInfo.listing().get(path.name()).fileId()));
+ new ListingRemoveProcessor(path.name(), parentInfo.listing().get(path.name()).fileId()));
createNewEntry(newInfo, parentInfo.id(), path.name()); // Put new one.
@@ -3101,7 +3094,7 @@ public class IgfsMetaManager extends IgfsManager {
* Remove entry from directory listing.
*/
@GridInternal
- private static final class ListingRemove implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static final class ListingRemoveProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3115,7 +3108,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Default constructor.
*/
- public ListingRemove() {
+ public ListingRemoveProcessor() {
// No-op.
}
@@ -3125,7 +3118,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param fileName File name.
* @param fileId File ID.
*/
- public ListingRemove(String fileName, IgniteUuid fileId) {
+ public ListingRemoveProcessor(String fileName, IgniteUuid fileId) {
this.fileName = fileName;
this.fileId = fileId;
}
@@ -3173,7 +3166,7 @@ public class IgfsMetaManager extends IgfsManager {
* Update directory listing closure.
*/
@GridInternal
- private static final class ListingAdd implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static final class ListingAddProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3190,7 +3183,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param fileName File name to add into parent listing.
* @param entry Listing entry to add or remove.
*/
- private ListingAdd(String fileName, IgfsListingEntry entry) {
+ private ListingAddProcessor(String fileName, IgfsListingEntry entry) {
assert fileName != null;
assert entry != null;
@@ -3202,7 +3195,7 @@ public class IgfsMetaManager extends IgfsManager {
* Empty constructor required for {@link Externalizable}.
*
*/
- public ListingAdd() {
+ public ListingAddProcessor() {
// No-op.
}
@@ -3242,7 +3235,7 @@ public class IgfsMetaManager extends IgfsManager {
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(ListingAdd.class, this);
+ return S.toString(ListingAddProcessor.class, this);
}
}
@@ -3250,7 +3243,7 @@ public class IgfsMetaManager extends IgfsManager {
* Update path closure.
*/
@GridInternal
- private static final class UpdatePath implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static final class UpdatePathProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3261,14 +3254,14 @@ public class IgfsMetaManager extends IgfsManager {
/**
* @param path Path.
*/
- private UpdatePath(IgfsPath path) {
+ private UpdatePathProcessor(IgfsPath path) {
this.path = path;
}
/**
* Default constructor (required by Externalizable).
*/
- public UpdatePath() {
+ public UpdatePathProcessor() {
// No-op.
}
@@ -3293,7 +3286,7 @@ public class IgfsMetaManager extends IgfsManager {
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(UpdatePath.class, this);
+ return S.toString(UpdatePathProcessor.class, this);
}
}
@@ -3665,7 +3658,7 @@ public class IgfsMetaManager extends IgfsManager {
leafParentId = parentId;
// Now link the newly created directory chain to the lowermost existing parent:
- id2InfoPrj.invoke(lowermostExistingId, new ListingAdd(childName, childInfo));
+ id2InfoPrj.invoke(lowermostExistingId, new ListingAddProcessor(childName, childInfo));
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/f57f3657/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
index 72a2bee..19a91ad 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManagerSelfTest.java
@@ -352,17 +352,6 @@ public class IgfsMetaManagerSelfTest extends IgfsCommonAbstractTest {
assertEmpty(mgr.directoryListing(b.id()));
- // Validate last actual data received from 'remove' operation.
- IgfsFileInfo newF2 = mgr.updateInfo(f2.id(), new C1<IgfsFileInfo, IgfsFileInfo>() {
- @Override public IgfsFileInfo apply(IgfsFileInfo e) {
- return new IgfsFileInfo(e, e.length() + 20);
- }
- });
-
- assertNotNull(newF2);
- assertEquals(f2.id(), newF2.id());
- assertNotSame(f2, newF2);
-
del = mgr.softDelete(path("/a/f2"), false);
assertEquals(f2.id(), del);
[10/50] [abbrv] ignite git commit: IGNITE-2814: IGFS: File
lock/unlock/reserve operations are no longer require put/replace on cache.
Thin entry processors are used instead.
Posted by sb...@apache.org.
IGNITE-2814: IGFS: File lock/unlock/reserve operations are no longer require put/replace on cache. Thin entry processors are used instead.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8083391b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8083391b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8083391b
Branch: refs/heads/ignite-1837
Commit: 8083391be726c2bbc27e018983ca713e4b25e2a2
Parents: 54e6991
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Mar 14 13:17:58 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:05 2016 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsMetaManager.java | 270 ++++++++++++++++---
.../processors/igfs/IgfsOutputStreamImpl.java | 76 +-----
2 files changed, 228 insertions(+), 118 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8083391b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index 89ddd02..8bb9e92 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -466,10 +466,11 @@ public class IgfsMetaManager extends IgfsManager {
* Lock the file explicitly outside of transaction.
*
* @param fileId File ID to lock.
+ * @param delete If file is being locked for delete.
* @return Locked file info or {@code null} if file cannot be locked or doesn't exist.
* @throws IgniteCheckedException If the file with such id does not exist, or on another failure.
*/
- public @Nullable IgfsFileInfo lock(IgniteUuid fileId, boolean isDeleteLock) throws IgniteCheckedException {
+ public @Nullable IgfsFileInfo lock(IgniteUuid fileId, boolean delete) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
assert validTxState(false);
@@ -487,13 +488,11 @@ public class IgfsMetaManager extends IgfsManager {
if (oldInfo.lockId() != null)
return null; // The file is already locked, we cannot lock it.
- IgfsFileInfo newInfo = lockInfo(oldInfo, isDeleteLock);
+ IgniteUuid lockId = createFileLockId(delete);
- boolean put = id2InfoPrj.replace(fileId, oldInfo, newInfo);
+ id2InfoPrj.invoke(fileId, new FileLockProcessor(lockId));
- assert put : "Value was not stored in cache [fileId=" + fileId + ", newInfo=" + newInfo + ']';
-
- assert newInfo.id().equals(oldInfo.id()); // Same id.
+ IgfsFileInfo newInfo = id2InfoPrj.get(fileId);
tx.commit();
@@ -515,30 +514,13 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * Set lock on file info.
+ * Create file lock ID.
*
- * @param info File info.
- * @return New file info with lock set, or null if the info passed in is already locked.
- * @throws IgniteCheckedException In case lock is already set on that file.
+ * @param delete If lock ID is required for file deletion.
+ * @return Lock ID.
*/
- private @Nullable IgfsFileInfo lockInfo(IgfsFileInfo info, boolean isDeleteLock) {
- assert info != null;
-
- if (info.lockId() != null)
- return null; // Null return value indicates that the file is already locked.
-
- return new IgfsFileInfo(info, composeLockId(isDeleteLock), info.modificationTime());
- }
-
- /**
- * Gets a new lock id.
- * The returned Id #globalId() method will return the Id of the node which locked the file.
- *
- * @param isDeleteLock if this is special delete lock.
- * @return The new lock id.
- */
- private IgniteUuid composeLockId(boolean isDeleteLock) {
- if (isDeleteLock)
+ private IgniteUuid createFileLockId(boolean delete) {
+ if (delete)
return IgfsUtils.DELETE_LOCK_ID;
return IgniteUuid.fromUuid(locNode.id());
@@ -584,12 +566,7 @@ public class IgfsMetaManager extends IgfsManager {
"[fileId=" + fileId + ", lockId=" + info.lockId() + ", actualLockId=" +
oldInfo.lockId() + ']');
- IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, null, modificationTime);
-
- boolean put = id2InfoPrj.put(fileId, newInfo);
-
- assert put : "Value was not stored in cache [fileId=" + fileId + ", newInfo=" + newInfo
- + ']';
+ id2InfoPrj.invoke(fileId, new FileUnlockProcessor(modificationTime));
return null;
}
@@ -1680,6 +1657,57 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
+ * Reserve space for file.
+ *
+ * @param path File path.
+ * @param fileId File ID.
+ * @param space Space.
+ * @param affRange Affinity range.
+ * @return New file info.
+ */
+ public IgfsFileInfo reserveSpace(IgfsPath path, IgniteUuid fileId, long space, IgfsFileAffinityRange affRange)
+ throws IgniteCheckedException {
+ assert validTxState(false);
+
+ if (busyLock.enterBusy()) {
+ try {
+ if (log.isDebugEnabled())
+ log.debug("Reserve file space [path=" + path + ", id=" + fileId + ']');
+
+ IgniteInternalTx tx = startTx();
+
+ try {
+ // Lock file ID for this transaction.
+ IgfsFileInfo oldInfo = info(fileId);
+
+ if (oldInfo == null)
+ throw fsException("File has been deleted concurrently [path=" + path + ", id=" + fileId + ']');
+
+ id2InfoPrj.invoke(fileId, new FileReserveSpaceProcessor(space, affRange));
+
+ IgfsFileInfo newInfo = id2InfoPrj.get(fileId);
+
+ tx.commit();
+
+ return newInfo;
+ }
+ catch (GridClosureException e) {
+ throw U.cast(e);
+ }
+ finally {
+ tx.close();
+ }
+ }
+ finally {
+ busyLock.leaveBusy();
+ }
+ }
+ else
+ throw new IllegalStateException("Failed to reseve file space because Grid is stopping [path=" + path +
+ ", id=" + fileId + ']');
+ }
+
+ /**
* Update file info in cache.
*
* @param fileId File ID to update information for.
@@ -1992,7 +2020,7 @@ public class IgfsMetaManager extends IgfsManager {
"the secondary file system because the path points to a directory: " + path);
IgfsFileInfo newInfo = new IgfsFileInfo(status.blockSize(), status.length(), affKey,
- composeLockId(false), igfsCtx.igfs().evictExclude(path, false), status.properties(),
+ createFileLockId(false), igfsCtx.igfs().evictExclude(path, false), status.properties(),
status.accessTime(), status.modificationTime());
// Add new file info to the listing optionally removing the previous one.
@@ -2113,13 +2141,11 @@ public class IgfsMetaManager extends IgfsManager {
}
// Set lock and return.
- IgfsFileInfo lockedInfo = lockInfo(info, false);
-
- assert lockedInfo != null; // We checked the lock above.
+ IgniteUuid lockId = createFileLockId(false);
- boolean put = id2InfoPrj.put(info.id(), lockedInfo);
+ id2InfoPrj.invoke(info.id(), new FileLockProcessor(lockId));
- assert put;
+ IgfsFileInfo lockedInfo = id2InfoPrj.get(info.id());
return new IgfsSecondaryOutputStreamDescriptor(infos.get(path.parent()).id(),
lockedInfo, out);
@@ -3455,7 +3481,7 @@ public class IgfsMetaManager extends IgfsManager {
@Override protected IgfsFileInfo buildLeaf() {
long t = System.currentTimeMillis();
- return new IgfsFileInfo(blockSize, 0L, affKey, composeLockId(false),
+ return new IgfsFileInfo(blockSize, 0L, affKey, createFileLockId(false),
evictExclude, leafProps, t, t);
}
};
@@ -3505,7 +3531,7 @@ public class IgfsMetaManager extends IgfsManager {
+ "[fileName=" + name + ", fileId=" + lowermostExistingInfo.id()
+ ", lockId=" + lockId + ']');
- IgniteUuid newLockId = composeLockId(false);
+ IgniteUuid newLockId = createFileLockId(false);
EntryProcessorResult<IgfsFileInfo> result
= id2InfoPrj.invoke(lowermostExistingInfo.id(),
@@ -3553,7 +3579,7 @@ public class IgfsMetaManager extends IgfsManager {
long t = System.currentTimeMillis();
final IgfsFileInfo newFileInfo = new IgfsFileInfo(cfg.getBlockSize(), 0L,
- affKey, composeLockId(false), evictExclude, fileProps, t, t);
+ affKey, createFileLockId(false), evictExclude, fileProps, t, t);
assert newFileInfo.lockId() != null; // locked info should be created.
@@ -3874,4 +3900,162 @@ public class IgfsMetaManager extends IgfsManager {
return S.toString(LockFileProcessor.class, this);
}
}
+
+ /**
+ * File lock entry processor.
+ */
+ private static class FileLockProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>, Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Lock Id. */
+ private IgniteUuid lockId;
+
+ /**
+ * Default constructor.
+ */
+ public FileLockProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param lockId Lock ID.
+ */
+ public FileLockProcessor(IgniteUuid lockId) {
+ this.lockId = lockId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsFileInfo old = entry.getValue();
+
+ entry.setValue(new IgfsFileInfo(old, lockId, old.modificationTime()));
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeGridUuid(out, lockId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ lockId = U.readGridUuid(in);
+ }
+ }
+
+ /**
+ * File unlock entry processor.
+ */
+ private static class FileUnlockProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Modification time. */
+ private long modificationTime;
+
+ /**
+ * Default constructor.
+ */
+ public FileUnlockProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param modificationTime Modification time.
+ */
+ public FileUnlockProcessor(long modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsFileInfo old = entry.getValue();
+
+ entry.setValue(new IgfsFileInfo(old, null, modificationTime));
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(modificationTime);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ modificationTime = in.readLong();
+ }
+ }
+
+ /**
+ * File reserve space entry processor.
+ */
+ private static class FileReserveSpaceProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Space. */
+ private long space;
+
+ /** Affinity range. */
+ private IgfsFileAffinityRange affRange;
+
+ /**
+ * Default constructor.
+ */
+ public FileReserveSpaceProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param space Space.
+ * @param affRange
+ */
+ public FileReserveSpaceProcessor(long space, IgfsFileAffinityRange affRange) {
+ this.space = space;
+ this.affRange = affRange;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsFileInfo oldInfo = entry.getValue();
+
+ IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
+
+ newMap.addRange(affRange);
+
+ IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, oldInfo.length() + space);
+
+ newInfo.fileMap(newMap);
+
+ entry.setValue(newInfo);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(space);
+ out.writeObject(affRange);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ space = in.readLong();
+ affRange = (IgfsFileAffinityRange)in.readObject();
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/8083391b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
index 83056af..8c11073 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
@@ -18,10 +18,7 @@
package org.apache.ignite.internal.processors.igfs;
import java.io.DataInput;
-import java.io.Externalizable;
import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.ignite.IgniteCheckedException;
@@ -30,11 +27,9 @@ import org.apache.ignite.igfs.IgfsMode;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.igfs.IgfsPathNotFoundException;
import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.task.GridInternal;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
@@ -297,8 +292,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
if (space > 0) {
data.awaitAllAcksReceived(fileInfo.id());
- IgfsFileInfo fileInfo0 = meta.updateInfo(fileInfo.id(),
- new ReserveSpaceClosure(space, streamRange));
+ IgfsFileInfo fileInfo0 = meta.reserveSpace(path, fileInfo.id(), space, streamRange);
if (fileInfo0 == null)
throw new IOException("File was concurrently deleted: " + path);
@@ -446,72 +440,4 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
@Override public String toString() {
return S.toString(IgfsOutputStreamImpl.class, this);
}
-
- /**
- * Helper closure to reserve specified space and update file's length
- */
- @GridInternal
- private static final class ReserveSpaceClosure implements IgniteClosure<IgfsFileInfo, IgfsFileInfo>,
- Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Space amount (bytes number) to increase file's length. */
- private long space;
-
- /** Affinity range for this particular update. */
- private IgfsFileAffinityRange range;
-
- /**
- * Empty constructor required for {@link Externalizable}.
- *
- */
- public ReserveSpaceClosure() {
- // No-op.
- }
-
- /**
- * Constructs the closure to reserve specified space and update file's length.
- *
- * @param space Space amount (bytes number) to increase file's length.
- * @param range Affinity range specifying which part of file was colocated.
- */
- private ReserveSpaceClosure(long space, IgfsFileAffinityRange range) {
- this.space = space;
- this.range = range;
- }
-
- /** {@inheritDoc} */
- @Override public IgfsFileInfo apply(IgfsFileInfo oldInfo) {
- IgfsFileMap oldMap = oldInfo.fileMap();
-
- IgfsFileMap newMap = new IgfsFileMap(oldMap);
-
- newMap.addRange(range);
-
- // Update file length.
- IgfsFileInfo updated = new IgfsFileInfo(oldInfo, oldInfo.length() + space);
-
- updated.fileMap(newMap);
-
- return updated;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeLong(space);
- out.writeObject(range);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- space = in.readLong();
- range = (IgfsFileAffinityRange)in.readObject();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(ReserveSpaceClosure.class, this);
- }
- }
}
\ No newline at end of file
[36/50] [abbrv] ignite git commit: Added detail info about keys count
in partitions for offheap and swap.
Posted by sb...@apache.org.
Added detail info about keys count in partitions for offheap and swap.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0412c9bf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0412c9bf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0412c9bf
Branch: refs/heads/ignite-1837
Commit: 0412c9bfd89b8d2a377588e908f1012c845ac5bc
Parents: 59705e0
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Wed Mar 30 11:43:19 2016 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Wed Mar 30 11:43:19 2016 +0700
----------------------------------------------------------------------
.../processors/cache/GridCacheSwapManager.java | 26 ++++-
.../internal/visor/cache/VisorCacheV3.java | 108 +++++++++++++++++++
.../visor/node/VisorNodeDataCollectorJob.java | 31 +++---
3 files changed, 152 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0412c9bf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index cbf09bc..a35bb3f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -305,6 +305,18 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
}
/**
+ * @param partId Partition ID to get swap entries count for.
+ * @return Number of swap entries.
+ * @throws IgniteCheckedException If failed.
+ */
+ public long swapEntriesCount(int partId) throws IgniteCheckedException {
+ if (!swapEnabled)
+ return 0;
+
+ return swapMgr.swapKeys(spaceName, Collections.singleton(partId));
+ }
+
+ /**
* @param primary If {@code true} includes primary entries.
* @param backup If {@code true} includes backup entries.
* @param topVer Topology version.
@@ -328,6 +340,18 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
}
/**
+ * @param partId Partition ID to get entries count for.
+ * @return Number of offheap entries.
+ * @throws IgniteCheckedException If failed.
+ */
+ public long offheapEntriesCount(int partId) throws IgniteCheckedException {
+ if (!offheapEnabled)
+ return 0;
+
+ return offheap.entriesCount(spaceName, Collections.singleton(partId));
+ }
+
+ /**
* Gets number of swap entries (keys).
*
* @return Swap keys count.
@@ -2523,4 +2547,4 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
throw new UnsupportedOperationException();
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0412c9bf/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV3.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV3.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV3.java
new file mode 100644
index 0000000..bd9a3ce
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheV3.java
@@ -0,0 +1,108 @@
+/*
+ * 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.visor.cache;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.GridCacheSwapManager;
+import org.apache.ignite.internal.util.lang.GridTuple3;
+import org.apache.ignite.internal.util.lang.IgnitePair;
+
+/**
+ * Data transfer object for {@link IgniteCache}.
+ */
+public class VisorCacheV3 extends VisorCacheV2 {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Primary partitions IDs with offheap and swap entries count. */
+ private Collection<GridTuple3<Integer, Long, Long>> primaryPartsOffheapSwap;
+
+ /** Backup partitions IDs with offheap and swap entries count. */
+ private Collection<GridTuple3<Integer, Long, Long>> backupPartsOffheapSwap;
+
+ /** {@inheritDoc} */
+ @Override public VisorCache from(IgniteEx ignite, String cacheName, int sample) throws IgniteCheckedException {
+ VisorCache c = super.from(ignite, cacheName, sample);
+
+ if (c != null && c instanceof VisorCacheV3) {
+ VisorCacheV3 cacheV3 = (VisorCacheV3)c;
+
+ GridCacheAdapter ca = ignite.context().cache().internalCache(cacheName);
+
+ // Process only started caches.
+ if (ca != null && ca.context().started()) {
+ GridCacheSwapManager swap = ca.context().swap();
+
+ cacheV3.primaryPartsOffheapSwap = new ArrayList<>(c.primaryPartitions().size());
+
+ for (IgnitePair<Integer> part: c.primaryPartitions()) {
+ int p = part.get1();
+
+ cacheV3.primaryPartsOffheapSwap.add(new GridTuple3<>(p, swap.offheapEntriesCount(p), swap.swapEntriesCount(p)));
+ }
+
+ cacheV3.backupPartsOffheapSwap = new ArrayList<>(c.backupPartitions().size());
+
+ for (IgnitePair<Integer> part: c.backupPartitions()) {
+ int p = part.get1();
+
+ cacheV3.backupPartsOffheapSwap.add(new GridTuple3<>(p, swap.offheapEntriesCount(p), swap.swapEntriesCount(p)));
+ }
+ }
+ }
+
+ return c;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected VisorCache initHistory(VisorCache c) {
+ super.initHistory(c);
+
+ if (c instanceof VisorCacheV3) {
+ ((VisorCacheV3)c).primaryPartsOffheapSwap = Collections.emptyList();
+ ((VisorCacheV3)c).backupPartsOffheapSwap = Collections.emptyList();
+ }
+
+ return c;
+ }
+
+ /** {@inheritDoc} */
+ @Override public VisorCache history() {
+ return initHistory(new VisorCacheV3());
+ }
+
+ /**
+ * @return Collection with primary partitions IDs and offheap and swap entries count.
+ */
+ public Collection<GridTuple3<Integer, Long, Long>> primaryPartitionsOffheapSwap() {
+ return primaryPartsOffheapSwap;
+ }
+
+ /**
+ * @return Collection with backup partitions IDs and offheap and swap entries count.
+ */
+ public Collection<GridTuple3<Integer, Long, Long>> backupPartitionsOffheapSwap() {
+ return backupPartsOffheapSwap;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0412c9bf/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java
index f996d9a..79760ef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java
@@ -30,6 +30,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.visor.VisorJob;
import org.apache.ignite.internal.visor.cache.VisorCache;
import org.apache.ignite.internal.visor.cache.VisorCacheV2;
+import org.apache.ignite.internal.visor.cache.VisorCacheV3;
import org.apache.ignite.internal.visor.compute.VisorComputeMonitoringHolder;
import org.apache.ignite.internal.visor.igfs.VisorIgfs;
import org.apache.ignite.internal.visor.igfs.VisorIgfsEndpoint;
@@ -53,6 +54,9 @@ public class VisorNodeDataCollectorJob extends VisorJob<VisorNodeDataCollectorTa
/** */
private static final IgniteProductVersion VER_1_4_1 = IgniteProductVersion.fromString("1.4.1");
+ /** */
+ private static final IgniteProductVersion VER_1_5_9 = IgniteProductVersion.fromString("1.5.9");
+
/**
* Create job with given argument.
*
@@ -120,6 +124,18 @@ public class VisorNodeDataCollectorJob extends VisorJob<VisorNodeDataCollectorTa
}
/**
+ * @param ver Version to check.
+ * @return {@code true} if compatible.
+ */
+ private boolean compatibleWith(IgniteProductVersion ver) {
+ for (ClusterNode node : ignite.cluster().nodes())
+ if (node.version().compareToIgnoreTimestamp(ver) <= 0)
+ return true;
+
+ return false;
+ }
+
+ /**
* Collect caches.
*
* @param res Job result.
@@ -136,18 +152,9 @@ public class VisorNodeDataCollectorJob extends VisorJob<VisorNodeDataCollectorTa
long start0 = U.currentTimeMillis();
try {
- boolean compatibility = false;
-
- for (ClusterNode node : ignite.cluster().nodes()) {
- if (node.version().compareToIgnoreTimestamp(VER_1_4_1) <= 0) {
- compatibility = true;
-
- break;
- }
- }
-
- VisorCache cache = (compatibility ? new VisorCache() : new VisorCacheV2())
- .from(ignite, cacheName, arg.sample());
+ VisorCache cache = (compatibleWith(VER_1_4_1) ? new VisorCache() :
+ compatibleWith(VER_1_5_9) ? new VisorCacheV2() : new VisorCacheV3())
+ .from(ignite, cacheName, arg.sample());
if (cache != null)
res.caches().add(cache);
[39/50] [abbrv] ignite git commit: Now cache plugins are able to
unwrap entries passed to EntryProcessor.
Posted by sb...@apache.org.
Now cache plugins are able to unwrap entries passed to EntryProcessor.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ec2ec996
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ec2ec996
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ec2ec996
Branch: refs/heads/ignite-1837
Commit: ec2ec9965ae03ef3666b2035a13f444cf2765aec
Parents: a70d2dc
Author: dkarachentsev <dk...@gridgain.com>
Authored: Wed Mar 30 13:29:36 2016 +0300
Committer: dkarachentsev <dk...@gridgain.com>
Committed: Tue Apr 5 12:06:22 2016 +0300
----------------------------------------------------------------------
.../processors/cache/CacheInvokeEntry.java | 41 +++++++++++++++-----
.../processors/cache/CacheLazyEntry.java | 9 ++++-
.../processors/cache/GridCacheMapEntry.java | 9 +++--
.../distributed/dht/GridDhtTxPrepareFuture.java | 12 +++---
.../dht/atomic/GridDhtAtomicCache.java | 4 +-
.../local/atomic/GridLocalAtomicCache.java | 4 +-
.../cache/transactions/IgniteTxAdapter.java | 8 ++--
.../cache/transactions/IgniteTxEntry.java | 4 +-
.../transactions/IgniteTxLocalAdapter.java | 5 +--
.../processors/plugin/CachePluginManager.java | 25 ++++++++++++
.../ignite/plugin/CachePluginProvider.java | 11 ++++++
...CacheDeploymentCachePluginConfiguration.java | 7 ++++
12 files changed, 107 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec2ec996/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
index 2ecfdbf..2526146 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheInvokeEntry.java
@@ -40,44 +40,53 @@ public class CacheInvokeEntry<K, V> extends CacheLazyEntry<K, V> implements Muta
/** Entry version. */
private GridCacheVersion ver;
+ /** Cache entry instance. */
+ private GridCacheEntryEx entry;
+
/**
- * @param cctx Cache context.
+ * Constructor.
+ *
* @param keyObj Key cache object.
* @param valObj Cache object value.
* @param ver Entry version.
+ * @param keepBinary Keep binary flag.
+ * @param entry Original entry.
*/
- public CacheInvokeEntry(GridCacheContext cctx,
- KeyCacheObject keyObj,
+ public CacheInvokeEntry(KeyCacheObject keyObj,
@Nullable CacheObject valObj,
GridCacheVersion ver,
- boolean keepBinary
+ boolean keepBinary,
+ GridCacheEntryEx entry
) {
- super(cctx, keyObj, valObj, keepBinary);
+ super(entry.context(), keyObj, valObj, keepBinary);
this.hadVal = valObj != null;
this.ver = ver;
+ this.entry = entry;
}
/**
- * @param ctx Cache context.
* @param keyObj Key cache object.
* @param key Key value.
* @param valObj Value cache object.
* @param val Value.
* @param ver Entry version.
+ * @param keepBinary Keep binary flag.
+ * @param entry Grid cache entry.
*/
- public CacheInvokeEntry(GridCacheContext<K, V> ctx,
- KeyCacheObject keyObj,
+ public CacheInvokeEntry(KeyCacheObject keyObj,
@Nullable K key,
@Nullable CacheObject valObj,
@Nullable V val,
GridCacheVersion ver,
- boolean keepBinary
+ boolean keepBinary,
+ GridCacheEntryEx entry
) {
- super(ctx, keyObj, key, valObj, val, keepBinary);
+ super(entry.context(), keyObj, key, valObj, val, keepBinary);
this.hadVal = valObj != null || val != null;
this.ver = ver;
+ this.entry = entry;
}
/** {@inheritDoc} */
@@ -122,12 +131,24 @@ public class CacheInvokeEntry<K, V> extends CacheLazyEntry<K, V> implements Muta
return op != Operation.NONE;
}
+ /**
+ * @return Cache entry instance.
+ */
+ public GridCacheEntryEx entry() {
+ return entry;
+ }
+
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public <T> T unwrap(Class<T> cls) {
if (cls.isAssignableFrom(CacheEntry.class) && ver != null)
return (T)new CacheEntryImplEx<>(getKey(), getValue(), ver);
+ final T res = cctx.plugin().unwrapCacheEntry(this, cls);
+
+ if (res != null)
+ return res;
+
return super.unwrap(cls);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec2ec996/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
index 6ec17c0..c1fcb77 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
@@ -80,7 +80,7 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, V> {
* @param keepBinary Keep binary flag.
* @param val Cache value.
*/
- public CacheLazyEntry(GridCacheContext<K, V> ctx,
+ public CacheLazyEntry(GridCacheContext ctx,
KeyCacheObject keyObj,
K key,
CacheObject valObj,
@@ -136,6 +136,13 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, V> {
return key;
}
+ /**
+ * @return Keep binary flag.
+ */
+ public boolean keepBinary() {
+ return keepBinary;
+ }
+
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public <T> T unwrap(Class<T> cls) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec2ec996/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 9678fe0..5519070 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -1614,7 +1614,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
assert entryProcessor != null;
- CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry<>(cctx, key, old, version(), keepBinary);
+ CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry<>(key, old, version(), keepBinary, this);
try {
Object computed = entryProcessor.process(entry, invokeArgs);
@@ -1907,7 +1907,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
oldVal = rawGetOrUnmarshalUnlocked(true);
- CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry(cctx, key, oldVal, version(), keepBinary);
+ CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry(key, oldVal, version(),
+ keepBinary, this);
try {
Object computed = entryProcessor.process(entry, invokeArgs);
@@ -2045,7 +2046,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
(EntryProcessor<Object, Object, ?>)writeObj;
CacheInvokeEntry<Object, Object> entry =
- new CacheInvokeEntry<>(cctx, key, prevVal, version(), keepBinary);
+ new CacheInvokeEntry<>(key, prevVal, version(), keepBinary, this);
try {
entryProcessor.process(entry, invokeArgs);
@@ -2175,7 +2176,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
EntryProcessor<Object, Object, ?> entryProcessor = (EntryProcessor<Object, Object, ?>)writeObj;
- CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry(cctx, key, oldVal, version(), keepBinary);
+ CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry(key, oldVal, version(), keepBinary, this);
try {
Object computed = entryProcessor.process(entry, invokeArgs);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec2ec996/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index b8995bf..00cbd29 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -344,6 +344,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (evt && txEntry.op() == TRANSFORM)
entryProc = F.first(txEntry.entryProcessors()).get1();
+ final boolean keepBinary = txEntry.keepBinary();
+
CacheObject val = cached.innerGet(
tx,
/*swap*/true,
@@ -357,7 +359,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
entryProc,
tx.resolveTaskName(),
null,
- txEntry.keepBinary());
+ keepBinary);
if (retVal || txEntry.op() == TRANSFORM) {
if (!F.isEmpty(txEntry.entryProcessors())) {
@@ -373,9 +375,9 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
boolean modified = false;
- for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : txEntry.entryProcessors()) {
- CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry<>(
- txEntry.context(), key, val, txEntry.cached().version(), txEntry.keepBinary());
+ for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : txEntry.entryProcessors()) {
+ CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry<>(key, val,
+ txEntry.cached().version(), keepBinary, txEntry.cached());
try {
EntryProcessor<Object, Object, Object> processor = t.get1();
@@ -419,7 +421,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
}
}
else if (retVal)
- ret.value(cacheCtx, val, txEntry.keepBinary());
+ ret.value(cacheCtx, val, keepBinary);
}
if (hasFilters && !cacheCtx.isAll(cached, txEntry.filters())) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec2ec996/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 2a9cc2f..3a71b7a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -1659,8 +1659,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
Object oldVal = null;
Object updatedVal = null;
- CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry(ctx, entry.key(), old,
- entry.version(), req.keepBinary());
+ CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry(entry.key(), old,
+ entry.version(), req.keepBinary(), entry);
CacheObject updated;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec2ec996/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index fed3e33..651c4d0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -1195,8 +1195,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
Object oldVal = null;
- CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry<>(ctx, entry.key(), old,
- entry.version(), keepBinary);
+ CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry<>(entry.key(), old,
+ entry.version(), keepBinary, entry);
CacheObject updated;
Object updatedVal = null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec2ec996/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index ca5a8fd..6af388b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -1240,6 +1240,8 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
boolean recordEvt = cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ);
+ final boolean keepBinary = txEntry.keepBinary();
+
CacheObject cacheVal = txEntry.hasValue() ? txEntry.value() :
txEntry.cached().innerGet(this,
/*swap*/false,
@@ -1253,7 +1255,7 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
/**closure name */recordEvt ? F.first(txEntry.entryProcessors()).get1() : null,
resolveTaskName(),
null,
- txEntry.keepBinary());
+ keepBinary);
boolean modified = false;
@@ -1276,8 +1278,8 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
}
for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : txEntry.entryProcessors()) {
- CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry(txEntry.context(),
- txEntry.key(), key, cacheVal, val, ver, txEntry.keepBinary());
+ CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry<>(
+ txEntry.key(), key, cacheVal, val, ver, keepBinary, txEntry.cached());
try {
EntryProcessor<Object, Object, Object> processor = t.get1();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec2ec996/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index 18fca64..ecaf04f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -687,8 +687,8 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : entryProcessors()) {
try {
- CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry(ctx, key, keyVal, cacheVal, val,
- ver, keepBinary());
+ CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry(key, keyVal, cacheVal, val,
+ ver, keepBinary(), cached());
EntryProcessor processor = t.get1();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec2ec996/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index 7ed9542..fef91c8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -2963,9 +2963,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
Object res = null;
for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : txEntry.entryProcessors()) {
- CacheInvokeEntry<Object, Object> invokeEntry =
- new CacheInvokeEntry(txEntry.context(), txEntry.key(), key0, cacheVal, val0, ver,
- txEntry.keepBinary());
+ CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry<>(txEntry.key(), key0, cacheVal,
+ val0, ver, txEntry.keepBinary(), txEntry.cached());
EntryProcessor<Object, Object, ?> entryProcessor = t.get1();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec2ec996/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
index 23f1f3f..d0efc0a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
@@ -38,6 +38,9 @@ import org.apache.ignite.internal.processors.cache.store.CacheStoreManager;
import org.apache.ignite.plugin.CachePluginConfiguration;
import org.apache.ignite.plugin.CachePluginContext;
import org.apache.ignite.plugin.CachePluginProvider;
+import org.jetbrains.annotations.Nullable;
+
+import javax.cache.Cache;
/**
* Cache plugin manager.
@@ -131,6 +134,28 @@ public class CachePluginManager extends GridCacheManagerAdapter {
}
/**
+ * Unwrap entry to specified type. For details see {@code javax.cache.Cache.Entry.unwrap(Class)}.
+ *
+ * @param entry Entry to unwrap.
+ * @param cls Type of the expected component.
+ * @param <T> Return type.
+ * @param <K> Key type.
+ * @param <V> Value type.
+ * @return New instance of underlying type or {@code null} if it's not available.
+ */
+ @SuppressWarnings({"unchecked", "ForLoopReplaceableByForEach"})
+ @Nullable public <T, K, V> T unwrapCacheEntry(Cache.Entry<K, V> entry, Class<T> cls) {
+ for (int i = 0; i < providersList.size(); i++) {
+ final T res = (T)providersList.get(i).unwrapCacheEntry(entry, cls);
+
+ if (res != null)
+ return res;
+ }
+
+ return null;
+ }
+
+ /**
* Validates cache plugin configurations. Throw exception if validation failed.
*
* @throws IgniteCheckedException If validation failed.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec2ec996/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java b/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java
index 11550ec..b7ed0b3 100644
--- a/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java
+++ b/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java
@@ -22,6 +22,8 @@ import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.jetbrains.annotations.Nullable;
+import javax.cache.Cache;
+
/**
* Cache plugin provider is a point for processing of properties
* which provide specific {@link CachePluginConfiguration}.
@@ -65,6 +67,15 @@ public interface CachePluginProvider<C extends CachePluginConfiguration> {
@Nullable public <T> T createComponent(Class<T> cls);
/**
+ * Unwrap entry to specified type. For details see {@code javax.cache.Cache.Entry.unwrap(Class)}.
+ *
+ * @param entry Mutable entry to unwrap.
+ * @param cls Type of the expected component.
+ * @return New instance of underlying type or {@code null} if it's not available.
+ */
+ @Nullable public <T, K, V> T unwrapCacheEntry(Cache.Entry<K, V> entry, Class<T> cls);
+
+ /**
* Validates cache plugin configuration in process of cache creation. Throw exception if validation failed.
*
* @throws IgniteCheckedException If validation failed.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec2ec996/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCachePluginConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCachePluginConfiguration.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCachePluginConfiguration.java
index bb37c25..ff2e674 100644
--- a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCachePluginConfiguration.java
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCachePluginConfiguration.java
@@ -25,6 +25,8 @@ import org.apache.ignite.plugin.CachePluginContext;
import org.apache.ignite.plugin.CachePluginProvider;
import org.jetbrains.annotations.Nullable;
+import javax.cache.Cache;
+
/**
* Test cache plugin configuration for cache deployment tests.
*/
@@ -41,6 +43,11 @@ public class CacheDeploymentCachePluginConfiguration<K, V> implements CachePlugi
}
/** {@inheritDoc} */
+ @Nullable @Override public Object unwrapCacheEntry(final Cache.Entry mutableEntry, final Class cls) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public void start() throws IgniteCheckedException {
}
[17/50] [abbrv] ignite git commit: IGNITE-2860: IGFS: Reworked base
meta operations.
Posted by sb...@apache.org.
IGNITE-2860: IGFS: Reworked base meta operations.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8a93c3bf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8a93c3bf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8a93c3bf
Branch: refs/heads/ignite-1837
Commit: 8a93c3bf1687e6f2de1a4391d95366d733a44a7d
Parents: f57f365
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Mar 18 16:38:45 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:30 2016 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/igfs/IgfsPath.java | 9 +
.../internal/processors/igfs/IgfsImpl.java | 59 +-
.../processors/igfs/IgfsMetaManager.java | 1058 +++++++++---------
.../internal/processors/igfs/IgfsPathIds.java | 291 +++++
.../processors/igfs/IgfsPathsCreateResult.java | 77 ++
.../internal/processors/igfs/IgfsUtils.java | 23 +-
.../processors/igfs/IgfsAbstractSelfTest.java | 68 +-
.../igfs/IgfsMetaManagerSelfTest.java | 31 +-
.../processors/igfs/IgfsProcessorSelfTest.java | 26 +-
.../processors/igfs/IgfsStartCacheTest.java | 9 +-
.../apache/ignite/igfs/IgfsEventsTestSuite.java | 10 +-
11 files changed, 1039 insertions(+), 622 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a93c3bf/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java
index fb0621c..bbb4efb 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsPath.java
@@ -159,6 +159,15 @@ public final class IgfsPath implements Comparable<IgfsPath>, Externalizable {
}
/**
+ * Get components in array form.
+ *
+ * @return Components array.
+ */
+ public String[] componentsArray() {
+ return path.length() == 1 ? new String[0] : path.substring(1).split(SLASH);
+ }
+
+ /**
* Returns the parent of a path or {@code null} if at root.
*
* @return The parent of a path or {@code null} if at root.
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a93c3bf/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 3065427..9ec583c 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
@@ -17,24 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
@@ -94,6 +76,25 @@ import org.apache.ignite.thread.IgniteThreadPoolExecutor;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicBoolean;
+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_DIR_RENAMED;
import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_CLOSED_READ;
@@ -1033,8 +1034,15 @@ public final class IgfsImpl implements IgfsEx {
else
dirProps = fileProps = new HashMap<>(props);
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = meta.create(path, false/*append*/, overwrite, dirProps,
- cfg.getBlockSize(), affKey, evictExclude(path, true), fileProps);
+ IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = meta.create(
+ path,
+ dirProps,
+ overwrite,
+ cfg.getBlockSize(),
+ affKey,
+ evictExclude(path, true),
+ fileProps
+ );
assert t2 != null;
@@ -1104,8 +1112,15 @@ public final class IgfsImpl implements IgfsEx {
else
dirProps = fileProps = new HashMap<>(props);
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = meta.create(path, true/*append*/, false/*overwrite*/,
- dirProps, cfg.getBlockSize(), null/*affKey*/, evictExclude(path, true), fileProps);
+ IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = meta.append(
+ path,
+ dirProps,
+ create,
+ cfg.getBlockSize(),
+ null/*affKey*/,
+ evictExclude(path, true),
+ fileProps
+ );
assert t2 != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a93c3bf/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index b4774f2..d91b0bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -17,31 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.concurrent.CountDownLatch;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.EntryProcessorException;
-import javax.cache.processor.MutableEntry;
-
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteInterruptedException;
@@ -82,16 +57,36 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
import org.jetbrains.annotations.Nullable;
-import static org.apache.ignite.events.EventType.EVT_IGFS_DIR_CREATED;
-import static org.apache.ignite.events.EventType.EVT_IGFS_DIR_RENAMED;
-import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_CREATED;
-import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_RENAMED;
-import static org.apache.ignite.events.EventType.EVT_IGFS_FILE_OPENED_WRITE;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.concurrent.CountDownLatch;
+
import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.builder;
-import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
-import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
/**
* Cache based structure (meta data) manager.
@@ -334,6 +329,51 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
+ * Gets all file IDs for components of specified path. Result cannot be empty - there is at least root element.
+ * But each element (except the first) can be {@code null} if such files don't exist.
+ *
+ * @param path Path.
+ * @return Collection of file IDs for components of specified path.
+ * @throws IgniteCheckedException If failed.
+ */
+ public IgfsPathIds pathIds(IgfsPath path) throws IgniteCheckedException {
+ if (busyLock.enterBusy()) {
+ try {
+ validTxState(false);
+
+ // Prepare parts.
+ String[] components = path.componentsArray();
+
+ String[] parts = new String[components.length + 1];
+
+ System.arraycopy(components, 0, parts, 1, components.length);
+
+ // Prepare IDs.
+ IgniteUuid[] ids = new IgniteUuid[parts.length];
+
+ ids[0] = IgfsUtils.ROOT_ID;
+
+ for (int i = 1; i < ids.length; i++) {
+ IgniteUuid id = fileId(ids[i - 1], parts[i], false);
+
+ if (id != null)
+ ids[i] = id;
+ else
+ break;
+ }
+
+ // Return.
+ return new IgfsPathIds(path, parts, ids);
+ }
+ finally {
+ busyLock.leaveBusy();
+ }
+ }
+ else
+ throw new IllegalStateException("Failed to get file IDS because Grid is stopping: " + path);
+ }
+
+ /**
* Gets all file IDs for components of specified path possibly skipping existing transaction. Result cannot
* be empty - there is at least root element. But each element (except the first) can be {@code null} if such
* files don't exist.
@@ -823,107 +863,84 @@ public class IgfsMetaManager extends IgfsManager {
try {
validTxState(false);
- // 1. First get source and destination path IDs.
- List<IgniteUuid> srcPathIds = fileIds(srcPath);
- List<IgniteUuid> dstPathIds = fileIds(dstPath);
+ // Prepare path IDs.
+ IgfsPathIds srcPathIds = pathIds(srcPath);
+ IgfsPathIds dstPathIds = pathIds(dstPath);
- final Set<IgniteUuid> allIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
+ // Source path must exists.
+ if (!srcPathIds.allExists())
+ throw new IgfsPathNotFoundException("Failed to perform move because source path is not " +
+ "found: " + srcPath);
- allIds.addAll(srcPathIds);
+ // At this point we need to understand name of resulting entry. It will be either destination leaf
+ // or source leaf depending on existence.
+ String dstName;
- final IgniteUuid dstLeafId = dstPathIds.get(dstPathIds.size() - 1);
+ if (dstPathIds.lastExists())
+ // Full destination path exists -> use source name.
+ dstName = srcPathIds.lastPart();
+ else {
+ if (dstPathIds.lastParentExists()) {
+ // Destination path doesn't exists -> use destination name.
+ dstName = dstPathIds.lastPart();
- if (dstLeafId == null) {
- // Delete null entry for the unexisting destination element:
- dstPathIds.remove(dstPathIds.size() - 1);
+ dstPathIds = dstPathIds.parent();
+ }
+ else
+ // Destination parent is not found either -> exception.
+ throw new IgfsPathNotFoundException("Failed to perform move because destination path is not " +
+ "found: " + dstPath.parent());
}
- allIds.addAll(dstPathIds);
+ // Lock participating IDs.
+ final Set<IgniteUuid> lockIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
- if (allIds.remove(null)) {
- throw new IgfsPathNotFoundException("Failed to perform move because some path component was " +
- "not found. [src=" + srcPath + ", dst=" + dstPath + ']');
- }
+ srcPathIds.addExistingIds(lockIds);
+ dstPathIds.addExistingIds(lockIds);
- // 2. Start transaction.
IgniteInternalTx tx = startTx();
try {
- // 3. Obtain the locks.
- final Map<IgniteUuid, IgfsFileInfo> allInfos = lockIds(allIds);
+ // Obtain the locks.
+ final Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(lockIds);
- // 4. Verify integrity of source directory.
- if (!verifyPathIntegrity(srcPath, srcPathIds, allInfos)) {
+ // Verify integrity of source and destination paths.
+ if (!srcPathIds.verifyIntegrity(lockInfos))
throw new IgfsPathNotFoundException("Failed to perform move because source directory " +
"structure changed concurrently [src=" + srcPath + ", dst=" + dstPath + ']');
- }
-
- // 5. Verify integrity of destination directory.
- final IgfsPath dstDirPath = dstLeafId != null ? dstPath : dstPath.parent();
- if (!verifyPathIntegrity(dstDirPath, dstPathIds, allInfos)) {
+ if (!dstPathIds.verifyIntegrity(lockInfos))
throw new IgfsPathNotFoundException("Failed to perform move because destination directory " +
"structure changed concurrently [src=" + srcPath + ", dst=" + dstPath + ']');
- }
-
- // 6. Calculate source and destination targets which will be changed.
- IgniteUuid srcTargetId = srcPathIds.get(srcPathIds.size() - 2);
- IgfsFileInfo srcTargetInfo = allInfos.get(srcTargetId);
- String srcName = srcPath.name();
-
- IgniteUuid dstTargetId;
- IgfsFileInfo dstTargetInfo;
- String dstName;
- if (dstLeafId != null) {
- // Destination leaf exists. Check if it is an empty directory.
- IgfsFileInfo dstLeafInfo = allInfos.get(dstLeafId);
-
- assert dstLeafInfo != null;
-
- if (dstLeafInfo.isDirectory()) {
- // Destination is a directory.
- dstTargetId = dstLeafId;
- dstTargetInfo = dstLeafInfo;
- dstName = srcPath.name();
- }
- else {
- // Error, destination is existing file.
- throw new IgfsPathAlreadyExistsException("Failed to perform move " +
- "because destination points to " +
- "existing file [src=" + srcPath + ", dst=" + dstPath + ']');
- }
- }
- else {
- // Destination leaf doesn't exist, so we operate on parent.
- dstTargetId = dstPathIds.get(dstPathIds.size() - 1);
- dstTargetInfo = allInfos.get(dstTargetId);
- dstName = dstPath.name();
- }
+ // Addiional check: is destination directory?
+ IgfsFileInfo dstParentInfo = lockInfos.get(dstPathIds.lastId());
- assert dstTargetInfo != null;
- assert dstTargetInfo.isDirectory();
+ if (dstParentInfo.isFile())
+ throw new IgfsPathAlreadyExistsException("Failed to perform move because destination points " +
+ "to existing file [src=" + srcPath + ", dst=" + dstPath + ']');
- // 7. Last check: does destination target already have listing entry with the same name?
- if (dstTargetInfo.hasChild(dstName)) {
+ // Additional check: does destination already has child with the same name?
+ if (dstParentInfo.hasChild(dstName))
throw new IgfsPathAlreadyExistsException("Failed to perform move because destination already " +
"contains entry with the same name existing file [src=" + srcPath +
", dst=" + dstPath + ']');
- }
- // 8. Actual move: remove from source parent and add to destination target.
- IgfsListingEntry entry = srcTargetInfo.listing().get(srcName);
+ // Actual move: remove from source parent and add to destination target.
+ IgfsFileInfo srcParentInfo = lockInfos.get(srcPathIds.lastParentId());
- transferEntry(entry, srcTargetId, srcName, dstTargetId, dstName);
+ IgfsFileInfo srcInfo = lockInfos.get(srcPathIds.lastId());
+ String srcName = srcPathIds.lastPart();
+ IgfsListingEntry srcEntry = srcParentInfo.listing().get(srcName);
- tx.commit();
+ transferEntry(srcEntry, srcParentInfo.id(), srcName, dstParentInfo.id(), dstName);
- IgfsPath realNewPath = new IgfsPath(dstDirPath, dstName);
+ tx.commit();
- IgfsFileInfo moved = allInfos.get(srcPathIds.get(srcPathIds.size() - 1));
+ IgfsPath newPath = new IgfsPath(dstPathIds.path(), dstName);
// Set the new path to the info to simplify event creation:
- return IgfsFileInfo.builder(moved).path(realNewPath).build();
+ return IgfsFileInfo.builder(srcInfo).path(newPath).build();
}
finally {
tx.close();
@@ -1117,72 +1134,57 @@ public class IgfsMetaManager extends IgfsManager {
try {
validTxState(false);
- final SortedSet<IgniteUuid> allIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
+ IgfsPathIds pathIds = pathIds(path);
- List<IgniteUuid> pathIdList = fileIds(path);
-
- assert pathIdList.size() > 1;
+ // Continue only if the whole path present.
+ if (!pathIds.allExists())
+ return null; // A fragment of the path no longer exists.
- final IgniteUuid victimId = pathIdList.get(pathIdList.size() - 1);
+ IgniteUuid victimId = pathIds.lastId();
+ String victimName = pathIds.lastPart();
- assert !IgfsUtils.isRootOrTrashId(victimId) : "Cannot delete root or trash directories.";
+ if (IgfsUtils.isRootId(victimId))
+ throw new IgfsException("Cannot remove root directory");
- allIds.addAll(pathIdList);
+ // Prepare IDs to lock.
+ SortedSet<IgniteUuid> allIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
- if (allIds.remove(null))
- return null; // A fragment of the path no longer exists.
+ pathIds.addExistingIds(allIds);
IgniteUuid trashId = IgfsUtils.randomTrashId();
- boolean added = allIds.add(trashId);
- assert added;
+ allIds.add(trashId);
- final IgniteInternalTx tx = startTx();
+ IgniteInternalTx tx = startTx();
try {
- final Map<IgniteUuid, IgfsFileInfo> infoMap = lockIds(allIds);
+ // Lock participants.
+ Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(allIds);
- // Directory starure was changed concurrently, so the original path no longer exists:
- if (!verifyPathIntegrity(path, pathIdList, infoMap))
+ // Ensure that all participants are still in place.
+ if (!pathIds.verifyIntegrity(lockInfos))
return null;
- final IgfsFileInfo victimInfo = infoMap.get(victimId);
+ IgfsFileInfo victimInfo = lockInfos.get(victimId);
+ // Cannot delete non-empty directory if recursive flag is not set.
if (!recursive && victimInfo.hasChildren())
- // Throw exception if not empty and not recursive.
throw new IgfsDirectoryNotEmptyException("Failed to remove directory (directory is not " +
"empty and recursive flag is not set).");
- IgfsFileInfo destInfo = infoMap.get(trashId);
-
- assert destInfo != null;
+ // Prepare trash data.
+ IgfsFileInfo trashInfo = lockInfos.get(trashId);
+ final String trashName = victimId.toString();
- final String srcFileName = path.name();
+ assert !trashInfo.hasChild(trashName) : "Failed to add file name into the " +
+ "destination directory (file already exists) [destName=" + trashName + ']';
- final String destFileName = victimId.toString();
+ IgniteUuid parentId = pathIds.lastParentId();
+ IgfsFileInfo parentInfo = lockInfos.get(parentId);
- assert !destInfo.hasChild(destFileName) : "Failed to add file name into the " +
- "destination directory (file already exists) [destName=" + destFileName + ']';
-
- IgfsFileInfo srcParentInfo = infoMap.get(pathIdList.get(pathIdList.size() - 2));
-
- assert srcParentInfo != null;
-
- IgniteUuid srcParentId = srcParentInfo.id();
- assert srcParentId.equals(pathIdList.get(pathIdList.size() - 2));
-
- IgfsListingEntry srcEntry = srcParentInfo.listing().get(srcFileName);
-
- assert srcEntry != null : "Deletion victim not found in parent listing [path=" + path +
- ", name=" + srcFileName + ", listing=" + srcParentInfo.listing() + ']';
-
- assert victimId.equals(srcEntry.fileId());
-
- transferEntry(srcEntry, srcParentId, srcFileName, trashId, destFileName);
+ transferEntry(parentInfo.listing().get(victimName), parentId, victimName, trashId, trashName);
if (victimInfo.isFile())
- // Update a file info of the removed file with a file path,
- // which will be used by delete worker for event notifications.
invokeUpdatePath(victimId, path);
tx.commit();
@@ -1647,74 +1649,57 @@ public class IgfsMetaManager extends IgfsManager {
*
* @param path The path to create.
* @param props The properties to use for created directories.
- * @return True iff a directory was created during the operation.
+ * @return True if a directory was created during the operation.
* @throws IgniteCheckedException If a non-directory file exists on the requested path, and in case of other errors.
*/
boolean mkdirs(final IgfsPath path, final Map<String, String> props) throws IgniteCheckedException {
- assert props != null;
validTxState(false);
- DirectoryChainBuilder b = null;
-
while (true) {
if (busyLock.enterBusy()) {
try {
- b = new DirectoryChainBuilder(path, props);
+ // Prepare path IDs.
+ IgfsPathIds pathIds = pathIds(path);
+
+ // Prepare lock IDs. Essentially, they consist of two parts: existing IDs and potential new IDs.
+ Set<IgniteUuid> lockIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
+
+ pathIds.addExistingIds(lockIds);
+ pathIds.addSurrogateIds(lockIds);
+
+ assert lockIds.size() == pathIds.count();
// Start TX.
IgniteInternalTx tx = startTx();
try {
- final Map<IgniteUuid, IgfsFileInfo> lockedInfos = lockIds(b.idSet);
+ final Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(lockIds);
- // If the path was changed, we close the current Tx and repeat the procedure again
- // starting from taking the path ids.
- if (verifyPathIntegrity(b.existingPath, b.idList, lockedInfos)) {
- // Locked path okay, trying to proceed with the remainder creation.
- IgfsFileInfo lowermostExistingInfo = lockedInfos.get(b.lowermostExistingId);
+ if (!pathIds.verifyIntegrity(lockInfos))
+ // Directory structure changed concurrently. So we simply re-try.
+ continue;
- // Check only the lowermost directory in the existing directory chain
- // because others are already checked in #verifyPathIntegrity() above.
- if (!lowermostExistingInfo.isDirectory())
+ // Check if the whole structure is already in place.
+ if (pathIds.allExists()) {
+ if (lockInfos.get(pathIds.lastExistingId()).isDirectory())
+ return false;
+ else
throw new IgfsParentNotDirectoryException("Failed to create directory (parent " +
"element is not a directory)");
+ }
- if (b.existingIdCnt == b.components.size() + 1) {
- assert b.existingPath.equals(path);
- assert lockedInfos.size() == b.existingIdCnt;
-
- // The target directory already exists, nothing to do.
- // (The fact that all the path consisns of directories is already checked above).
- // Note that properties are not updated in this case.
- return false;
- }
-
- Map<String, IgfsListingEntry> parentListing = lowermostExistingInfo.listing();
-
- String shortName = b.components.get(b.existingIdCnt - 1);
-
- IgfsListingEntry entry = parentListing.get(shortName);
+ IgfsPathsCreateResult res = createDirectory(pathIds, lockInfos, props);
- if (entry == null) {
- b.doBuild();
+ if (res == null)
+ continue;
- tx.commit();
+ // Commit TX.
+ tx.commit();
- break;
- }
- else {
- // Another thread created file or directory with the same name.
- if (!entry.isDirectory()) {
- // Entry exists, and it is not a directory:
- throw new IgfsParentNotDirectoryException("Failed to create directory (parent " +
- "element is not a directory)");
- }
+ generateCreateEvents(res.createdPaths(), false);
- // If this is a directory, we continue the repeat loop,
- // because we cannot lock this directory without
- // lock ordering rule violation.
- }
- }
+ // We are done.
+ return true;
}
finally {
tx.close();
@@ -1727,12 +1712,6 @@ public class IgfsMetaManager extends IgfsManager {
else
throw new IllegalStateException("Failed to mkdir because Grid is stopping. [path=" + path + ']');
}
-
- assert b != null;
-
- b.sendEvents();
-
- return true;
}
/**
@@ -1960,11 +1939,12 @@ public class IgfsMetaManager extends IgfsManager {
parentInfo = synchronize(fs, parentPath, parentInfo, parent0, true, null);
// Fire notification about missing directories creation.
- if (evts.isRecordable(EVT_IGFS_DIR_CREATED)) {
+ if (evts.isRecordable(EventType.EVT_IGFS_DIR_CREATED)) {
IgfsPath evtPath = parent0;
while (!parentPath.equals(evtPath)) {
- pendingEvts.addFirst(new IgfsEvent(evtPath, locNode, EVT_IGFS_DIR_CREATED));
+ pendingEvts.addFirst(new IgfsEvent(evtPath, locNode,
+ EventType.EVT_IGFS_DIR_CREATED));
evtPath = evtPath.parent();
@@ -2010,8 +1990,8 @@ public class IgfsMetaManager extends IgfsManager {
}
// Record CREATE event if needed.
- if (evts.isRecordable(EVT_IGFS_FILE_CREATED))
- pendingEvts.add(new IgfsEvent(path, locNode, EVT_IGFS_FILE_CREATED));
+ if (evts.isRecordable(EventType.EVT_IGFS_FILE_CREATED))
+ pendingEvts.add(new IgfsEvent(path, locNode, EventType.EVT_IGFS_FILE_CREATED));
return new IgfsSecondaryOutputStreamDescriptor(parentInfo.id(), newInfo, out);
}
@@ -2285,11 +2265,11 @@ public class IgfsMetaManager extends IgfsManager {
synchronize(fs, parentPath, parentPathInfo, path, true, null);
- if (evts.isRecordable(EVT_IGFS_DIR_CREATED)) {
+ if (evts.isRecordable(EventType.EVT_IGFS_DIR_CREATED)) {
IgfsPath evtPath = path;
while (!parentPath.equals(evtPath)) {
- pendingEvts.addFirst(new IgfsEvent(evtPath, locNode, EVT_IGFS_DIR_CREATED));
+ pendingEvts.addFirst(new IgfsEvent(evtPath, locNode, EventType.EVT_IGFS_DIR_CREATED));
evtPath = evtPath.parent();
@@ -2386,15 +2366,15 @@ public class IgfsMetaManager extends IgfsManager {
// Record event if needed.
if (srcInfo.isFile()) {
- if (evts.isRecordable(EVT_IGFS_FILE_RENAMED))
+ if (evts.isRecordable(EventType.EVT_IGFS_FILE_RENAMED))
pendingEvts.add(new IgfsEvent(
src,
destInfo == null ? dest : new IgfsPath(dest, src.name()),
locNode,
- EVT_IGFS_FILE_RENAMED));
+ EventType.EVT_IGFS_FILE_RENAMED));
}
- else if (evts.isRecordable(EVT_IGFS_DIR_RENAMED))
- pendingEvts.add(new IgfsEvent(src, dest, locNode, EVT_IGFS_DIR_RENAMED));
+ else if (evts.isRecordable(EventType.EVT_IGFS_DIR_RENAMED))
+ pendingEvts.add(new IgfsEvent(src, dest, locNode, EventType.EVT_IGFS_DIR_RENAMED));
return true;
}
@@ -2896,7 +2876,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Transaction.
*/
private IgniteInternalTx startTx() {
- return metaCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
+ return metaCache.txStartEx(TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
}
/**
@@ -3178,6 +3158,14 @@ public class IgfsMetaManager extends IgfsManager {
private IgfsListingEntry entry;
/**
+ * Empty constructor required for {@link Externalizable}.
+ *
+ */
+ public ListingAddProcessor() {
+ // No-op.
+ }
+
+ /**
* Constructs update directory listing closure.
*
* @param fileName File name to add into parent listing.
@@ -3191,19 +3179,10 @@ public class IgfsMetaManager extends IgfsManager {
this.entry = entry;
}
- /**
- * Empty constructor required for {@link Externalizable}.
- *
- */
- public ListingAddProcessor() {
- // No-op.
- }
-
/** {@inheritDoc} */
@Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> e, Object... args) {
IgfsFileInfo fileInfo = e.getValue();
- assert fileInfo != null : "File info not found for the child: " + entry.fileId();
assert fileInfo.isDirectory();
Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
@@ -3240,6 +3219,73 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
+ * Listing replace processor.
+ */
+ private static final class ListingReplaceProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Name. */
+ private String name;
+
+ /** New ID. */
+ private IgniteUuid id;
+
+ /**
+ * Constructor.
+ */
+ public ListingReplaceProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param name Name.
+ * @param id ID.
+ */
+ public ListingReplaceProcessor(String name, IgniteUuid id) {
+ this.name = name;
+ this.id = id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> e, Object... args)
+ throws EntryProcessorException {
+ IgfsFileInfo fileInfo = e.getValue();
+
+ assert fileInfo.isDirectory();
+
+ Map<String, IgfsListingEntry> listing = new HashMap<>(fileInfo.listing());
+
+ // Modify listing in-place.
+ IgfsListingEntry oldEntry = listing.get(name);
+
+ if (oldEntry == null)
+ throw new IgniteException("Directory listing doesn't contain expected entry: " + name);
+
+ listing.put(name, new IgfsListingEntry(id, oldEntry.isDirectory()));
+
+ e.setValue(new IgfsFileInfo(listing, fileInfo));
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeString(out, name);
+ out.writeObject(id);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ name = U.readString(in);
+ id = (IgniteUuid)in.readObject();
+ }
+ }
+
+ /**
* Update path closure.
*/
@GridInternal
@@ -3291,170 +3337,92 @@ public class IgfsMetaManager extends IgfsManager {
}
/**
- * Create a new file.
+ * Append routine.
*
* @param path Path.
- * @param bufSize Buffer size.
- * @param overwrite Overwrite flag.
+ * @param dirProps Directory properties.
+ * @param create Create flag.
+ * @param blockSize Block size.
* @param affKey Affinity key.
- * @param replication Replication factor.
- * @param props Properties.
- * @param simpleCreate Whether new file should be created in secondary FS using create(Path, boolean) method.
- * @return Tuple containing the created file info and its parent id.
+ * @param evictExclude Evict exclude flag.
+ * @param fileProps File properties.
+ * @return Tuple containing the file info and its parent id.
+ * @throws IgniteCheckedException If failed.
*/
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> create(
+ IgniteBiTuple<IgfsFileInfo, IgniteUuid> append(
final IgfsPath path,
- final boolean append,
- final boolean overwrite,
Map<String, String> dirProps,
+ final boolean create,
final int blockSize,
final @Nullable IgniteUuid affKey,
final boolean evictExclude,
@Nullable Map<String, String> fileProps) throws IgniteCheckedException {
validTxState(false);
- assert path != null;
-
- final String name = path.name();
-
- DirectoryChainBuilder b = null;
-
- IgniteUuid trashId = IgfsUtils.randomTrashId();
-
while (true) {
if (busyLock.enterBusy()) {
try {
- b = new DirectoryChainBuilder(path, dirProps, fileProps, blockSize, affKey, evictExclude);
-
- // Start Tx:
- IgniteInternalTx tx = startTx();
-
- try {
- if (overwrite)
- // Lock also the TRASH directory because in case of overwrite we
- // may need to delete the old file:
- b.idSet.add(trashId);
-
- final Map<IgniteUuid, IgfsFileInfo> lockedInfos = lockIds(b.idSet);
-
- assert !overwrite || lockedInfos.get(trashId) != null; // TRASH must exist at this point.
-
- // If the path was changed, we close the current Tx and repeat the procedure again
- // starting from taking the path ids.
- if (verifyPathIntegrity(b.existingPath, b.idList, lockedInfos)) {
- // Locked path okay, trying to proceed with the remainder creation.
- final IgfsFileInfo lowermostExistingInfo = lockedInfos.get(b.lowermostExistingId);
+ // Prepare path IDs.
+ IgfsPathIds pathIds = pathIds(path);
- if (b.existingIdCnt == b.components.size() + 1) {
- // Full requestd path exists.
+ // Fail-fast: create flag is not specified and some paths are missing.
+ if (!pathIds.allExists() && !create)
+ throw new IgfsPathNotFoundException("Failed to append because file is not found: " + path);
- assert b.existingPath.equals(path);
- assert lockedInfos.size() ==
- (overwrite ? b.existingIdCnt + 1/*TRASH*/ : b.existingIdCnt);
-
- if (lowermostExistingInfo.isDirectory()) {
- throw new IgfsPathAlreadyExistsException("Failed to "
- + (append ? "open" : "create") + " file (path points to an " +
- "existing directory): " + path);
- }
- else {
- // This is a file.
- assert lowermostExistingInfo.isFile();
-
- final IgniteUuid parentId = b.idList.get(b.idList.size() - 2);
-
- final IgniteUuid lockId = lowermostExistingInfo.lockId();
-
- if (append) {
- if (lockId != null)
- throw fsException("Failed to open file (file is opened for writing) "
- + "[fileName=" + name + ", fileId=" + lowermostExistingInfo.id()
- + ", lockId=" + lockId + ']');
-
- IgfsFileInfo lockedInfo = invokeLock(lowermostExistingInfo.id(), false);
-
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(lockedInfo, parentId);
-
- tx.commit();
-
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), path,
- EventType.EVT_IGFS_FILE_OPENED_WRITE);
-
- return t2;
- }
- else if (overwrite) {
- // Delete existing file, but fail if it is locked:
- if (lockId != null)
- throw fsException("Failed to overwrite file (file is opened for writing) " +
- "[fileName=" + name + ", fileId=" + lowermostExistingInfo.id()
- + ", lockId=" + lockId + ']');
+ // Prepare lock IDs.
+ Set<IgniteUuid> lockIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
- final IgfsListingEntry deletedEntry = lockedInfos.get(parentId).listing()
- .get(name);
+ pathIds.addExistingIds(lockIds);
+ pathIds.addSurrogateIds(lockIds);
- assert deletedEntry != null;
-
- transferEntry(deletedEntry, parentId, name, trashId,
- lowermostExistingInfo.id().toString());
-
- // Update a file info of the removed file with a file path,
- // which will be used by delete worker for event notifications.
- invokeUpdatePath(lowermostExistingInfo.id(), path);
-
- // Make a new locked info:
- long t = System.currentTimeMillis();
-
- final IgfsFileInfo newFileInfo = new IgfsFileInfo(cfg.getBlockSize(), 0L,
- affKey, createFileLockId(false), evictExclude, fileProps, t, t);
-
- assert newFileInfo.lockId() != null; // locked info should be created.
-
- createNewEntry(newFileInfo, parentId, name);
-
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(newFileInfo, parentId);
+ // Start TX.
+ IgniteInternalTx tx = startTx();
- tx.commit();
+ try {
+ Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(lockIds);
- delWorker.signal();
+ if (!pathIds.verifyIntegrity(lockInfos))
+ // Directory structure changed concurrently. So we simply re-try.
+ continue;
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_FILE_OPENED_WRITE);
+ if (pathIds.allExists()) {
+ // All participants are found. Simply open the stream.
+ IgfsFileInfo info = lockInfos.get(pathIds.lastId());
- return t2;
- }
- else {
- throw new IgfsPathAlreadyExistsException("Failed to create file (file " +
- "already exists and overwrite flag is false): " + path);
- }
- }
- }
+ // Check: is it a file?
+ if (!info.isFile())
+ throw new IgfsPathIsDirectoryException("Failed to open file for write." + path);
- // The full requested path does not exist.
+ // Check if file already opened for write.
+ if (info.lockId() != null)
+ throw new IgfsException("File is already opened for write: " + path);
- // Check only the lowermost directory in the existing directory chain
- // because others are already checked in #verifyPathIntegrity() above.
- if (!lowermostExistingInfo.isDirectory())
- throw new IgfsParentNotDirectoryException("Failed to " + (append ? "open" : "create" )
- + " file (parent element is not a directory)");
+ // At this point we can open the stream safely.
+ info = invokeLock(info.id(), false);
- final String uppermostFileToBeCreatedName = b.components.get(b.existingIdCnt - 1);
+ IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(info, pathIds.lastParentId());
- if (!lowermostExistingInfo.hasChild(uppermostFileToBeCreatedName)) {
- b.doBuild();
+ tx.commit();
- assert b.leafInfo != null;
- assert b.leafParentId != null;
+ IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EventType.EVT_IGFS_FILE_OPENED_WRITE);
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(b.leafInfo, b.leafParentId);
+ return t2;
+ }
+ else {
+ // Create file and parent folders.
+ IgfsPathsCreateResult res =
+ createFile(pathIds, lockInfos, dirProps, fileProps, blockSize, affKey, evictExclude);
- tx.commit();
+ if (res == null)
+ continue;
- b.sendEvents();
+ // Commit.
+ tx.commit();
- return t2;
- }
+ // Generate events.
+ generateCreateEvents(res.createdPaths(), true);
- // Another thread concurrently created file or directory in the path with
- // the name we need.
+ return new T2<>(res.info(), res.parentId());
}
}
finally {
@@ -3464,224 +3432,292 @@ public class IgfsMetaManager extends IgfsManager {
finally {
busyLock.leaveBusy();
}
- } else
- throw new IllegalStateException("Failed to mkdir because Grid is stopping. [path=" + path + ']');
+ }
+ else
+ throw new IllegalStateException("Failed to append for file because Grid is stopping:" + path);
}
}
- /** File chain builder. */
- private class DirectoryChainBuilder {
- /** The requested path to be created. */
- private final IgfsPath path;
+ /**
+ * Create a new file.
+ *
+ * @param path Path.
+ * @param bufSize Buffer size.
+ * @param overwrite Overwrite flag.
+ * @param affKey Affinity key.
+ * @param replication Replication factor.
+ * @param props Properties.
+ * @param simpleCreate Whether new file should be created in secondary FS using create(Path, boolean) method.
+ * @return Tuple containing the created file info and its parent id.
+ */
+ IgniteBiTuple<IgfsFileInfo, IgniteUuid> create(
+ final IgfsPath path,
+ Map<String, String> dirProps,
+ final boolean overwrite,
+ final int blockSize,
+ final @Nullable IgniteUuid affKey,
+ final boolean evictExclude,
+ @Nullable Map<String, String> fileProps) throws IgniteCheckedException {
+ validTxState(false);
- /** Full path components. */
- private final List<String> components;
+ while (true) {
+ if (busyLock.enterBusy()) {
+ try {
+ // Prepare path IDs.
+ IgfsPathIds pathIds = pathIds(path);
- /** The list of ids. */
- private final List<IgniteUuid> idList;
+ // Prepare lock IDs.
+ Set<IgniteUuid> lockIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
- /** The set of ids. */
- private final SortedSet<IgniteUuid> idSet = new TreeSet<IgniteUuid>(PATH_ID_SORTING_COMPARATOR);
+ pathIds.addExistingIds(lockIds);
+ pathIds.addSurrogateIds(lockIds);
- /** The middle node properties. */
- private final Map<String, String> props;
+ // In overwrite mode we also lock ID of potential replacement as well as trash ID.
+ IgniteUuid overwriteId = IgniteUuid.randomUuid();
+ IgniteUuid trashId = IgfsUtils.randomTrashId();
- /** The leaf node properties. */
- private final Map<String, String> leafProps;
+ if (overwrite) {
+ lockIds.add(overwriteId);
- /** The lowermost exsiting path id. */
- private final IgniteUuid lowermostExistingId;
+ // Trash ID is only added if we suspect conflict.
+ if (pathIds.allExists())
+ lockIds.add(trashId);
+ }
- /** The existing path. */
- private final IgfsPath existingPath;
+ // Start TX.
+ IgniteInternalTx tx = startTx();
- /** The created leaf info. */
- private IgfsFileInfo leafInfo;
+ try {
+ Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(lockIds);
- /** The leaf parent id. */
- private IgniteUuid leafParentId;
+ if (!pathIds.verifyIntegrity(lockInfos))
+ // Directory structure changed concurrently. So we simply re-try.
+ continue;
- /** The number of existing ids. */
- private final int existingIdCnt;
+ if (pathIds.allExists()) {
+ // All participants found.
+ IgfsFileInfo oldInfo = lockInfos.get(pathIds.lastId());
- /** Whether laef is directory. */
- private final boolean leafDir;
+ // Check: is it a file?
+ if (!oldInfo.isFile())
+ throw new IgfsPathIsDirectoryException("Failed to create a file: " + path);
- /** Block size. */
- private final int blockSize;
+ // Check: can we overwrite it?
+ if (!overwrite)
+ throw new IgfsPathAlreadyExistsException("Failed to create a file: " + path);
- /** Affinity key. */
- private final IgniteUuid affKey;
+ // Check if file already opened for write.
+ if (oldInfo.lockId() != null)
+ throw new IgfsException("File is already opened for write: " + path);
- /** Evict exclude flag. */
- private final boolean evictExclude;
+ // At this point file can be re-created safely.
- /**
- * Constructor for directories.
- *
- * @param path Path.
- * @param props Properties.
- * @throws IgniteCheckedException If failed.
- */
- protected DirectoryChainBuilder(IgfsPath path, Map<String, String> props) throws IgniteCheckedException {
- this(path, props, props, true, 0, null, false);
- }
+ // First step: add existing to trash listing.
+ IgniteUuid oldId = pathIds.lastId();
- /**
- * Constructor for files.
- *
- * @param path Path.
- * @param dirProps Directory properties.
- * @param fileProps File properties.
- * @param blockSize Block size.
- * @param affKey Affinity key (optional).
- * @param evictExclude Evict exclude flag.
- * @throws IgniteCheckedException If failed.
- */
- protected DirectoryChainBuilder(IgfsPath path, Map<String, String> dirProps, Map<String, String> fileProps,
- int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude)
- throws IgniteCheckedException {
- this(path, dirProps, fileProps, false, blockSize, affKey, evictExclude);
- }
+ id2InfoPrj.invoke(trashId, new ListingAddProcessor(oldId.toString(),
+ new IgfsListingEntry(oldId, true)));
- /**
- * Constructor.
- *
- * @param path Path.
- * @param props Middle properties.
- * @param leafProps Leaf properties.
- * @param leafDir Whether leaf is directory or file.
- * @param blockSize Block size.
- * @param affKey Affinity key (optional).
- * @param evictExclude Evict exclude flag.
- * @throws IgniteCheckedException If failed.
- */
- private DirectoryChainBuilder(IgfsPath path, Map<String,String> props, Map<String,String> leafProps,
- boolean leafDir, int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude)
- throws IgniteCheckedException {
- this.path = path;
- this.components = path.components();
- this.idList = fileIds(path);
- this.props = props;
- this.leafProps = leafProps;
- this.leafDir = leafDir;
- this.blockSize = blockSize;
- this.affKey = affKey;
- this.evictExclude = evictExclude;
+ // Second step: replace ID in parent directory.
+ String name = pathIds.lastPart();
+ IgniteUuid parentId = pathIds.lastParentId();
- // Store all the non-null ids in the set & construct existing path in one loop:
- IgfsPath existingPath = path.root();
+ id2InfoPrj.invoke(parentId, new ListingReplaceProcessor(name, overwriteId));
- assert idList.size() == components.size() + 1;
+ // Third step: create the file.
+ long createTime = System.currentTimeMillis();
- // Find the lowermost existing id:
- IgniteUuid lowermostExistingId = null;
+ IgfsFileInfo newInfo = invokeAndGet(overwriteId, new FileCreateProcessor(createTime,
+ fileProps, blockSize, affKey, createFileLockId(false), evictExclude));
- int idIdx = 0;
+ // Fourth step: update path of remove file.
+ invokeUpdatePath(oldId, path);
- for (IgniteUuid id : idList) {
- if (id == null)
- break;
+ // Prepare result and commit.
+ IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(newInfo, parentId);
- lowermostExistingId = id;
+ tx.commit();
- boolean added = idSet.add(id);
+ IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EventType.EVT_IGFS_FILE_OPENED_WRITE);
- assert added : "Not added id = " + id;
+ return t2;
+ }
+ else {
+ // Create file and parent folders.
+ IgfsPathsCreateResult res =
+ createFile(pathIds, lockInfos, dirProps, fileProps, blockSize, affKey, evictExclude);
- if (idIdx >= 1) // skip root.
- existingPath = new IgfsPath(existingPath, components.get(idIdx - 1));
+ if (res == null)
+ continue;
- idIdx++;
- }
+ // Commit.
+ tx.commit();
- assert idSet.contains(IgfsUtils.ROOT_ID);
+ // Generate events.
+ generateCreateEvents(res.createdPaths(), true);
- this.lowermostExistingId = lowermostExistingId;
+ return new T2<>(res.info(), res.parentId());
+ }
+ }
+ finally {
+ tx.close();
+ }
+ }
+ finally {
+ busyLock.leaveBusy();
+ }
+ }
+ else
+ throw new IllegalStateException("Failed to mkdir because Grid is stopping. [path=" + path + ']');
+ }
+ }
- this.existingPath = existingPath;
+ /**
+ * Create directory and it's parents.
+ *
+ * @param pathIds Path IDs.
+ * @param lockInfos Lock infos.
+ * @param dirProps Directory properties.
+ * @return Result or {@code} if the first parent already contained child with the same name.
+ * @throws IgniteCheckedException If failed.
+ */
+ @Nullable IgfsPathsCreateResult createDirectory(IgfsPathIds pathIds, Map<IgniteUuid, IgfsFileInfo> lockInfos,
+ Map<String, String> dirProps) throws IgniteCheckedException {
+ // Check if entry we are going to write to is directory.
+ if (lockInfos.get(pathIds.lastExistingId()).isFile())
+ throw new IgfsParentNotDirectoryException("Failed to create directory (parent " +
+ "element is not a directory)");
+
+ return createFileOrDirectory(true, pathIds, lockInfos, dirProps, null, 0, null, false);
+ }
- this.existingIdCnt = idSet.size();
- }
+ /**
+ * Create file and all it's parents.
+ *
+ * @param pathIds Paths IDs.
+ * @param lockInfos Lock infos.
+ * @param dirProps Directory properties.
+ * @param fileProps File propertris.
+ * @param blockSize Block size.
+ * @param affKey Affinity key (optional)
+ * @param evictExclude Evict exclude flag.
+ * @return Result or {@code} if the first parent already contained child with the same name.
+ * @throws IgniteCheckedException If failed.
+ */
+ @Nullable private IgfsPathsCreateResult createFile(IgfsPathIds pathIds, Map<IgniteUuid, IgfsFileInfo> lockInfos,
+ Map<String, String> dirProps, Map<String, String> fileProps, int blockSize, @Nullable IgniteUuid affKey,
+ boolean evictExclude) throws IgniteCheckedException{
+ // Check if entry we are going to write to is directory.
+ if (lockInfos.get(pathIds.lastExistingId()).isFile())
+ throw new IgfsParentNotDirectoryException("Failed to open file for write " +
+ "(parent element is not a directory): " + pathIds.path());
+
+ return createFileOrDirectory(false, pathIds, lockInfos, dirProps, fileProps, blockSize, affKey, evictExclude);
+ }
- /**
- * Does the main portion of job building the renmaining path.
- */
- public final void doBuild() throws IgniteCheckedException {
- // Fix current time. It will be used in all created entities.
- long createTime = System.currentTimeMillis();
+ /**
+ * Ceate file or directory.
+ *
+ * @param dir Directory flag.
+ * @param pathIds Path IDs.
+ * @param lockInfos Lock infos.
+ * @param dirProps Directory properties.
+ * @param fileProps File properties.
+ * @param blockSize Block size.
+ * @param affKey Affinity key.
+ * @param evictExclude Evict exclude flag.
+ * @return Result.
+ * @throws IgniteCheckedException If failed.
+ */
+ private IgfsPathsCreateResult createFileOrDirectory(boolean dir, IgfsPathIds pathIds,
+ Map<IgniteUuid, IgfsFileInfo> lockInfos, Map<String, String> dirProps, Map<String, String> fileProps,
+ int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude) throws IgniteCheckedException {
+ // This is our starting point.
+ int lastExistingIdx = pathIds.lastExistingIndex();
+ IgfsFileInfo lastExistingInfo = lockInfos.get(pathIds.lastExistingId());
+
+ // If current info already contains entry with the same name as it's child, then something
+ // has changed concurrently. We must re-try because we cannot get info of this unexpected
+ // element due to possible deadlocks.
+ int curIdx = lastExistingIdx + 1;
+
+ String curPart = pathIds.part(curIdx);
+ IgniteUuid curId = pathIds.surrogateId(curIdx);
+ IgniteUuid curParentId = lastExistingInfo.id();
+
+ if (lastExistingInfo.hasChild(curPart))
+ return null;
- IgfsListingEntry childInfo = null;
- String childName = null;
+ // First step: add new entry to the last existing element.
+ id2InfoPrj.invoke(lastExistingInfo.id(), new ListingAddProcessor(curPart,
+ new IgfsListingEntry(curId, dir || !pathIds.isLastIndex(curIdx))));
- IgniteUuid parentId = null;
+ // Events support.
+ IgfsPath lastCreatedPath = pathIds.lastExistingPath();
- // This loop creates the missing directory chain from the bottom to the top:
- for (int i = components.size() - 1; i >= existingIdCnt - 1; i--) {
- IgniteUuid childId = IgniteUuid.randomUuid();
- boolean childDir;
+ List<IgfsPath> createdPaths = new ArrayList<>(pathIds.count() - curIdx);
- if (childName == null) {
- assert childInfo == null;
+ // Second step: create middle directories.
+ long createTime = System.currentTimeMillis();
- if (leafDir) {
- childDir = true;
+ while (curIdx < pathIds.count() - 1) {
+ int nextIdx = curIdx + 1;
- leafInfo = invokeAndGet(childId, new DirectoryCreateProcessor(createTime, leafProps));
- }
- else {
- childDir = false;
+ String nextPart = pathIds.part(nextIdx);
+ IgniteUuid nextId = pathIds.surrogateId(nextIdx);
- leafInfo = invokeAndGet(childId, new FileCreateProcessor(createTime, leafProps, blockSize,
- affKey, createFileLockId(false), evictExclude));
- }
- }
- else {
- assert childInfo != null;
+ id2InfoPrj.invoke(curId, new DirectoryCreateProcessor(createTime, dirProps,
+ nextPart, new IgfsListingEntry(nextId, dir || !pathIds.isLastIndex(nextIdx))));
- childDir = true;
+ // Save event.
+ lastCreatedPath = new IgfsPath(lastCreatedPath, curPart);
- id2InfoPrj.invoke(childId, new DirectoryCreateProcessor(createTime, props, childName, childInfo));
+ createdPaths.add(lastCreatedPath);
- if (parentId == null)
- parentId = childId;
- }
+ // Advance things further.
+ curIdx++;
- childInfo = new IgfsListingEntry(childId, childDir);
+ curParentId = curId;
- childName = components.get(i);
- }
+ curPart = nextPart;
+ curId = nextId;
+ }
- if (parentId == null)
- parentId = lowermostExistingId;
+ // Third step: create leaf.
+ IgfsFileInfo info;
- leafParentId = parentId;
+ if (dir)
+ info = invokeAndGet(curId, new DirectoryCreateProcessor(createTime, dirProps));
+ else
+ info = invokeAndGet(curId, new FileCreateProcessor(createTime, fileProps,
+ blockSize, affKey, createFileLockId(false), evictExclude));
- // Now link the newly created directory chain to the lowermost existing parent:
- id2InfoPrj.invoke(lowermostExistingId, new ListingAddProcessor(childName, childInfo));
- }
+ createdPaths.add(pathIds.path());
- /**
- * Sends events.
- */
- public final void sendEvents() {
- if (evts.isRecordable(EVT_IGFS_DIR_CREATED)) {
- IgfsPath createdPath = existingPath;
+ return new IgfsPathsCreateResult(createdPaths, info, curParentId);
+ }
- for (int i = existingPath.components().size(); i < components.size() - 1; i++) {
- createdPath = new IgfsPath(createdPath, components.get(i));
+ /**
+ * Generate events for created file or directory.
+ *
+ * @param createdPaths Created paths.
+ * @param file Whether file was created.
+ */
+ private void generateCreateEvents(List<IgfsPath> createdPaths, boolean file) {
+ if (evts.isRecordable(EventType.EVT_IGFS_DIR_CREATED)) {
+ for (int i = 0; i < createdPaths.size() - 1; i++)
+ IgfsUtils.sendEvents(igfsCtx.kernalContext(), createdPaths.get(i),
+ EventType.EVT_IGFS_DIR_CREATED);
+ }
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), createdPath, EVT_IGFS_DIR_CREATED);
- }
- }
+ IgfsPath leafPath = createdPaths.get(createdPaths.size() - 1);
- if (leafDir)
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_DIR_CREATED);
- else {
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_FILE_CREATED);
- IgfsUtils.sendEvents(igfsCtx.kernalContext(), path, EVT_IGFS_FILE_OPENED_WRITE);
- }
+ if (file) {
+ IgfsUtils.sendEvents(igfsCtx.kernalContext(), leafPath, EventType.EVT_IGFS_FILE_CREATED);
+ IgfsUtils.sendEvents(igfsCtx.kernalContext(), leafPath, EventType.EVT_IGFS_FILE_OPENED_WRITE);
}
+ else
+ IgfsUtils.sendEvents(igfsCtx.kernalContext(), leafPath, EventType.EVT_IGFS_DIR_CREATED);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a93c3bf/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
new file mode 100644
index 0000000..1f669b0
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
@@ -0,0 +1,291 @@
+/*
+ * 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.igfs.IgfsPath;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Path IDs abstraction. Contains path and corresponding IDs.
+ */
+public class IgfsPathIds {
+ /** Original path. */
+ private final IgfsPath path;
+
+ /** Path parts. */
+ private final String[] parts;
+
+ /** IDs. */
+ private final IgniteUuid[] ids;
+
+ /** Surrogate IDs for paths which doesn't exist yet. Initialized on demand. */
+ private IgniteUuid[] surrogateIds;
+
+ /** Index of last existing ID. */
+ private final int lastExistingIdx;
+
+ /**
+ * Constructor.
+ *
+ * @param path Path.
+ * @param parts Path parts.
+ * @param ids IDs.
+ */
+ public IgfsPathIds(IgfsPath path, String[] parts, IgniteUuid[] ids) {
+ assert path != null;
+ assert parts.length == ids.length;
+
+ this.path = path;
+ this.parts = parts;
+ this.ids = ids;
+
+ int lastExistingIdx0 = -1;
+
+ for (int i = parts.length - 1; i >= 0; i--) {
+ if (ids[i] != null) {
+ lastExistingIdx0 = i;
+
+ break;
+ }
+ }
+
+ assert lastExistingIdx0 >= 0;
+
+ lastExistingIdx = lastExistingIdx0;
+ }
+
+ /**
+ * Get parent entity.
+ *
+ * @return Parent entity.
+ */
+ public IgfsPathIds parent() {
+ assert ids.length > 1;
+
+ String[] parentParts = new String[parts.length - 1];
+ IgniteUuid[] parentIds = new IgniteUuid[ids.length - 1];
+
+ System.arraycopy(parts, 0, parentParts, 0, parentParts.length);
+ System.arraycopy(ids, 0, parentIds, 0, parentIds.length);
+
+ return new IgfsPathIds(path.parent(), parentParts, parentIds);
+ }
+
+ /**
+ * Get number of elements.
+ *
+ * @return ID count.
+ */
+ public int count() {
+ return ids.length;
+ }
+
+ /**
+ * Get original path.
+ *
+ * @return Path.
+ */
+ public IgfsPath path() {
+ return path;
+ }
+
+ /**
+ * Get path part at the given index.
+ *
+ * @param idx Index.
+ * @return Path part.
+ */
+ public String part(int idx) {
+ assert idx < parts.length;
+
+ return parts[idx];
+ }
+
+ /**
+ * Get last part of original path.
+ *
+ * @return Last part.
+ */
+ public String lastPart() {
+ return parts[parts.length - 1];
+ }
+
+ /**
+ * Get last ID.
+ *
+ * @return Last ID.
+ */
+ @Nullable public IgniteUuid lastId() {
+ return ids[ids.length - 1];
+ }
+
+ /**
+ * Get last parent ID.
+ *
+ * @return Last parent ID.
+ */
+ @Nullable public IgniteUuid lastParentId() {
+ return ids[ids.length - 2];
+ }
+
+ /**
+ * Whether provided index denotes last entry in the path.
+ *
+ * @param idx Index.
+ * @return {@code True} if last.
+ */
+ public boolean isLastIndex(int idx) {
+ return idx == parts.length - 1;
+ }
+
+ /**
+ * Get path of the last existing element.
+ *
+ * @return Path of the last existing element.
+ */
+ public IgfsPath lastExistingPath() {
+ IgfsPath path = new IgfsPath();
+
+ for (int i = 1; i <= lastExistingIdx; i++)
+ path = new IgfsPath(path, parts[i]);
+
+ return path;
+ }
+
+ /**
+ * Whether all parts exists.
+ *
+ * @return {@code True} if all parts were found.
+ */
+ public boolean allExists() {
+ return parts.length == lastExistingIdx + 1;
+ }
+
+ /**
+ * Whether last entry exists.
+ *
+ * @return {@code True} if exists.
+ */
+ public boolean lastExists() {
+ return lastExistingIdx == ids.length - 1;
+ }
+
+
+ /**
+ * Whether parent of the last entry exists.
+ *
+ * @return {@code True} if exists.
+ */
+ public boolean lastParentExists() {
+ return ids.length > 1 && lastExistingIdx == ids.length - 2;
+ }
+
+ /**
+ * Get ID of the last existing entry.
+ *
+ * @return ID of the last existing entry.
+ */
+ public IgniteUuid lastExistingId() {
+ return ids[lastExistingIdx];
+ }
+
+ /**
+ * Get index of the last existing entry.
+ *
+ * @return Index of the last existing entry.
+ */
+ public int lastExistingIndex() {
+ return lastExistingIdx;
+ }
+
+ /**
+ * Add existing IDs to provided collection.
+ *
+ * @param col Collection.
+ */
+ @SuppressWarnings("ManualArrayToCollectionCopy")
+ public void addExistingIds(Collection<IgniteUuid> col) {
+ for (int i = 0; i <= lastExistingIdx; i++)
+ col.add(ids[i]);
+ }
+
+ /**
+ * Add surrogate IDs to provided collection potentially creating them on demand.
+ *
+ * @param col Collection.
+ */
+ @SuppressWarnings("ManualArrayToCollectionCopy")
+ public void addSurrogateIds(Collection<IgniteUuid> col) {
+ if (surrogateIds == null) {
+ surrogateIds = new IgniteUuid[ids.length];
+
+ for (int i = lastExistingIdx + 1; i < surrogateIds.length; i++)
+ surrogateIds[i] = IgniteUuid.randomUuid();
+ }
+
+ for (int i = lastExistingIdx + 1; i < surrogateIds.length; i++)
+ col.add(surrogateIds[i]);
+ }
+
+ /**
+ * Get surrogate ID at the given index.
+ *
+ * @param idx Index.
+ * @return Surrogate ID.
+ */
+ public IgniteUuid surrogateId(int idx) {
+ assert surrogateIds != null;
+
+ assert idx > lastExistingIdx;
+ assert idx < surrogateIds.length;
+
+ return surrogateIds[idx];
+ }
+
+ /**
+ * Verify that observed paths are found in provided infos in the right order.
+ *
+ * @param infos Info.
+ * @return {@code True} if full integrity is preserved.
+ */
+ public boolean verifyIntegrity(Map<IgniteUuid, IgfsFileInfo> infos) {
+ for (int i = 0; i <= lastExistingIdx; i++) {
+ IgniteUuid curId = ids[i];
+ IgfsFileInfo curInfo = infos.get(curId);
+
+ // Check if required ID is there.
+ if (curInfo == null)
+ return false;
+
+ // For non-leaf entry we check if child exists.
+ if (i < lastExistingIdx) {
+ String childName = parts[i + 1];
+ IgniteUuid childId = ids[i + 1];
+
+ if (!curInfo.hasChild(childName, childId))
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a93c3bf/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
new file mode 100644
index 0000000..3b620f8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
@@ -0,0 +1,77 @@
+/*
+ * 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.igfs.IgfsPath;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgniteUuid;
+
+import java.util.List;
+
+/**
+ * IGFS paths create result.
+ */
+public class IgfsPathsCreateResult {
+ /** Created paths. */
+ private final List<IgfsPath> paths;
+
+ /** Info of the last created file. */
+ private final IgfsFileInfo info;
+
+ /** Parent ID. */
+ private final IgniteUuid parentId;
+
+ /**
+ * Constructor.
+ *
+ * @param paths Created paths.
+ * @param info Info of the last created file.
+ * @param parentId Parent ID.
+ */
+ public IgfsPathsCreateResult(List<IgfsPath> paths, IgfsFileInfo info, IgniteUuid parentId) {
+ this.paths = paths;
+ this.info = info;
+ this.parentId = parentId;
+ }
+
+ /**
+ * @return Created paths.
+ */
+ public List<IgfsPath> createdPaths() {
+ return paths;
+ }
+
+ /**
+ * @return Info of the last created file.
+ */
+ public IgfsFileInfo info() {
+ return info;
+ }
+
+ /**
+ * @return Parent ID.
+ */
+ public IgniteUuid parentId() {
+ return parentId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsPathsCreateResult.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a93c3bf/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index edded2f..b176e21 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -17,10 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.lang.reflect.Constructor;
-import java.util.UUID;
-import java.util.concurrent.ThreadLocalRandom;
-
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteSystemProperties;
@@ -43,6 +39,10 @@ import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.transactions.Transaction;
import org.jetbrains.annotations.Nullable;
+import java.lang.reflect.Constructor;
+import java.util.UUID;
+import java.util.concurrent.ThreadLocalRandom;
+
import static org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_RETRIES_COUNT;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
@@ -104,7 +104,17 @@ public class IgfsUtils {
* @return {@code True} if this is root ID or trash ID.
*/
public static boolean isRootOrTrashId(@Nullable IgniteUuid id) {
- return id != null && (ROOT_ID.equals(id) || isTrashId(id));
+ return isRootId(id) || isTrashId(id);
+ }
+
+ /**
+ * Check whether provided ID is root ID.
+ *
+ * @param id ID.
+ * @return {@code True} if this is root ID.
+ */
+ public static boolean isRootId(@Nullable IgniteUuid id) {
+ return id != null && ROOT_ID.equals(id);
}
/**
@@ -114,7 +124,8 @@ public class IgfsUtils {
* @return {@code True} if this is trash ID.
*/
private static boolean isTrashId(IgniteUuid id) {
- assert id != null;
+ if (id == null)
+ return false;
UUID gid = id.globalId();
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a93c3bf/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
index 52d8bd5..2acf59c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
@@ -17,27 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.Field;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
@@ -79,6 +58,28 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.jetbrains.annotations.Nullable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Random;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -1449,19 +1450,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
createCtr.incrementAndGet();
}
catch (IgniteException e) {
- Throwable[] chain = X.getThrowables(e);
-
- Throwable cause = chain[chain.length - 1];
-
- if (!e.getMessage().startsWith("Failed to overwrite file (file is opened for writing)")
- && (cause == null
- || !cause.getMessage().startsWith("Failed to overwrite file (file is opened for writing)"))) {
-
- System.out.println("Failed due to IgniteException exception. Cause:");
- cause.printStackTrace(System.out);
-
- err.compareAndSet(null, e);
- }
+ // No-op.
}
catch (IOException e) {
err.compareAndSet(null, e);
@@ -1937,15 +1926,8 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
chunksCtr.incrementAndGet();
}
- catch (IgniteException e) {
- Throwable[] chain = X.getThrowables(e);
-
- Throwable cause = chain[chain.length - 1];
-
- if (!e.getMessage().startsWith("Failed to open file (file is opened for writing)")
- && (cause == null
- || !cause.getMessage().startsWith("Failed to open file (file is opened for writing)")))
- err.compareAndSet(null, e);
+ catch (IgniteException ignore) {
+ // No-op.
}
catch (IOException e) {
err.compareAndSet(null, e);
[28/50] [abbrv] ignite git commit: IGNITE-2868: IGFS: Increased trash
concurrency from 16 to 64.
Posted by sb...@apache.org.
IGNITE-2868: IGFS: Increased trash concurrency from 16 to 64.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/218132dc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/218132dc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/218132dc
Branch: refs/heads/ignite-1837
Commit: 218132dc0c3764966294a5f29ad480af4af7b0ff
Parents: ee5ea53
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Mar 22 09:23:29 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:14:04 2016 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/218132dc/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index 7063f68..94e1cef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -65,7 +65,7 @@ public class IgfsUtils {
public static final IgniteUuid DELETE_LOCK_ID = new IgniteUuid(new UUID(0, 0), 0);
/** Constant trash concurrency level. */
- public static final int TRASH_CONCURRENCY = 16;
+ public static final int TRASH_CONCURRENCY = 64;
/** Trash directory IDs. */
private static final IgniteUuid[] TRASH_IDS;
[09/50] [abbrv] ignite git commit: IGNITE-2810: IGFS: Minor
correction to IgfsUtils.isRootOrTrashId() method.
Posted by sb...@apache.org.
IGNITE-2810: IGFS: Minor correction to IgfsUtils.isRootOrTrashId() method.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/54e6991c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/54e6991c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/54e6991c
Branch: refs/heads/ignite-1837
Commit: 54e6991cb1d0b68c4490dede603c9e3ba7cc3b9e
Parents: 37c4d50
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Mar 14 12:05:39 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:02 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsUtils.java | 22 ++++++++++----------
1 file changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/54e6991c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index 6f8960a..edded2f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -98,12 +98,22 @@ public class IgfsUtils {
}
/**
+ * Check whether provided ID is either root ID or trash ID.
+ *
+ * @param id ID.
+ * @return {@code True} if this is root ID or trash ID.
+ */
+ public static boolean isRootOrTrashId(@Nullable IgniteUuid id) {
+ return id != null && (ROOT_ID.equals(id) || isTrashId(id));
+ }
+
+ /**
* Check whether provided ID is trash ID.
*
* @param id ID.
* @return {@code True} if this is trash ID.
*/
- public static boolean isTrashId(IgniteUuid id) {
+ private static boolean isTrashId(IgniteUuid id) {
assert id != null;
UUID gid = id.globalId();
@@ -113,16 +123,6 @@ public class IgfsUtils {
}
/**
- * Check whether provided ID is either root ID or trash ID.
- *
- * @param id ID.
- * @return {@code True} if this is root ID or trash ID.
- */
- public static boolean isRootOrTrashId(IgniteUuid id) {
- return ROOT_ID.equals(id) || isTrashId(id);
- }
-
- /**
* Converts any passed exception to IGFS exception.
*
* @param err Initial exception.
[23/50] [abbrv] ignite git commit: IGNITE-2861: IGFS: Moved metadata
processors into separate top-level classes to simplify code. Also cleaned up
IgfsMetaManager from unused code.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java
new file mode 100644
index 0000000..43a5d7d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java
@@ -0,0 +1,63 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * File lock entry processor.
+ */
+public class IgfsMetaFileLockProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Lock Id. */
+ private IgniteUuid lockId;
+
+ /**
+ * Default constructor.
+ */
+ public IgfsMetaFileLockProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param lockId Lock ID.
+ */
+ public IgfsMetaFileLockProcessor(IgniteUuid lockId) {
+ this.lockId = lockId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsEntryInfo oldInfo = entry.getValue();
+
+ IgfsEntryInfo newInfo = oldInfo.lock(lockId);
+
+ entry.setValue(newInfo);
+
+ return newInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeGridUuid(out, lockId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ lockId = U.readGridUuid(in);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java
new file mode 100644
index 0000000..5af09e5
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java
@@ -0,0 +1,74 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange;
+import org.apache.ignite.internal.processors.igfs.IgfsFileMap;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgniteUuid;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * Delete range processor.
+ */
+public class IgfsMetaFileRangeDeleteProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Range. */
+ private IgfsFileAffinityRange range;
+
+ /**
+ * Constructor.
+ */
+ public IgfsMetaFileRangeDeleteProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param range Range.
+ */
+ public IgfsMetaFileRangeDeleteProcessor(IgfsFileAffinityRange range) {
+ this.range = range;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsEntryInfo oldInfo = entry.getValue();
+
+ IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
+
+ newMap.deleteRange(range);
+
+ IgfsEntryInfo newInfo = oldInfo.fileMap(newMap);
+
+ entry.setValue(newInfo);
+
+ return newInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(range);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ range = (IgfsFileAffinityRange)in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaFileRangeDeleteProcessor.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java
new file mode 100644
index 0000000..ae886c8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java
@@ -0,0 +1,81 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange;
+import org.apache.ignite.internal.processors.igfs.IgfsFileMap;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgniteUuid;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * Update range processor.
+ */
+public class IgfsMetaFileRangeUpdateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Range. */
+ private IgfsFileAffinityRange range;
+
+ /** Status. */
+ private int status;
+
+ /**
+ * Constructor.
+ */
+ public IgfsMetaFileRangeUpdateProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param range Range.
+ * @param status Status.
+ */
+ public IgfsMetaFileRangeUpdateProcessor(IgfsFileAffinityRange range, int status) {
+ this.range = range;
+ this.status = status;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsEntryInfo oldInfo = entry.getValue();
+
+ IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
+
+ newMap.updateRangeStatus(range, status);
+
+ IgfsEntryInfo newInfo = oldInfo.fileMap(newMap);
+
+ entry.setValue(newInfo);
+
+ return newInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(range);
+ out.writeInt(status);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ range = (IgfsFileAffinityRange)in.readObject();
+ status = in.readInt();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaFileRangeUpdateProcessor.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java
new file mode 100644
index 0000000..30f8e22
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java
@@ -0,0 +1,75 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsFileAffinityRange;
+import org.apache.ignite.internal.processors.igfs.IgfsFileMap;
+import org.apache.ignite.lang.IgniteUuid;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * File reserve space entry processor.
+ */
+public class IgfsMetaFileReserveSpaceProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Space. */
+ private long space;
+
+ /** Affinity range. */
+ private IgfsFileAffinityRange affRange;
+
+ /**
+ * Default constructor.
+ */
+ public IgfsMetaFileReserveSpaceProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param space Space.
+ * @param affRange
+ */
+ public IgfsMetaFileReserveSpaceProcessor(long space, IgfsFileAffinityRange affRange) {
+ this.space = space;
+ this.affRange = affRange;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsEntryInfo oldInfo = entry.getValue();
+
+ IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
+
+ newMap.addRange(affRange);
+
+ IgfsEntryInfo newInfo = oldInfo.length(oldInfo.length() + space).fileMap(newMap);
+
+ entry.setValue(newInfo);
+
+ return newInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(space);
+ out.writeObject(affRange);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ space = in.readLong();
+ affRange = (IgfsFileAffinityRange)in.readObject();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java
new file mode 100644
index 0000000..d535a1d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java
@@ -0,0 +1,60 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.lang.IgniteUuid;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * File unlock entry processor.
+ */
+public class IgfsMetaFileUnlockProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Modification time. */
+ private long modificationTime;
+
+ /**
+ * Default constructor.
+ */
+ public IgfsMetaFileUnlockProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param modificationTime Modification time.
+ */
+ public IgfsMetaFileUnlockProcessor(long modificationTime) {
+ this.modificationTime = modificationTime;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsEntryInfo old = entry.getValue();
+
+ entry.setValue(old.unlock(modificationTime));
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(modificationTime);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ modificationTime = in.readLong();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
new file mode 100644
index 0000000..32e5512
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
@@ -0,0 +1,66 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.igfs.IgfsPath;
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.processors.igfs.IgfsMetaManager;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgniteUuid;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * Update path closure.
+ */
+public final class IgfsMetaUpdatePathProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** New path. */
+ private IgfsPath path;
+
+ /**
+ * @param path Path.
+ */
+ public IgfsMetaUpdatePathProcessor(IgfsPath path) {
+ this.path = path;
+ }
+
+ /**
+ * Default constructor (required by Externalizable).
+ */
+ public IgfsMetaUpdatePathProcessor() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) {
+ IgfsEntryInfo info = e.getValue();
+
+ IgfsEntryInfo newInfo = info.path(path);
+
+ e.setValue(newInfo);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(path);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ path = (IgfsPath)in.readObject();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(IgfsMetaUpdatePathProcessor.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
new file mode 100644
index 0000000..a97c186
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
@@ -0,0 +1,78 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.internal.util.GridLeanMap;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteUuid;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Map;
+
+/**
+ * Update properties processor.
+ */
+public class IgfsMetaUpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Properties to be updated. */
+ private Map<String, String> props;
+
+ /**
+ * Constructor.
+ */
+ public IgfsMetaUpdatePropertiesProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param props Properties.
+ */
+ public IgfsMetaUpdatePropertiesProcessor(Map<String, String> props) {
+ this.props = props;
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
+ throws EntryProcessorException {
+ IgfsEntryInfo oldInfo = entry.getValue();
+
+ Map<String, String> tmp = oldInfo.properties();
+
+ tmp = tmp == null ? new GridLeanMap<String, String>(props.size()) : new GridLeanMap<>(tmp);
+
+ for (Map.Entry<String, String> e : props.entrySet()) {
+ if (e.getValue() == null)
+ // Remove properties with 'null' values.
+ tmp.remove(e.getKey());
+ else
+ // Add/overwrite property.
+ tmp.put(e.getKey(), e.getValue());
+ }
+
+ IgfsEntryInfo newInfo = oldInfo.properties(tmp);
+
+ entry.setValue(newInfo);
+
+ return newInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeStringMap(out, props);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ props = U.readStringMap(in);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9a4b5bd7/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java
new file mode 100644
index 0000000..8acd289
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java
@@ -0,0 +1,68 @@
+package org.apache.ignite.internal.processors.igfs.meta;
+
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
+import org.apache.ignite.lang.IgniteUuid;
+
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+/**
+ * Update times entry processor.
+ */
+public class IgfsMetaUpdateTimesProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
+ Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Access time. */
+ private long accessTime;
+
+ /** Modification time. */
+ private long modificationTime;
+
+ /**
+ * Default constructor.
+ */
+ public IgfsMetaUpdateTimesProcessor() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param accessTime Access time.
+ * @param modificationTime Modification time.
+ */
+ public IgfsMetaUpdateTimesProcessor(long accessTime, long modificationTime) {
+ this.accessTime = accessTime;
+ this.modificationTime = modificationTime;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
+ throws EntryProcessorException {
+
+ IgfsEntryInfo oldInfo = entry.getValue();
+
+ entry.setValue(oldInfo.accessModificationTime(accessTime, modificationTime));
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeLong(accessTime);
+ out.writeLong(modificationTime);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ accessTime = in.readLong();
+ modificationTime = in.readLong();
+ }
+}
[46/50] [abbrv] ignite git commit: gridgain-7.5.11 Affinity history
cleanup ignoring client discovery event.
Posted by sb...@apache.org.
gridgain-7.5.11 Affinity history cleanup ignoring client discovery event.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e7ab8eef
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e7ab8eef
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e7ab8eef
Branch: refs/heads/ignite-1837
Commit: e7ab8eef504cdcf8987941e8b7a552ada451aec8
Parents: b2c934d
Author: sboikov <sb...@gridgain.com>
Authored: Wed Apr 6 17:38:04 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Apr 6 17:38:04 2016 +0300
----------------------------------------------------------------------
.../affinity/GridAffinityAssignment.java | 14 +
.../affinity/GridAffinityAssignmentCache.java | 67 ++++-
.../cache/GridCacheAffinityManager.java | 11 -
.../GridCachePartitionExchangeManager.java | 14 -
.../affinity/AffinityHistoryCleanupTest.java | 295 +++++++++++++++++++
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +
6 files changed, 363 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e7ab8eef/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
index 810843c..ef228cf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
@@ -47,6 +47,9 @@ class GridAffinityAssignment implements Serializable {
/** Map of backup node partitions. */
private final Map<UUID, Set<Integer>> backup;
+ /** */
+ private final boolean clientEvtChange;
+
/**
* Constructs cached affinity calculations item.
*
@@ -56,6 +59,7 @@ class GridAffinityAssignment implements Serializable {
this.topVer = topVer;
primary = new HashMap<>();
backup = new HashMap<>();
+ clientEvtChange = false;
}
/**
@@ -68,6 +72,7 @@ class GridAffinityAssignment implements Serializable {
primary = new HashMap<>();
backup = new HashMap<>();
+ clientEvtChange = false;
initPrimaryBackupMaps();
}
@@ -82,6 +87,15 @@ class GridAffinityAssignment implements Serializable {
assignment = aff.assignment;
primary = aff.primary;
backup = aff.backup;
+
+ clientEvtChange = true;
+ }
+
+ /**
+ * @return {@code True} if
+ */
+ public boolean clientEventChange() {
+ return clientEvtChange;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/e7ab8eef/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index d728927..ac8d19d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -25,6 +25,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
@@ -47,12 +48,17 @@ import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
import org.jsr166.ConcurrentLinkedHashMap;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE;
+import static org.apache.ignite.IgniteSystemProperties.getInteger;
import static org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT;
/**
* Affinity cached function.
*/
public class GridAffinityAssignmentCache {
+ /** Cleanup history size. */
+ private final int MAX_HIST_SIZE = getInteger(IGNITE_AFFINITY_HISTORY_SIZE, 500);
+
/** Cache name. */
private final String cacheName;
@@ -86,6 +92,9 @@ public class GridAffinityAssignmentCache {
/** Node stop flag. */
private volatile IgniteCheckedException stopErr;
+ /** History size ignoring*/
+ private final AtomicInteger histSize = new AtomicInteger();
+
/**
* Constructs affinity cached calculations.
*
@@ -141,6 +150,8 @@ public class GridAffinityAssignmentCache {
entry.getValue().onDone(topVer);
}
}
+
+ onHistoryAdded(assignment);
}
/**
@@ -244,6 +255,8 @@ public class GridAffinityAssignmentCache {
}
}
+ onHistoryAdded(updated);
+
return updated.assignment();
}
@@ -274,6 +287,8 @@ public class GridAffinityAssignmentCache {
entry.getValue().onDone(topVer);
}
}
+
+ onHistoryAdded(assignmentCpy);
}
/**
@@ -284,21 +299,6 @@ public class GridAffinityAssignmentCache {
}
/**
- * Clean up outdated cache items.
- *
- * @param topVer Actual topology version, older versions will be removed.
- */
- public void cleanUpCache(AffinityTopologyVersion topVer) {
- if (log.isDebugEnabled())
- log.debug("Cleaning up cache for version [locNodeId=" + ctx.localNodeId() +
- ", topVer=" + topVer + ']');
-
- for (Iterator<AffinityTopologyVersion> it = affCache.keySet().iterator(); it.hasNext(); )
- if (it.next().compareTo(topVer) < 0)
- it.remove();
- }
-
- /**
* @param topVer Topology version.
* @return Affinity assignment.
*/
@@ -483,6 +483,43 @@ public class GridAffinityAssignmentCache {
}
/**
+ * @param aff Added affinity assignment.
+ */
+ private void onHistoryAdded(GridAffinityAssignment aff) {
+ int size;
+
+ if (aff.clientEventChange())
+ size = histSize.get();
+ else
+ size = histSize.incrementAndGet();
+
+ int rmvCnt = size - MAX_HIST_SIZE;
+
+ if (rmvCnt <= 0) {
+ int sizex = affCache.sizex();
+
+ if (sizex > MAX_HIST_SIZE * 2)
+ rmvCnt = MAX_HIST_SIZE;
+ }
+
+ if (rmvCnt > 0) {
+ Iterator<GridAffinityAssignment> it = affCache.values().iterator();
+
+ while (it.hasNext() && rmvCnt > 0) {
+ GridAffinityAssignment aff0 = it.next();
+
+ it.remove();
+
+ rmvCnt--;
+
+ if (!aff0.clientEventChange())
+ histSize.decrementAndGet();
+ }
+ }
+ }
+
+
+ /**
* Affinity ready future. Will remove itself from ready futures map.
*/
private class AffinityReadyFuture extends GridFutureAdapter<AffinityTopologyVersion> {
http://git-wip-us.apache.org/repos/asf/ignite/blob/e7ab8eef/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
index eddffea..5afced8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
@@ -126,17 +126,6 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter {
}
/**
- * Clean up outdated cache items.
- *
- * @param topVer Actual topology version, older versions will be removed.
- */
- public void cleanUpCache(AffinityTopologyVersion topVer) {
- assert !cctx.isLocal();
-
- aff.cleanUpCache(topVer);
- }
-
- /**
* Initializes affinity for joined node.
*
* @param topVer Topology version.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e7ab8eef/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 14df1aa..5e91d01 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -88,9 +88,7 @@ import org.jsr166.ConcurrentHashMap8;
import org.jsr166.ConcurrentLinkedDeque8;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static org.apache.ignite.IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_PRELOAD_RESEND_TIMEOUT;
-import static org.apache.ignite.IgniteSystemProperties.getInteger;
import static org.apache.ignite.IgniteSystemProperties.getLong;
import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_STARTED;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
@@ -108,9 +106,6 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
/** Exchange history size. */
private static final int EXCHANGE_HISTORY_SIZE = 1000;
- /** Cleanup history size. */
- public static final int EXCH_FUT_CLEANUP_HISTORY_SIZE = getInteger(IGNITE_AFFINITY_HISTORY_SIZE, 1000);
-
/** Atomic reference for pending timeout object. */
private AtomicReference<ResendTimeoutObject> pendingResend = new AtomicReference<>();
@@ -938,15 +933,6 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
skipped++;
- if (skipped == EXCH_FUT_CLEANUP_HISTORY_SIZE) {
- for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
- if (err == null) {
- if (!cacheCtx.isLocal())
- cacheCtx.affinity().cleanUpCache(fut.topologyVersion());
- }
- }
- }
-
if (skipped > 10)
fut.cleanUp();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e7ab8eef/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityHistoryCleanupTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityHistoryCleanupTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityHistoryCleanupTest.java
new file mode 100644
index 0000000..39a2a76
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/AffinityHistoryCleanupTest.java
@@ -0,0 +1,295 @@
+/*
+ * 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.cache.affinity;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.cache.affinity.fair.FairAffinityFunction;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class AffinityHistoryCleanupTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private boolean client;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ CacheConfiguration[] ccfgs = new CacheConfiguration[4];
+
+ for (int i = 0; i < ccfgs.length; i++) {
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ ccfg.setName("static-cache-" + i);
+ ccfg.setAffinity(i % 2 == 0 ? new RendezvousAffinityFunction() : new FairAffinityFunction());
+
+ ccfgs[i] = ccfg;
+ }
+
+ cfg.setCacheConfiguration(ccfgs);
+
+ cfg.setClientMode(client);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+
+ super.afterTest();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAffinityHistoryCleanup() throws Exception {
+ String histProp = System.getProperty(IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE);
+
+ try {
+ System.setProperty(IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE, "5");
+
+ Ignite ignite = startGrid(0);
+
+ checkHistory(ignite, F.asList(topVer(1, 0)), 1);
+
+ for (int i = 0; i < 3; i++) {
+ startGrid(1);
+
+ stopGrid(1);
+ }
+
+ checkHistory(ignite, F.asList(
+ topVer(3, 0),
+ topVer(4, 0),
+ topVer(5, 0),
+ topVer(6, 0),
+ topVer(7, 0)),
+ 5);
+
+ client = true;
+
+ startGrid(1);
+
+ stopGrid(1);
+
+ checkHistory(ignite, F.asList(
+ topVer(3, 0),
+ topVer(4, 0),
+ topVer(5, 0),
+ topVer(6, 0),
+ topVer(7, 0),
+ topVer(8, 0),
+ topVer(9, 0)),
+ 5);
+
+ startGrid(1);
+
+ stopGrid(1);
+
+ checkHistory(ignite, F.asList(
+ topVer(3, 0),
+ topVer(4, 0),
+ topVer(5, 0),
+ topVer(6, 0),
+ topVer(7, 0),
+ topVer(8, 0),
+ topVer(9, 0),
+ topVer(10, 0),
+ topVer(11, 0)),
+ 5);
+
+ startGrid(1);
+
+ checkHistory(ignite, F.asList(
+ topVer(3, 0),
+ topVer(4, 0),
+ topVer(5, 0),
+ topVer(6, 0),
+ topVer(7, 0),
+ topVer(8, 0),
+ topVer(9, 0),
+ topVer(10, 0),
+ topVer(11, 0),
+ topVer(12, 0)),
+ 5);
+
+ stopGrid(1);
+
+ checkHistory(ignite, F.asList(
+ topVer(8, 0),
+ topVer(9, 0),
+ topVer(10, 0),
+ topVer(11, 0),
+ topVer(12, 0),
+ topVer(13, 0)),
+ 0);
+
+ client = false;
+
+ startGrid(1);
+
+ stopGrid(1);
+
+ checkHistory(ignite, F.asList(
+ topVer(8, 0),
+ topVer(9, 0),
+ topVer(10, 0),
+ topVer(11, 0),
+ topVer(12, 0),
+ topVer(13, 0),
+ topVer(14, 0),
+ topVer(15, 0)),
+ 2);
+
+ startGrid(1);
+
+ stopGrid(1);
+
+ checkHistory(ignite, F.asList(
+ topVer(8, 0),
+ topVer(9, 0),
+ topVer(10, 0),
+ topVer(11, 0),
+ topVer(12, 0),
+ topVer(13, 0),
+ topVer(14, 0),
+ topVer(15, 0),
+ topVer(16, 0),
+ topVer(17, 0)),
+ 4);
+
+ startGrid(1);
+
+ checkHistory(ignite, F.asList(
+ topVer(13, 0),
+ topVer(14, 0),
+ topVer(15, 0),
+ topVer(16, 0),
+ topVer(17, 0),
+ topVer(18, 0)),
+ 5);
+
+ stopGrid(1);
+
+ checkHistory(ignite, F.asList(
+ topVer(14, 0),
+ topVer(15, 0),
+ topVer(16, 0),
+ topVer(17, 0),
+ topVer(18, 0),
+ topVer(19, 0)),
+ 6);
+
+ startGrid(1);
+
+ checkHistory(ignite, F.asList(
+ topVer(16, 0),
+ topVer(17, 0),
+ topVer(18, 0),
+ topVer(19, 0),
+ topVer(20, 0)),
+ 5);
+
+ client = true;
+
+ startGrid(2);
+
+ stopGrid(2);
+
+ checkHistory(ignite, F.asList(
+ topVer(16, 0),
+ topVer(17, 0),
+ topVer(18, 0),
+ topVer(19, 0),
+ topVer(20, 0),
+ topVer(21, 0),
+ topVer(22, 0)),
+ 5);
+ }
+ finally {
+ if (histProp != null)
+ System.setProperty(IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE, histProp);
+ else
+ System.clearProperty(IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE);
+ }
+ }
+
+ /**
+ * @param ignite Node.
+ * @param expHist Expected history.
+ * @param expSize Expected 'non client events' history size.
+ */
+ private void checkHistory(Ignite ignite, List<AffinityTopologyVersion> expHist, int expSize) {
+ GridCacheProcessor proc = ((IgniteKernal)ignite).context().cache();
+
+ int cnt = 0;
+
+ for (GridCacheContext cctx : proc.context().cacheContexts()) {
+ GridAffinityAssignmentCache aff = GridTestUtils.getFieldValue(cctx.affinity(), "aff");
+
+ AtomicInteger histSize = GridTestUtils.getFieldValue(aff, "histSize");
+
+ assertEquals(expSize, histSize.get());
+
+ Map<AffinityTopologyVersion, Object> cache = GridTestUtils.getFieldValue(aff, "affCache");
+
+ assertEquals("Unexpected history: " + cache.keySet(), expHist.size(), cache.size());
+
+ for (AffinityTopologyVersion topVer : expHist)
+ assertTrue("No history [ver=" + topVer + ", hist=" + cache.keySet() + ']', cache.containsKey(topVer));
+
+ cnt++;
+ }
+
+ assert cnt > 4;
+ }
+
+ /**
+ * @param major Major version.
+ * @param minor Minor version.
+ * @return Version.
+ */
+ private static AffinityTopologyVersion topVer(int major, int minor) {
+ return new AffinityTopologyVersion(major, minor);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e7ab8eef/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 9892ff7..7f1d7df 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -23,6 +23,7 @@ import org.apache.ignite.GridCacheAffinityBackupsSelfTest;
import org.apache.ignite.IgniteCacheAffinitySelfTest;
import org.apache.ignite.cache.IgniteWarmupClosureSelfTest;
import org.apache.ignite.cache.affinity.AffinityClientNodeSelfTest;
+import org.apache.ignite.cache.affinity.AffinityHistoryCleanupTest;
import org.apache.ignite.cache.affinity.fair.FairAffinityDynamicCacheSelfTest;
import org.apache.ignite.cache.affinity.fair.FairAffinityFunctionNodesSelfTest;
import org.apache.ignite.cache.affinity.fair.FairAffinityFunctionSelfTest;
@@ -209,6 +210,7 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(GridCacheAffinityBackupsSelfTest.class);
suite.addTestSuite(IgniteCacheAffinitySelfTest.class);
suite.addTestSuite(AffinityClientNodeSelfTest.class);
+ suite.addTestSuite(AffinityHistoryCleanupTest.class);
// Swap tests.
suite.addTestSuite(GridCacheSwapPreloadSelfTest.class);
[31/50] [abbrv] ignite git commit: IGNITE-2806: IGFS: Implemented
relaxed consistency model.
Posted by sb...@apache.org.
IGNITE-2806: IGFS: Implemented relaxed consistency model.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b286facc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b286facc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b286facc
Branch: refs/heads/ignite-1837
Commit: b286facc4b8c44ab1628039dded6c7527760df73
Parents: 8d95eba
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Tue Mar 22 12:34:35 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:14:16 2016 +0300
----------------------------------------------------------------------
.../configuration/FileSystemConfiguration.java | 49 +++++++++++++++++-
.../processors/igfs/IgfsMetaManager.java | 38 ++++++++------
.../internal/processors/igfs/IgfsPathIds.java | 52 ++++++++++++++------
.../internal/processors/igfs/IgfsProcessor.java | 29 ++++++-----
.../processors/igfs/IgfsAbstractSelfTest.java | 11 +++++
.../igfs/IgfsPrimaryRelaxedSelfTest.java | 28 +++++++++++
.../processors/igfs/IgfsProcessorSelfTest.java | 17 ++++---
.../ignite/testsuites/IgniteIgfsTestSuite.java | 2 +
8 files changed, 177 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b286facc/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
index 99d364e..0d7f3cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
@@ -17,8 +17,6 @@
package org.apache.ignite.configuration;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.igfs.IgfsIpcEndpointConfiguration;
import org.apache.ignite.igfs.IgfsMode;
@@ -27,6 +25,9 @@ import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.jetbrains.annotations.Nullable;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+
/**
* {@code IGFS} configuration. More than one file system can be configured within grid.
* {@code IGFS} configuration is provided via {@link IgniteConfiguration#getFileSystemConfiguration()}
@@ -87,6 +88,9 @@ public class FileSystemConfiguration {
/** Default value of metadata co-location flag. */
public static boolean DFLT_COLOCATE_META = true;
+ /** Default value of relaxed consistency flag. */
+ public static boolean DFLT_RELAXED_CONSISTENCY = true;
+
/** IGFS instance name. */
private String name;
@@ -171,6 +175,9 @@ public class FileSystemConfiguration {
/** Metadata co-location flag. */
private boolean colocateMeta = DFLT_COLOCATE_META;
+ /** Relaxed consistency flag. */
+ private boolean relaxedConsistency = DFLT_RELAXED_CONSISTENCY;
+
/**
* Constructs default configuration.
*/
@@ -215,6 +222,7 @@ public class FileSystemConfiguration {
perNodeBatchSize = cfg.getPerNodeBatchSize();
perNodeParallelBatchCnt = cfg.getPerNodeParallelBatchCount();
prefetchBlocks = cfg.getPrefetchBlocks();
+ relaxedConsistency = cfg.isRelaxedConsistency();
seqReadsBeforePrefetch = cfg.getSequentialReadsBeforePrefetch();
trashPurgeTimeout = cfg.getTrashPurgeTimeout();
}
@@ -877,6 +885,43 @@ public class FileSystemConfiguration {
this.colocateMeta = colocateMeta;
}
+ /**
+ * Get relaxed consistency flag.
+ * <p>
+ * Concurrent file system operations might conflict with each other. E.g. {@code move("/a1/a2", "/b")} and
+ * {@code move("/b", "/a1")}. Hence, it is necessary to atomically verify that participating paths are still
+ * on their places to keep file system in consistent state in such cases. These checks are expensive in
+ * distributed environment.
+ * <p>
+ * Real applications, e.g. Hadoop jobs, rarely produce conflicting operations. So additional checks could be
+ * skipped in these scenarios without any negative effect on file system integrity. It significantly increases
+ * performance of file system operations.
+ * <p>
+ * If value of this flag is {@code true}, IGFS will skip expensive consistency checks. It is recommended to set
+ * this flag to {@code false} if your application has conflicting operations, or you do not how exactly users will
+ * use your system.
+ * <p>
+ * This property affects only {@link IgfsMode#PRIMARY} paths.
+ * <p>
+ * Defaults to {@link #DFLT_RELAXED_CONSISTENCY}.
+ *
+ * @return {@code True} if relaxed consistency is enabled.
+ */
+ public boolean isRelaxedConsistency() {
+ return relaxedConsistency;
+ }
+
+ /**
+ * Set relaxed consistency flag.
+ * <p>
+ * See {@link #isColocateMetadata()} for more information.
+ *
+ * @param relaxedConsistency Whether to use relaxed consistency optimization.
+ */
+ public void setRelaxedConsistency(boolean relaxedConsistency) {
+ this.relaxedConsistency = relaxedConsistency;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(FileSystemConfiguration.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/b286facc/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index d6c5995..a4212ba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -136,8 +136,20 @@ public class IgfsMetaManager extends IgfsManager {
/** Busy lock. */
private final GridSpinBusyLock busyLock = new GridSpinBusyLock();
+ /** Relaxed flag. */
+ private final boolean relaxed;
+
/**
+ * Constructor.
*
+ * @param relaxed Relaxed mode flag.
+ */
+ public IgfsMetaManager(boolean relaxed) {
+ this.relaxed = relaxed;
+ }
+
+ /**
+ * Await initialization.
*/
void awaitInit() {
try {
@@ -889,19 +901,19 @@ public class IgfsMetaManager extends IgfsManager {
// Lock participating IDs.
final Set<IgniteUuid> lockIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
- srcPathIds.addExistingIds(lockIds);
- dstPathIds.addExistingIds(lockIds);
+ srcPathIds.addExistingIds(lockIds, relaxed);
+ dstPathIds.addExistingIds(lockIds, relaxed);
try (IgniteInternalTx tx = startTx()) {
// Obtain the locks.
final Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
// Verify integrity of source and destination paths.
- if (!srcPathIds.verifyIntegrity(lockInfos))
+ if (!srcPathIds.verifyIntegrity(lockInfos, relaxed))
throw new IgfsPathNotFoundException("Failed to perform move because source directory " +
"structure changed concurrently [src=" + srcPath + ", dst=" + dstPath + ']');
- if (!dstPathIds.verifyIntegrity(lockInfos))
+ if (!dstPathIds.verifyIntegrity(lockInfos, relaxed))
throw new IgfsPathNotFoundException("Failed to perform move because destination directory " +
"structure changed concurrently [src=" + srcPath + ", dst=" + dstPath + ']');
@@ -1103,7 +1115,7 @@ public class IgfsMetaManager extends IgfsManager {
// Prepare IDs to lock.
SortedSet<IgniteUuid> allIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
- pathIds.addExistingIds(allIds);
+ pathIds.addExistingIds(allIds, relaxed);
IgniteUuid trashId = IgfsUtils.randomTrashId();
@@ -1114,7 +1126,7 @@ public class IgfsMetaManager extends IgfsManager {
Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(allIds);
// Ensure that all participants are still in place.
- if (!pathIds.verifyIntegrity(lockInfos))
+ if (!pathIds.verifyIntegrity(lockInfos, relaxed))
return null;
IgfsEntryInfo victimInfo = lockInfos.get(victimId);
@@ -1589,16 +1601,14 @@ public class IgfsMetaManager extends IgfsManager {
// Prepare lock IDs. Essentially, they consist of two parts: existing IDs and potential new IDs.
Set<IgniteUuid> lockIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
- pathIds.addExistingIds(lockIds);
+ pathIds.addExistingIds(lockIds, relaxed);
pathIds.addSurrogateIds(lockIds);
- assert lockIds.size() == pathIds.count();
-
// Start TX.
try (IgniteInternalTx tx = startTx()) {
final Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
- if (!pathIds.verifyIntegrity(lockInfos))
+ if (!pathIds.verifyIntegrity(lockInfos, relaxed))
// Directory structure changed concurrently. So we simply re-try.
continue;
@@ -2907,14 +2917,14 @@ public class IgfsMetaManager extends IgfsManager {
// Prepare lock IDs.
Set<IgniteUuid> lockIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
- pathIds.addExistingIds(lockIds);
+ pathIds.addExistingIds(lockIds, relaxed);
pathIds.addSurrogateIds(lockIds);
// Start TX.
try (IgniteInternalTx tx = startTx()) {
Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
- if (!pathIds.verifyIntegrity(lockInfos))
+ if (!pathIds.verifyIntegrity(lockInfos, relaxed))
// Directory structure changed concurrently. So we simply re-try.
continue;
@@ -2998,7 +3008,7 @@ public class IgfsMetaManager extends IgfsManager {
// Prepare lock IDs.
Set<IgniteUuid> lockIds = new TreeSet<>(PATH_ID_SORTING_COMPARATOR);
- pathIds.addExistingIds(lockIds);
+ pathIds.addExistingIds(lockIds, relaxed);
pathIds.addSurrogateIds(lockIds);
// In overwrite mode we also lock ID of potential replacement as well as trash ID.
@@ -3017,7 +3027,7 @@ public class IgfsMetaManager extends IgfsManager {
try (IgniteInternalTx tx = startTx()) {
Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
- if (!pathIds.verifyIntegrity(lockInfos))
+ if (!pathIds.verifyIntegrity(lockInfos, relaxed))
// Directory structure changed concurrently. So we simply re-try.
continue;
http://git-wip-us.apache.org/repos/asf/ignite/blob/b286facc/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
index e2fe58d..446495e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
@@ -221,11 +221,20 @@ public class IgfsPathIds {
* Add existing IDs to provided collection.
*
* @param col Collection.
+ * @param relaxed Relaxed mode flag.
*/
@SuppressWarnings("ManualArrayToCollectionCopy")
- public void addExistingIds(Collection<IgniteUuid> col) {
- for (int i = 0; i <= lastExistingIdx; i++)
- col.add(ids[i]);
+ public void addExistingIds(Collection<IgniteUuid> col, boolean relaxed) {
+ if (relaxed) {
+ col.add(ids[lastExistingIdx]);
+
+ if (lastExistingIdx == ids.length - 1 && lastExistingIdx > 0)
+ col.add(ids[lastExistingIdx - 1]);
+ }
+ else {
+ for (int i = 0; i <= lastExistingIdx; i++)
+ col.add(ids[i]);
+ }
}
/**
@@ -265,24 +274,39 @@ public class IgfsPathIds {
* Verify that observed paths are found in provided infos in the right order.
*
* @param infos Info.
+ * @param relaxed Whether to perform check in relaxed mode.
* @return {@code True} if full integrity is preserved.
*/
- public boolean verifyIntegrity(Map<IgniteUuid, IgfsEntryInfo> infos) {
- for (int i = 0; i <= lastExistingIdx; i++) {
- IgniteUuid curId = ids[i];
- IgfsEntryInfo curInfo = infos.get(curId);
+ public boolean verifyIntegrity(Map<IgniteUuid, IgfsEntryInfo> infos, boolean relaxed) {
+ if (relaxed) {
+ // Relaxed mode ensures that the last element is there. If this element is the last in the path, then
+ // existence of it's parent and link between them are checked as well.
+ IgfsEntryInfo info = infos.get(ids[lastExistingIdx]);
- // Check if required ID is there.
- if (curInfo == null)
+ if (info == null)
return false;
- // For non-leaf entry we check if child exists.
- if (i < lastExistingIdx) {
- String childName = parts[i + 1];
- IgniteUuid childId = ids[i + 1];
+ if (lastExistingIdx == ids.length - 1 && lastExistingIdx > 0) {
+ IgfsEntryInfo parentInfo = infos.get(ids[lastExistingIdx - 1]);
+
+ if (parentInfo == null || !parentInfo.hasChild(parts[lastExistingIdx], ids[lastExistingIdx]))
+ return false;
+ }
+ }
+ else {
+ // Strict mode ensures that all participants are in place and are still linked.
+ for (int i = 0; i <= lastExistingIdx; i++) {
+ IgfsEntryInfo info = infos.get(ids[i]);
- if (!curInfo.hasChild(childName, childId))
+ // Check if required ID is there.
+ if (info == null)
return false;
+
+ // For non-leaf entry we check if child exists.
+ if (i < lastExistingIdx) {
+ if (!info.hasChild(parts[i + 1], ids[i + 1]))
+ return false;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b286facc/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
index 1b60252..44f6e44 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
@@ -17,16 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentMap;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.cache.affinity.AffinityKeyMapper;
@@ -53,6 +43,17 @@ import org.apache.ignite.lang.IgniteClosure;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentMap;
+
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
import static org.apache.ignite.IgniteSystemProperties.getBoolean;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
@@ -104,10 +105,12 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
// Start IGFS instances.
for (FileSystemConfiguration cfg : cfgs) {
+ FileSystemConfiguration cfg0 = new FileSystemConfiguration(cfg);
+
IgfsContext igfsCtx = new IgfsContext(
ctx,
- new FileSystemConfiguration(cfg),
- new IgfsMetaManager(),
+ cfg0,
+ new IgfsMetaManager(cfg0.isRelaxedConsistency()),
new IgfsDataManager(),
new IgfsServerManager(),
new IgfsFragmentizerManager());
@@ -116,7 +119,7 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
for (IgfsManager mgr : igfsCtx.managers())
mgr.start(igfsCtx);
- igfsCache.put(maskName(cfg.getName()), igfsCtx);
+ igfsCache.put(maskName(cfg0.getName()), igfsCtx);
}
if (log.isDebugEnabled())
http://git-wip-us.apache.org/repos/asf/ignite/blob/b286facc/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
index 5894fa2..ec3878c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
@@ -225,6 +225,13 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
}
/**
+ * @return Relaxed consistency flag.
+ */
+ protected boolean relaxedConsistency() {
+ return false;
+ }
+
+ /**
* Data chunk.
*
* @param len Length.
@@ -302,6 +309,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
igfsCfg.setSecondaryFileSystem(secondaryFs);
igfsCfg.setPrefetchBlocks(PREFETCH_BLOCKS);
igfsCfg.setSequentialReadsBeforePrefetch(SEQ_READS_BEFORE_PREFETCH);
+ igfsCfg.setRelaxedConsistency(relaxedConsistency());
CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
@@ -2368,6 +2376,9 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
private void checkDeadlocksRepeat(final int lvlCnt, final int childrenDirPerLvl, final int childrenFilePerLvl,
int primaryLvlCnt, int renCnt, int delCnt,
int updateCnt, int mkdirsCnt, int createCnt) throws Exception {
+ if (relaxedConsistency())
+ return;
+
for (int i = 0; i < REPEAT_CNT; i++) {
try {
checkDeadlocks(lvlCnt, childrenDirPerLvl, childrenFilePerLvl, primaryLvlCnt, renCnt, delCnt,
http://git-wip-us.apache.org/repos/asf/ignite/blob/b286facc/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryRelaxedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryRelaxedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryRelaxedSelfTest.java
new file mode 100644
index 0000000..6691df5
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsPrimaryRelaxedSelfTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+/**
+ * Tests for PRIMARY mode and relaxed consistency model.
+ */
+public class IgfsPrimaryRelaxedSelfTest extends IgfsPrimarySelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean relaxedConsistency() {
+ return true;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/b286facc/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
index bcc2314..269706e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorSelfTest.java
@@ -35,6 +35,7 @@ import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
@@ -779,14 +780,18 @@ public class IgfsProcessorSelfTest extends IgfsCommonAbstractTest {
assert !igfs.exists(path(dirPath));
assert !igfs.exists(path(filePath));
- int metaSize = 0;
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ int metaSize = 0;
- for (Object metaId : grid(0).cachex(igfs.configuration().getMetaCacheName()).keySet()) {
- if (!IgfsUtils.isRootOrTrashId((IgniteUuid)metaId))
- metaSize++;
- }
+ for (Object metaId : grid(0).cachex(igfs.configuration().getMetaCacheName()).keySet()) {
+ if (!IgfsUtils.isRootOrTrashId((IgniteUuid)metaId))
+ metaSize++;
+ }
- assert metaSize == 0;
+ return metaSize == 0;
+ }
+ }, 5000);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/b286facc/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
index 489088c..038cb54 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
@@ -40,6 +40,7 @@ import org.apache.ignite.internal.processors.igfs.IgfsModesSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsOneClientNodeTest;
import org.apache.ignite.internal.processors.igfs.IgfsPrimaryOffheapTieredSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsPrimaryOffheapValuesSelfTest;
+import org.apache.ignite.internal.processors.igfs.IgfsPrimaryRelaxedSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsPrimarySelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsProcessorSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsProcessorValidationSelfTest;
@@ -67,6 +68,7 @@ public class IgniteIgfsTestSuite extends TestSuite {
TestSuite suite = new TestSuite("Ignite FS Test Suite For Platform Independent Tests");
suite.addTest(new TestSuite(IgfsPrimarySelfTest.class));
+ suite.addTest(new TestSuite(IgfsPrimaryRelaxedSelfTest.class));
suite.addTest(new TestSuite(IgfsPrimaryOffheapTieredSelfTest.class));
suite.addTest(new TestSuite(IgfsPrimaryOffheapValuesSelfTest.class));
suite.addTest(new TestSuite(IgfsDualSyncSelfTest.class));
[41/50] [abbrv] ignite git commit: ignite-2835 Minor test changes.
Posted by sb...@apache.org.
ignite-2835 Minor test changes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d33b4340
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d33b4340
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d33b4340
Branch: refs/heads/ignite-1837
Commit: d33b4340a68553e59e4adecf78fea79af55bf2ae
Parents: e85a717
Author: sboikov <sb...@gridgain.com>
Authored: Tue Apr 5 16:42:50 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Apr 5 16:42:50 2016 +0300
----------------------------------------------------------------------
.../BinaryObjectOffHeapUnswapTemporaryTest.java | 55 ++++++++------------
1 file changed, 23 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d33b4340/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java
index 4272a14..d63b2c3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/BinaryObjectOffHeapUnswapTemporaryTest.java
@@ -35,6 +35,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.binary.BinaryObjectOffheapImpl;
+import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
@@ -81,7 +82,7 @@ public class BinaryObjectOffHeapUnswapTemporaryTest extends GridCommonAbstractTe
CacheMemoryMode memoryMode) {
this.atomicityMode = atomicityMode;
- CacheConfiguration cfg = new CacheConfiguration();
+ CacheConfiguration<Object, Object> cfg = new CacheConfiguration<>();
cfg.setCacheMode(CacheMode.PARTITIONED);
cfg.setAtomicityMode(atomicityMode);
@@ -184,50 +185,50 @@ public class BinaryObjectOffHeapUnswapTemporaryTest extends GridCommonAbstractTe
for (int i = 0; i < 2 * CNT; i++)
keys.add(i);
- check(new TestCheck<Integer>() {
- @Override public void check(Integer key) {
+ check(new IgniteInClosure<Integer>() {
+ @Override public void apply(Integer key) {
assertFalse(cache.get(key) instanceof BinaryObjectOffheapImpl);
}
});
- check(new TestCheck<Integer>() {
- @Override public void check(Integer key) {
- assertFalse(cache.getEntry(key) instanceof BinaryObjectOffheapImpl);
+ check(new IgniteInClosure<Integer>() {
+ @Override public void apply(Integer key) {
+ assertFalse(cache.getEntry(key).getValue() instanceof BinaryObjectOffheapImpl);
}
});
- check(new TestCheck<Integer>() {
- @Override public void check(Integer key) {
+ check(new IgniteInClosure<Integer>() {
+ @Override public void apply(Integer key) {
assertFalse(cache.getAndPut(key, cache.get(key)) instanceof BinaryObjectOffheapImpl);
}
});
- check(new TestCheck<Integer>() {
- @Override public void check(Integer key) {
+ check(new IgniteInClosure<Integer>() {
+ @Override public void apply(Integer key) {
assertFalse(cache.getAndReplace(key, cache.get(key)) instanceof BinaryObjectOffheapImpl);
}
});
- check(new TestCheck<Integer>() {
- @Override public void check(Integer key) {
+ check(new IgniteInClosure<Integer>() {
+ @Override public void apply(Integer key) {
assertFalse(cache.getAndPutIfAbsent(key, cache.get(key)) instanceof BinaryObjectOffheapImpl);
}
});
- check(new TestCheck<Integer>() {
- @Override public void check(Integer key) {
+ check(new IgniteInClosure<Integer>() {
+ @Override public void apply(Integer key) {
assertFalse(cache.localPeek(key) instanceof BinaryObjectOffheapImpl);
}
});
- check(new TestCheck<Integer>() {
- @Override public void check(Integer key) {
+ check(new IgniteInClosure<Integer>() {
+ @Override public void apply(Integer key) {
assertFalse(cache.getAndRemove(key) instanceof BinaryObjectOffheapImpl);
}
});
- check(new TestCheck<Integer>() {
- @Override public void check(Integer key) {
+ check(new IgniteInClosure<Integer>() {
+ @Override public void apply(Integer key) {
assertFalse(cache.invoke(key, PROC) instanceof BinaryObjectOffheapImpl);
}
});
@@ -318,17 +319,17 @@ public class BinaryObjectOffHeapUnswapTemporaryTest extends GridCommonAbstractTe
}
/**
- *
+ * @param checkOp Check closure.
*/
- private void check(TestCheck<Integer> checkOp) {
+ private void check(IgniteInClosure<Integer> checkOp) {
for (int key = 0; key < 2 * CNT; key++) {
- checkOp.check(key);
+ checkOp.apply(key);
if (atomicityMode == TRANSACTIONAL) {
for (TransactionIsolation isolation : TransactionIsolation.values()) {
for (TransactionConcurrency concurrency : TransactionConcurrency.values()) {
try (Transaction tx = ignite(0).transactions().txStart(concurrency, isolation)) {
- checkOp.check(key);
+ checkOp.apply(key);
tx.commit();
}
@@ -357,14 +358,4 @@ public class BinaryObjectOffHeapUnswapTemporaryTest extends GridCommonAbstractTe
field2 = key;
}
}
-
- /**
- *
- */
- private static interface TestCheck<T> {
- /**
- * @param t Parameter.
- */
- public void check(T t);
- }
}
[26/50] [abbrv] ignite git commit: IGNITE-2861: Added missing Apache
headers.
Posted by sb...@apache.org.
IGNITE-2861: Added missing Apache headers.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/76191ff3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/76191ff3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/76191ff3
Branch: refs/heads/ignite-1837
Commit: 76191ff39456a30246df3aca7c026773d00a8446
Parents: 2cd0dcb
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Mar 21 10:36:26 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Mar 29 15:13:53 2016 +0300
----------------------------------------------------------------------
.../meta/IgfsMetaDirectoryCreateProcessor.java | 17 +++++++++++++++++
.../meta/IgfsMetaDirectoryListingAddProcessor.java | 17 +++++++++++++++++
.../IgfsMetaDirectoryListingRemoveProcessor.java | 17 +++++++++++++++++
.../IgfsMetaDirectoryListingReplaceProcessor.java | 17 +++++++++++++++++
.../igfs/meta/IgfsMetaFileCreateProcessor.java | 17 +++++++++++++++++
.../igfs/meta/IgfsMetaFileLockProcessor.java | 17 +++++++++++++++++
.../meta/IgfsMetaFileRangeDeleteProcessor.java | 17 +++++++++++++++++
.../meta/IgfsMetaFileRangeUpdateProcessor.java | 17 +++++++++++++++++
.../meta/IgfsMetaFileReserveSpaceProcessor.java | 17 +++++++++++++++++
.../igfs/meta/IgfsMetaFileUnlockProcessor.java | 17 +++++++++++++++++
.../igfs/meta/IgfsMetaUpdatePathProcessor.java | 17 +++++++++++++++++
.../meta/IgfsMetaUpdatePropertiesProcessor.java | 17 +++++++++++++++++
.../igfs/meta/IgfsMetaUpdateTimesProcessor.java | 17 +++++++++++++++++
13 files changed, 221 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
index ded66bf..dcca298 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryCreateProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.binary.BinaryObjectException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
index d45dea1..f27bdd5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingAddProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.IgniteException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java
index d5da117..15eb9c8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingRemoveProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.IgniteException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
index bf3c288..dfc9bfc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaDirectoryListingReplaceProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.IgniteException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
index 418227a..41745f1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileCreateProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.binary.BinaryObjectException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java
index ff71f13..3258f10 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileLockProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.binary.BinaryObjectException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java
index cdf07d1..f3132a0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeDeleteProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.binary.BinaryObjectException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java
index e1224de..a6b756f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileRangeUpdateProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.binary.BinaryObjectException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java
index a54ddcc..a1ed55f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileReserveSpaceProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.binary.BinaryObjectException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java
index 0d06c92..6827e4a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaFileUnlockProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.binary.BinaryObjectException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
index 81c1806..782b25b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePathProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.binary.BinaryObjectException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
index a9751c6..fb4466b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdatePropertiesProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.binary.BinaryObjectException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/76191ff3/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java
index b754f19..de03fac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/meta/IgfsMetaUpdateTimesProcessor.java
@@ -1,3 +1,20 @@
+/*
+ * 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.meta;
import org.apache.ignite.binary.BinaryObjectException;
[20/50] [abbrv] ignite git commit: IGNITE-2813: IGFS: Optimized
metadata values splitting file and directory into separate classes.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
index d91b0bc..84e4dae 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsMetaManager.java
@@ -86,8 +86,6 @@ import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.CountDownLatch;
-import static org.apache.ignite.internal.processors.igfs.IgfsFileInfo.builder;
-
/**
* Cache based structure (meta data) manager.
*/
@@ -117,7 +115,7 @@ public class IgfsMetaManager extends IgfsManager {
private CountDownLatch metaCacheStartLatch;
/** File ID to file info projection. */
- private IgniteInternalCache<IgniteUuid, IgfsFileInfo> id2InfoPrj;
+ private IgniteInternalCache<IgniteUuid, IgfsEntryInfo> id2InfoPrj;
/** Predefined key for sampling mode value. */
private GridCacheInternal sampling;
@@ -175,7 +173,7 @@ public class IgfsMetaManager extends IgfsManager {
}
});
- id2InfoPrj = (IgniteInternalCache<IgniteUuid, IgfsFileInfo>)metaCache.<IgniteUuid, IgfsFileInfo>cache();
+ id2InfoPrj = (IgniteInternalCache<IgniteUuid, IgfsEntryInfo>)metaCache.<IgniteUuid, IgfsEntryInfo>cache();
locNode = igfsCtx.kernalContext().discovery().localNode();
@@ -440,17 +438,17 @@ public class IgfsMetaManager extends IgfsManager {
* @return File info.
* @throws IgniteCheckedException If failed.
*/
- @Nullable public IgfsFileInfo info(@Nullable IgniteUuid fileId) throws IgniteCheckedException {
+ @Nullable public IgfsEntryInfo info(@Nullable IgniteUuid fileId) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
if (fileId == null)
return null;
- IgfsFileInfo info = getInfo(fileId);
+ IgfsEntryInfo info = getInfo(fileId);
// Force root ID always exist in cache.
if (info == null && IgfsUtils.ROOT_ID.equals(fileId))
- info = createSystemEntryIfAbsent(fileId);
+ info = createSystemDirectoryIfAbsent(fileId);
return info;
}
@@ -469,7 +467,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Files details.
* @throws IgniteCheckedException If failed.
*/
- public Map<IgniteUuid, IgfsFileInfo> infos(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
+ public Map<IgniteUuid, IgfsEntryInfo> infos(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
validTxState(false);
@@ -479,13 +477,13 @@ public class IgfsMetaManager extends IgfsManager {
if (F.isEmpty(fileIds))
return Collections.emptyMap();
- Map<IgniteUuid, IgfsFileInfo> map = getInfos(fileIds);
+ Map<IgniteUuid, IgfsEntryInfo> map = getInfos(fileIds);
// Force root ID always exist in cache.
if (fileIds.contains(IgfsUtils.ROOT_ID) && !map.containsKey(IgfsUtils.ROOT_ID)) {
map = new GridLeanMap<>(map);
- map.put(IgfsUtils.ROOT_ID, createSystemEntryIfAbsent(IgfsUtils.ROOT_ID));
+ map.put(IgfsUtils.ROOT_ID, createSystemDirectoryIfAbsent(IgfsUtils.ROOT_ID));
}
return map;
@@ -506,7 +504,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Locked file info or {@code null} if file cannot be locked or doesn't exist.
* @throws IgniteCheckedException If the file with such id does not exist, or on another failure.
*/
- public @Nullable IgfsFileInfo lock(IgniteUuid fileId, boolean delete) throws IgniteCheckedException {
+ public @Nullable IgfsEntryInfo lock(IgniteUuid fileId, boolean delete) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
validTxState(false);
@@ -517,7 +515,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
// Lock file ID for this transaction.
- IgfsFileInfo oldInfo = info(fileId);
+ IgfsEntryInfo oldInfo = info(fileId);
if (oldInfo == null)
return null;
@@ -525,7 +523,7 @@ public class IgfsMetaManager extends IgfsManager {
if (oldInfo.lockId() != null)
return null; // The file is already locked, we cannot lock it.
- IgfsFileInfo newInfo = invokeLock(fileId, delete);
+ IgfsEntryInfo newInfo = invokeLock(fileId, delete);
tx.commit();
@@ -566,7 +564,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param modificationTime Modification time to write to file info.
* @throws IgniteCheckedException If failed.
*/
- public void unlock(final IgfsFileInfo info, final long modificationTime) throws IgniteCheckedException {
+ public void unlock(final IgfsEntryInfo info, final long modificationTime) throws IgniteCheckedException {
validTxState(false);
assert info != null;
@@ -589,7 +587,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteUuid fileId = info.id();
// Lock file ID for this transaction.
- IgfsFileInfo oldInfo = info(fileId);
+ IgfsEntryInfo oldInfo = info(fileId);
if (oldInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to unlock file (file not " +
@@ -628,7 +626,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Locked file details. Resulting map doesn't contain details for not-existent files.
* @throws IgniteCheckedException If failed.
*/
- private Map<IgniteUuid, IgfsFileInfo> lockIds(IgniteUuid... fileIds) throws IgniteCheckedException {
+ private Map<IgniteUuid, IgfsEntryInfo> lockIds(IgniteUuid... fileIds) throws IgniteCheckedException {
validTxState(true);
assert fileIds != null && fileIds.length > 0;
@@ -668,7 +666,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Map with lock info.
* @throws IgniteCheckedException If failed.
*/
- private Map<IgniteUuid, IgfsFileInfo> lockIds(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
+ private Map<IgniteUuid, IgfsEntryInfo> lockIds(Collection<IgniteUuid> fileIds) throws IgniteCheckedException {
assert isSorted(fileIds);
validTxState(true);
@@ -676,7 +674,7 @@ public class IgfsMetaManager extends IgfsManager {
log.debug("Locking file ids: " + fileIds);
// Lock files and get their infos.
- Map<IgniteUuid, IgfsFileInfo> map = getInfos(fileIds);
+ Map<IgniteUuid, IgfsEntryInfo> map = getInfos(fileIds);
if (log.isDebugEnabled())
log.debug("Locked file ids: " + fileIds);
@@ -684,7 +682,7 @@ public class IgfsMetaManager extends IgfsManager {
for (IgniteUuid fileId : fileIds) {
if (IgfsUtils.isRootOrTrashId(fileId)) {
if (!map.containsKey(fileId))
- map.put(fileId, createSystemEntryIfAbsent(fileId));
+ map.put(fileId, createSystemDirectoryIfAbsent(fileId));
}
}
@@ -699,13 +697,15 @@ public class IgfsMetaManager extends IgfsManager {
* @return Value of created or existing system entry.
* @throws IgniteCheckedException On error.
*/
- private IgfsFileInfo createSystemEntryIfAbsent(IgniteUuid id)
+ private IgfsEntryInfo createSystemDirectoryIfAbsent(IgniteUuid id)
throws IgniteCheckedException {
assert IgfsUtils.isRootOrTrashId(id);
- IgfsFileInfo info = new IgfsFileInfo(id);
+ long time = System.currentTimeMillis();
+
+ IgfsEntryInfo info = IgfsUtils.createDirectory(id);
- IgfsFileInfo oldInfo = id2InfoPrj.getAndPutIfAbsent(id, info);
+ IgfsEntryInfo oldInfo = id2InfoPrj.getAndPutIfAbsent(id, info);
if (oldInfo != null)
info = oldInfo;
@@ -740,7 +740,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return First qualified file info.
* @throws IgniteCheckedException If failed to get file for fragmentizer.
*/
- public IgfsFileInfo fileForFragmentizer(Collection<IgniteUuid> exclude) throws IgniteCheckedException {
+ public IgfsEntryInfo fileForFragmentizer(Collection<IgniteUuid> exclude) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
return fileForFragmentizer0(IgfsUtils.ROOT_ID, exclude);
@@ -761,9 +761,9 @@ public class IgfsMetaManager extends IgfsManager {
* @return First qualified file info.
* @throws IgniteCheckedException If failed to get file for fragmentizer.
*/
- private IgfsFileInfo fileForFragmentizer0(IgniteUuid parentId, Collection<IgniteUuid> exclude)
+ private IgfsEntryInfo fileForFragmentizer0(IgniteUuid parentId, Collection<IgniteUuid> exclude)
throws IgniteCheckedException {
- IgfsFileInfo info = info(parentId);
+ IgfsEntryInfo info = info(parentId);
// Check if file was concurrently deleted.
if (info == null)
@@ -775,7 +775,7 @@ public class IgfsMetaManager extends IgfsManager {
for (IgfsListingEntry entry : listing.values()) {
if (entry.isFile()) {
- IgfsFileInfo fileInfo = info(entry.fileId());
+ IgfsEntryInfo fileInfo = info(entry.fileId());
if (fileInfo != null) {
if (!exclude.contains(fileInfo.id()) &&
@@ -785,7 +785,7 @@ public class IgfsMetaManager extends IgfsManager {
}
}
else {
- IgfsFileInfo fileInfo = fileForFragmentizer0(entry.fileId(), exclude);
+ IgfsEntryInfo fileInfo = fileForFragmentizer0(entry.fileId(), exclude);
if (fileInfo != null)
return fileInfo;
@@ -807,7 +807,7 @@ public class IgfsMetaManager extends IgfsManager {
throws IgniteCheckedException {
assert fileId != null;
- IgfsFileInfo info = skipTx ? id2InfoPrj.getAllOutTx(Collections.singleton(fileId)).get(fileId) :
+ IgfsEntryInfo info = skipTx ? id2InfoPrj.getAllOutTx(Collections.singleton(fileId)).get(fileId) :
getInfo(fileId);
return info == null ? Collections.<String, IgfsListingEntry>emptyMap() : info.listing();
@@ -822,7 +822,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return File id already stored in meta cache or {@code null} if passed file info was stored.
* @throws IgniteCheckedException If failed.
*/
- private IgniteUuid putIfAbsentNonTx(IgniteUuid parentId, String fileName, IgfsFileInfo newFileInfo)
+ private IgniteUuid putIfAbsentNonTx(IgniteUuid parentId, String fileName, IgfsEntryInfo newFileInfo)
throws IgniteCheckedException {
if (log.isDebugEnabled())
log.debug("Locking parent id [parentId=" + parentId + ", fileName=" + fileName + ", newFileInfo=" +
@@ -831,7 +831,7 @@ public class IgfsMetaManager extends IgfsManager {
validTxState(true);
// Lock only parent file ID.
- IgfsFileInfo parentInfo = info(parentId);
+ IgfsEntryInfo parentInfo = info(parentId);
if (parentInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to lock parent directory (not found): " +
@@ -858,7 +858,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return File info of renamed entry.
* @throws IgniteCheckedException In case of exception.
*/
- public IgfsFileInfo move(IgfsPath srcPath, IgfsPath dstPath) throws IgniteCheckedException {
+ public IgfsEntryInfo move(IgfsPath srcPath, IgfsPath dstPath) throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
validTxState(false);
@@ -902,7 +902,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
// Obtain the locks.
- final Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(lockIds);
+ final Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
// Verify integrity of source and destination paths.
if (!srcPathIds.verifyIntegrity(lockInfos))
@@ -914,7 +914,7 @@ public class IgfsMetaManager extends IgfsManager {
"structure changed concurrently [src=" + srcPath + ", dst=" + dstPath + ']');
// Addiional check: is destination directory?
- IgfsFileInfo dstParentInfo = lockInfos.get(dstPathIds.lastId());
+ IgfsEntryInfo dstParentInfo = lockInfos.get(dstPathIds.lastId());
if (dstParentInfo.isFile())
throw new IgfsPathAlreadyExistsException("Failed to perform move because destination points " +
@@ -927,9 +927,9 @@ public class IgfsMetaManager extends IgfsManager {
", dst=" + dstPath + ']');
// Actual move: remove from source parent and add to destination target.
- IgfsFileInfo srcParentInfo = lockInfos.get(srcPathIds.lastParentId());
+ IgfsEntryInfo srcParentInfo = lockInfos.get(srcPathIds.lastParentId());
- IgfsFileInfo srcInfo = lockInfos.get(srcPathIds.lastId());
+ IgfsEntryInfo srcInfo = lockInfos.get(srcPathIds.lastId());
String srcName = srcPathIds.lastPart();
IgfsListingEntry srcEntry = srcParentInfo.listing().get(srcName);
@@ -940,7 +940,7 @@ public class IgfsMetaManager extends IgfsManager {
IgfsPath newPath = new IgfsPath(dstPathIds.path(), dstName);
// Set the new path to the info to simplify event creation:
- return IgfsFileInfo.builder(srcInfo).path(newPath).build();
+ return srcInfo.path(newPath);
}
finally {
tx.close();
@@ -965,7 +965,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return verification result.
*/
private static boolean verifyPathIntegrity(IgfsPath path, List<IgniteUuid> expIds,
- Map<IgniteUuid, IgfsFileInfo> infos) {
+ Map<IgniteUuid, IgfsEntryInfo> infos) {
List<String> pathParts = path.components();
assert pathParts.size() < expIds.size();
@@ -975,7 +975,7 @@ public class IgfsMetaManager extends IgfsManager {
// If parent ID is null, it doesn't exist.
if (parentId != null) {
- IgfsFileInfo parentInfo = infos.get(parentId);
+ IgfsEntryInfo parentInfo = infos.get(parentId);
// If parent info is null, it doesn't exist.
if (parentInfo != null) {
@@ -1019,9 +1019,9 @@ public class IgfsMetaManager extends IgfsManager {
}
// Lock file ID and parent IDs for this transaction.
- Map<IgniteUuid, IgfsFileInfo> infoMap = lockIds(srcParentId, fileId, destParentId);
+ Map<IgniteUuid, IgfsEntryInfo> infoMap = lockIds(srcParentId, fileId, destParentId);
- IgfsFileInfo srcInfo = infoMap.get(srcParentId);
+ IgfsEntryInfo srcInfo = infoMap.get(srcParentId);
if (srcInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to lock source directory (not found?)" +
@@ -1030,7 +1030,7 @@ public class IgfsMetaManager extends IgfsManager {
if (!srcInfo.isDirectory())
throw fsException(new IgfsPathIsNotDirectoryException("Source is not a directory: " + srcInfo));
- IgfsFileInfo destInfo = infoMap.get(destParentId);
+ IgfsEntryInfo destInfo = infoMap.get(destParentId);
if (destInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to lock destination directory (not found?)" +
@@ -1039,7 +1039,7 @@ public class IgfsMetaManager extends IgfsManager {
if (!destInfo.isDirectory())
throw fsException(new IgfsPathIsNotDirectoryException("Destination is not a directory: " + destInfo));
- IgfsFileInfo fileInfo = infoMap.get(fileId);
+ IgfsEntryInfo fileInfo = infoMap.get(fileId);
if (fileInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to lock target file (not found?) [fileId=" +
@@ -1080,7 +1080,7 @@ public class IgfsMetaManager extends IgfsManager {
try {
// NB: We may lock root because its id is less than any other id:
- final IgfsFileInfo rootInfo = lockIds(IgfsUtils.ROOT_ID, trashId).get(IgfsUtils.ROOT_ID);
+ final IgfsEntryInfo rootInfo = lockIds(IgfsUtils.ROOT_ID, trashId).get(IgfsUtils.ROOT_ID);
assert rootInfo != null;
@@ -1094,13 +1094,17 @@ public class IgfsMetaManager extends IgfsManager {
// Construct new info and move locked entries from root to it.
Map<String, IgfsListingEntry> transferListing = new HashMap<>(rootListingMap);
- IgfsFileInfo newInfo = new IgfsFileInfo(transferListing);
+ IgfsEntryInfo newInfo = IgfsUtils.createDirectory(
+ IgniteUuid.randomUuid(),
+ transferListing,
+ (Map<String,String>)null
+ );
createNewEntry(newInfo, trashId, newInfo.id().toString());
// Remove listing entries from root.
// Note that root directory properties and other attributes are preserved:
- id2InfoPrj.put(IgfsUtils.ROOT_ID, new IgfsFileInfo(null/*listing*/, rootInfo));
+ id2InfoPrj.put(IgfsUtils.ROOT_ID, rootInfo.listing(null));
tx.commit();
@@ -1159,13 +1163,13 @@ public class IgfsMetaManager extends IgfsManager {
try {
// Lock participants.
- Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(allIds);
+ Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(allIds);
// Ensure that all participants are still in place.
if (!pathIds.verifyIntegrity(lockInfos))
return null;
- IgfsFileInfo victimInfo = lockInfos.get(victimId);
+ IgfsEntryInfo victimInfo = lockInfos.get(victimId);
// Cannot delete non-empty directory if recursive flag is not set.
if (!recursive && victimInfo.hasChildren())
@@ -1173,14 +1177,14 @@ public class IgfsMetaManager extends IgfsManager {
"empty and recursive flag is not set).");
// Prepare trash data.
- IgfsFileInfo trashInfo = lockInfos.get(trashId);
+ IgfsEntryInfo trashInfo = lockInfos.get(trashId);
final String trashName = victimId.toString();
assert !trashInfo.hasChild(trashName) : "Failed to add file name into the " +
"destination directory (file already exists) [destName=" + trashName + ']';
IgniteUuid parentId = pathIds.lastParentId();
- IgfsFileInfo parentInfo = lockInfos.get(parentId);
+ IgfsEntryInfo parentInfo = lockInfos.get(parentId);
transferEntry(parentInfo.listing().get(victimName), parentId, victimName, trashId, trashName);
@@ -1227,13 +1231,13 @@ public class IgfsMetaManager extends IgfsManager {
// Handle special case when we deleting root directory.
assert IgfsUtils.ROOT_ID.equals(id);
- IgfsFileInfo rootInfo = getInfo(IgfsUtils.ROOT_ID);
+ IgfsEntryInfo rootInfo = getInfo(IgfsUtils.ROOT_ID);
if (rootInfo == null)
return null; // Root was never created.
// Ensure trash directory existence.
- createSystemEntryIfAbsent(trashId);
+ createSystemDirectoryIfAbsent(trashId);
Map<String, IgfsListingEntry> rootListing = rootInfo.listing();
@@ -1253,13 +1257,18 @@ public class IgfsMetaManager extends IgfsManager {
transferListing.putAll(rootListing);
- IgfsFileInfo newInfo = new IgfsFileInfo(transferListing);
+ IgfsEntryInfo newInfo = IgfsUtils.createDirectory(
+ IgniteUuid.randomUuid(),
+ transferListing,
+ (Map<String,String>)null
+ );
createNewEntry(newInfo, trashId, newInfo.id().toString());
// Remove listing entries from root.
for (Map.Entry<String, IgfsListingEntry> entry : transferListing.entrySet())
- id2InfoPrj.invoke(IgfsUtils.ROOT_ID, new ListingRemoveProcessor(entry.getKey(), entry.getValue().fileId()));
+ id2InfoPrj.invoke(IgfsUtils.ROOT_ID,
+ new ListingRemoveProcessor(entry.getKey(), entry.getValue().fileId()));
resId = newInfo.id();
}
@@ -1268,7 +1277,7 @@ public class IgfsMetaManager extends IgfsManager {
}
else {
// Ensure trash directory existence.
- createSystemEntryIfAbsent(trashId);
+ createSystemDirectoryIfAbsent(trashId);
moveNonTx(id, name, parentId, id.toString(), trashId);
@@ -1310,9 +1319,9 @@ public class IgfsMetaManager extends IgfsManager {
for (IgfsListingEntry childEntry : listing.values())
allIds[i++] = childEntry.fileId();
- Map<IgniteUuid, IgfsFileInfo> locks = lockIds(allIds);
+ Map<IgniteUuid, IgfsEntryInfo> locks = lockIds(allIds);
- IgfsFileInfo parentInfo = locks.get(parentId);
+ IgfsEntryInfo parentInfo = locks.get(parentId);
// Ensure parent is still in place.
if (parentInfo != null) {
@@ -1327,7 +1336,7 @@ public class IgfsMetaManager extends IgfsManager {
String childName = entry.getKey();
IgniteUuid childId = entry.getValue().fileId();
- IgfsFileInfo entryInfo = locks.get(childId);
+ IgfsEntryInfo entryInfo = locks.get(childId);
if (entryInfo != null) {
// File must be locked for deletion:
@@ -1351,7 +1360,7 @@ public class IgfsMetaManager extends IgfsManager {
}
// Update parent listing.
- id2InfoPrj.put(parentId, new IgfsFileInfo(newListing, parentInfo));
+ id2InfoPrj.put(parentId, parentInfo.listing(newListing));
}
tx.commit();
@@ -1391,9 +1400,9 @@ public class IgfsMetaManager extends IgfsManager {
try {
boolean res = false;
- Map<IgniteUuid, IgfsFileInfo> infos = lockIds(parentId, id);
+ Map<IgniteUuid, IgfsEntryInfo> infos = lockIds(parentId, id);
- IgfsFileInfo victim = infos.get(id);
+ IgfsEntryInfo victim = infos.get(id);
if (victim == null)
return res;
@@ -1403,7 +1412,7 @@ public class IgfsMetaManager extends IgfsManager {
// Proceed only in case both parent and child exist.
if (infos.containsKey(parentId) && infos.containsKey(id)) {
- IgfsFileInfo parentInfo = infos.get(parentId);
+ IgfsEntryInfo parentInfo = infos.get(parentId);
assert parentInfo != null;
@@ -1448,7 +1457,7 @@ public class IgfsMetaManager extends IgfsManager {
for (int i = 0; i < IgfsUtils.TRASH_CONCURRENCY; i++) {
IgniteUuid trashId = IgfsUtils.trashId(i);
- IgfsFileInfo trashInfo = getInfo(trashId);
+ IgfsEntryInfo trashInfo = getInfo(trashId);
if (trashInfo != null && trashInfo.hasChildren()) {
for (IgfsListingEntry entry : trashInfo.listing().values())
@@ -1474,7 +1483,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Updated file info or {@code null} if such file ID not found.
* @throws IgniteCheckedException If operation failed.
*/
- @Nullable private IgfsFileInfo updatePropertiesNonTx(final IgniteUuid fileId, Map<String, String> props)
+ @Nullable private IgfsEntryInfo updatePropertiesNonTx(final IgniteUuid fileId, Map<String, String> props)
throws IgniteCheckedException {
assert fileId != null;
assert !F.isEmpty(props) : "Expects not-empty file's properties";
@@ -1485,7 +1494,7 @@ public class IgfsMetaManager extends IgfsManager {
log.debug("Update file properties [fileId=" + fileId + ", props=" + props + ']');
try {
- final IgfsFileInfo oldInfo = info(fileId);
+ final IgfsEntryInfo oldInfo = info(fileId);
if (oldInfo == null)
return null;
@@ -1505,7 +1514,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Updated file info or {@code null} if such file ID not found.
* @throws IgniteCheckedException If operation failed.
*/
- @Nullable public IgfsFileInfo updateProperties(IgniteUuid fileId, Map<String, String> props)
+ @Nullable public IgfsEntryInfo updateProperties(IgniteUuid fileId, Map<String, String> props)
throws IgniteCheckedException {
if (busyLock.enterBusy()) {
try {
@@ -1514,7 +1523,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteInternalTx tx = startTx();
try {
- IgfsFileInfo info = updatePropertiesNonTx(fileId, props);
+ IgfsEntryInfo info = updatePropertiesNonTx(fileId, props);
tx.commit();
@@ -1542,7 +1551,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param affRange Affinity range.
* @return New file info.
*/
- public IgfsFileInfo reserveSpace(IgfsPath path, IgniteUuid fileId, long space, IgfsFileAffinityRange affRange)
+ public IgfsEntryInfo reserveSpace(IgfsPath path, IgniteUuid fileId, long space, IgfsFileAffinityRange affRange)
throws IgniteCheckedException {
validTxState(false);
@@ -1555,12 +1564,12 @@ public class IgfsMetaManager extends IgfsManager {
try {
// Lock file ID for this transaction.
- IgfsFileInfo oldInfo = info(fileId);
+ IgfsEntryInfo oldInfo = info(fileId);
if (oldInfo == null)
throw fsException("File has been deleted concurrently [path=" + path + ", id=" + fileId + ']');
- IgfsFileInfo newInfo = invokeAndGet(fileId, new FileReserveSpaceProcessor(space, affRange));
+ IgfsEntryInfo newInfo = invokeAndGet(fileId, new FileReserveSpaceProcessor(space, affRange));
tx.commit();
@@ -1590,8 +1599,8 @@ public class IgfsMetaManager extends IgfsManager {
* @return Updated file info or {@code null} if such file ID not found.
* @throws IgniteCheckedException If failed.
*/
- @Nullable public IgfsFileInfo updateInfo(IgniteUuid fileId,
- EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo> proc) throws IgniteCheckedException {
+ @Nullable public IgfsEntryInfo updateInfo(IgniteUuid fileId,
+ EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo> proc) throws IgniteCheckedException {
validTxState(false);
assert fileId != null;
assert proc != null;
@@ -1605,12 +1614,12 @@ public class IgfsMetaManager extends IgfsManager {
try {
// Lock file ID for this transaction.
- IgfsFileInfo oldInfo = info(fileId);
+ IgfsEntryInfo oldInfo = info(fileId);
if (oldInfo == null)
return null; // File not found.
- IgfsFileInfo newInfo = invokeAndGet(fileId, proc);
+ IgfsEntryInfo newInfo = invokeAndGet(fileId, proc);
if (newInfo == null)
throw fsException("Failed to update file info with null value" +
@@ -1673,7 +1682,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteInternalTx tx = startTx();
try {
- final Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(lockIds);
+ final Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (!pathIds.verifyIntegrity(lockInfos))
// Directory structure changed concurrently. So we simply re-try.
@@ -1779,7 +1788,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param name Name in parent.
* @throws IgniteCheckedException If failed.
*/
- private void createNewEntry(IgfsFileInfo info, IgniteUuid parentId, String name) throws IgniteCheckedException {
+ private void createNewEntry(IgfsEntryInfo info, IgniteUuid parentId, String name) throws IgniteCheckedException {
validTxState(true);
if (!id2InfoPrj.putIfAbsent(info.id(), info))
@@ -1815,7 +1824,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Resulting file info.
* @throws IgniteCheckedException If failed.
*/
- private IgfsFileInfo invokeLock(IgniteUuid id, boolean delete) throws IgniteCheckedException {
+ private IgfsEntryInfo invokeLock(IgniteUuid id, boolean delete) throws IgniteCheckedException {
return invokeAndGet(id, new FileLockProcessor(createFileLockId(delete)));
}
@@ -1840,7 +1849,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return New file info.
* @throws IgniteCheckedException If failed.
*/
- private IgfsFileInfo invokeAndGet(IgniteUuid id, EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo> proc)
+ private IgfsEntryInfo invokeAndGet(IgniteUuid id, EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo> proc)
throws IgniteCheckedException {
validTxState(true);
@@ -1854,7 +1863,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Info.
* @throws IgniteCheckedException If failed.
*/
- @Nullable private IgfsFileInfo getInfo(IgniteUuid id) throws IgniteCheckedException {
+ @Nullable private IgfsEntryInfo getInfo(IgniteUuid id) throws IgniteCheckedException {
return id2InfoPrj.get(id);
}
@@ -1865,7 +1874,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Infos map.
* @throws IgniteCheckedException If failed.
*/
- private Map<IgniteUuid, IgfsFileInfo> getInfos(Collection<IgniteUuid> ids) throws IgniteCheckedException {
+ private Map<IgniteUuid, IgfsEntryInfo> getInfos(Collection<IgniteUuid> ids) throws IgniteCheckedException {
return id2InfoPrj.getAll(ids);
}
@@ -1909,7 +1918,7 @@ public class IgfsMetaManager extends IgfsManager {
private OutputStream out;
@Override public IgfsSecondaryOutputStreamDescriptor onSuccess(Map<IgfsPath,
- IgfsFileInfo> infos) throws Exception {
+ IgfsEntryInfo> infos) throws Exception {
validTxState(true);
assert !infos.isEmpty();
@@ -1924,7 +1933,7 @@ public class IgfsMetaManager extends IgfsManager {
assert parentPath != null;
- IgfsFileInfo parentInfo = infos.get(parentPath);
+ IgfsEntryInfo parentInfo = infos.get(parentPath);
// Delegate to the secondary file system.
out = simpleCreate ? fs.create(path, overwrite) :
@@ -1963,15 +1972,23 @@ public class IgfsMetaManager extends IgfsManager {
throw fsException("Failed to open output stream to the file created in " +
"the secondary file system because the path points to a directory: " + path);
- IgfsFileInfo newInfo = new IgfsFileInfo(status.blockSize(), status.length(), affKey,
- createFileLockId(false), igfsCtx.igfs().evictExclude(path, false), status.properties(),
- status.accessTime(), status.modificationTime());
+ IgfsEntryInfo newInfo = IgfsUtils.createFile(
+ IgniteUuid.randomUuid(),
+ status.blockSize(),
+ status.length(),
+ affKey,
+ createFileLockId(false),
+ igfsCtx.igfs().evictExclude(path, false),
+ status.properties(),
+ status.accessTime(),
+ status.modificationTime()
+ );
// Add new file info to the listing optionally removing the previous one.
IgniteUuid oldId = putIfAbsentNonTx(parentInfo.id(), path.name(), newInfo);
if (oldId != null) {
- IgfsFileInfo oldInfo = info(oldId);
+ IgfsEntryInfo oldInfo = info(oldId);
assert oldInfo != null; // Otherwise cache is in inconsistent state.
@@ -2047,10 +2064,10 @@ public class IgfsMetaManager extends IgfsManager {
private OutputStream out;
@Override public IgfsSecondaryOutputStreamDescriptor onSuccess(Map<IgfsPath,
- IgfsFileInfo> infos) throws Exception {
+ IgfsEntryInfo> infos) throws Exception {
validTxState(true);
- final IgfsFileInfo info = infos.get(path);
+ final IgfsEntryInfo info = infos.get(path);
if (info.isDirectory())
throw fsException("Failed to open output stream to the file in the " +
@@ -2083,7 +2100,7 @@ public class IgfsMetaManager extends IgfsManager {
}
// Set lock and return.
- IgfsFileInfo lockedInfo = invokeLock(info.id(), false);
+ IgfsEntryInfo lockedInfo = invokeLock(info.id(), false);
return new IgfsSecondaryOutputStreamDescriptor(infos.get(path.parent()).id(),
lockedInfo, out);
@@ -2129,7 +2146,7 @@ public class IgfsMetaManager extends IgfsManager {
assert path != null;
// First, try getting file info without any transactions and synchronization.
- IgfsFileInfo info = info(fileId(path));
+ IgfsEntryInfo info = info(fileId(path));
if (info != null) {
if (!info.isFile())
@@ -2143,8 +2160,8 @@ public class IgfsMetaManager extends IgfsManager {
SynchronizationTask<IgfsSecondaryInputStreamDescriptor> task =
new SynchronizationTask<IgfsSecondaryInputStreamDescriptor>() {
@Override public IgfsSecondaryInputStreamDescriptor onSuccess(
- Map<IgfsPath, IgfsFileInfo> infos) throws Exception {
- IgfsFileInfo info = infos.get(path);
+ Map<IgfsPath, IgfsEntryInfo> infos) throws Exception {
+ IgfsEntryInfo info = infos.get(path);
if (info == null)
throw fsException(new IgfsPathNotFoundException("File not found: " + path));
@@ -2183,7 +2200,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return File info or {@code null} if file not found.
* @throws IgniteCheckedException If sync task failed.
*/
- @Nullable public IgfsFileInfo synchronizeFileDual(final IgfsSecondaryFileSystem fs, final IgfsPath path)
+ @Nullable public IgfsEntryInfo synchronizeFileDual(final IgfsSecondaryFileSystem fs, final IgfsPath path)
throws IgniteCheckedException {
assert fs != null;
assert path != null;
@@ -2191,20 +2208,20 @@ public class IgfsMetaManager extends IgfsManager {
if (busyLock.enterBusy()) {
try {
// First, try getting file info without any transactions and synchronization.
- IgfsFileInfo info = info(fileId(path));
+ IgfsEntryInfo info = info(fileId(path));
if (info != null)
return info;
// If failed, try synchronize.
- SynchronizationTask<IgfsFileInfo> task =
- new SynchronizationTask<IgfsFileInfo>() {
- @Override public IgfsFileInfo onSuccess(Map<IgfsPath, IgfsFileInfo> infos)
+ SynchronizationTask<IgfsEntryInfo> task =
+ new SynchronizationTask<IgfsEntryInfo>() {
+ @Override public IgfsEntryInfo onSuccess(Map<IgfsPath, IgfsEntryInfo> infos)
throws Exception {
return infos.get(path);
}
- @Override public IgfsFileInfo onFailure(@Nullable Exception err) throws IgniteCheckedException {
+ @Override public IgfsEntryInfo onFailure(@Nullable Exception err) throws IgniteCheckedException {
throw new IgniteCheckedException("Failed to synchronize path due to secondary file " +
"system exception: " + path, err);
}
@@ -2246,7 +2263,7 @@ public class IgfsMetaManager extends IgfsManager {
final Deque<IgfsEvent> pendingEvts = new LinkedList<>();
SynchronizationTask<Boolean> task = new SynchronizationTask<Boolean>() {
- @Override public Boolean onSuccess(Map<IgfsPath, IgfsFileInfo> infos) throws Exception {
+ @Override public Boolean onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception {
fs.mkdirs(path, props);
assert !infos.isEmpty();
@@ -2261,7 +2278,7 @@ public class IgfsMetaManager extends IgfsManager {
assert parentPath != null;
- IgfsFileInfo parentPathInfo = infos.get(parentPath);
+ IgfsEntryInfo parentPathInfo = infos.get(parentPath);
synchronize(fs, parentPath, parentPathInfo, path, true, null);
@@ -2330,11 +2347,11 @@ public class IgfsMetaManager extends IgfsManager {
final Collection<IgfsEvent> pendingEvts = new LinkedList<>();
SynchronizationTask<Boolean> task = new SynchronizationTask<Boolean>() {
- @Override public Boolean onSuccess(Map<IgfsPath, IgfsFileInfo> infos) throws Exception {
- IgfsFileInfo srcInfo = infos.get(src);
- IgfsFileInfo srcParentInfo = infos.get(src.parent());
- IgfsFileInfo destInfo = infos.get(dest);
- IgfsFileInfo destParentInfo = dest.parent() != null ? infos.get(dest.parent()) : null;
+ @Override public Boolean onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception {
+ IgfsEntryInfo srcInfo = infos.get(src);
+ IgfsEntryInfo srcParentInfo = infos.get(src.parent());
+ IgfsEntryInfo destInfo = infos.get(dest);
+ IgfsEntryInfo destParentInfo = dest.parent() != null ? infos.get(dest.parent()) : null;
// Source path and destination (or destination parent) must exist.
if (srcInfo == null)
@@ -2424,8 +2441,8 @@ public class IgfsMetaManager extends IgfsManager {
final IgniteUuid trashId = IgfsUtils.randomTrashId();
SynchronizationTask<Boolean> task = new SynchronizationTask<Boolean>() {
- @Override public Boolean onSuccess(Map<IgfsPath, IgfsFileInfo> infos) throws Exception {
- IgfsFileInfo info = infos.get(path);
+ @Override public Boolean onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception {
+ IgfsEntryInfo info = infos.get(path);
if (info == null)
return false; // File doesn't exist in the secondary file system.
@@ -2482,7 +2499,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Update file info.
* @throws IgniteCheckedException If update failed.
*/
- public IgfsFileInfo updateDual(final IgfsSecondaryFileSystem fs, final IgfsPath path,
+ public IgfsEntryInfo updateDual(final IgfsSecondaryFileSystem fs, final IgfsPath path,
final Map<String, String> props) throws IgniteCheckedException {
assert fs != null;
assert path != null;
@@ -2490,8 +2507,8 @@ public class IgfsMetaManager extends IgfsManager {
if (busyLock.enterBusy()) {
try {
- SynchronizationTask<IgfsFileInfo> task = new SynchronizationTask<IgfsFileInfo>() {
- @Override public IgfsFileInfo onSuccess(Map<IgfsPath, IgfsFileInfo> infos) throws Exception {
+ SynchronizationTask<IgfsEntryInfo> task = new SynchronizationTask<IgfsEntryInfo>() {
+ @Override public IgfsEntryInfo onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception {
if (infos.get(path) == null)
return null;
@@ -2500,7 +2517,7 @@ public class IgfsMetaManager extends IgfsManager {
return updatePropertiesNonTx(infos.get(path).id(), props);
}
- @Override public IgfsFileInfo onFailure(@Nullable Exception err) throws IgniteCheckedException {
+ @Override public IgfsEntryInfo onFailure(@Nullable Exception err) throws IgniteCheckedException {
U.error(log, "Path update in DUAL mode failed [path=" + path + ", properties=" + props + ']',
err);
@@ -2531,12 +2548,12 @@ public class IgfsMetaManager extends IgfsManager {
* @return File info of the end path.
* @throws IgniteCheckedException If failed.
*/
- private IgfsFileInfo synchronize(IgfsSecondaryFileSystem fs,
+ private IgfsEntryInfo synchronize(IgfsSecondaryFileSystem fs,
IgfsPath startPath,
- IgfsFileInfo startPathInfo,
+ IgfsEntryInfo startPathInfo,
IgfsPath endPath,
boolean strict,
- @Nullable Map<IgfsPath, IgfsFileInfo> created)
+ @Nullable Map<IgfsPath, IgfsEntryInfo> created)
throws IgniteCheckedException
{
assert fs != null;
@@ -2544,7 +2561,7 @@ public class IgfsMetaManager extends IgfsManager {
validTxState(true);
- IgfsFileInfo parentInfo = startPathInfo;
+ IgfsEntryInfo parentInfo = startPathInfo;
List<String> components = endPath.components();
@@ -2585,11 +2602,25 @@ public class IgfsMetaManager extends IgfsManager {
}
// Recreate the path locally.
- IgfsFileInfo curInfo = status.isDirectory() ?
- new IgfsFileInfo(true, status.properties(), status.accessTime(), status.modificationTime()) :
- new IgfsFileInfo(igfsCtx.configuration().getBlockSize(), status.length(),
- igfsCtx.igfs().evictExclude(curPath, false), status.properties(),
- status.accessTime(), status.modificationTime());
+ IgfsEntryInfo curInfo = status.isDirectory() ?
+ IgfsUtils.createDirectory(
+ IgniteUuid.randomUuid(),
+ null,
+ status.properties(),
+ status.accessTime(),
+ status.modificationTime()
+ ) :
+ IgfsUtils.createFile(
+ IgniteUuid.randomUuid(),
+ igfsCtx.configuration().getBlockSize(),
+ status.length(),
+ null,
+ null,
+ igfsCtx.igfs().evictExclude(curPath, false),
+ status.properties(),
+ status.accessTime(),
+ status.modificationTime()
+ );
IgniteUuid oldId = putIfAbsentNonTx(parentInfo.id(), components.get(i), curInfo);
@@ -2719,7 +2750,7 @@ public class IgfsMetaManager extends IgfsManager {
lockArr[idx++] = id;
}
- Map<IgniteUuid, IgfsFileInfo> idToInfo = lockIds(lockArr);
+ Map<IgniteUuid, IgfsEntryInfo> idToInfo = lockIds(lockArr);
if (extraLockIds != null) {
for (IgniteUuid id : extraLockIds)
@@ -2762,9 +2793,9 @@ public class IgfsMetaManager extends IgfsManager {
continue; // Release all locks and try again.
else {
// Perform synchronization.
- Map<IgfsPath, IgfsFileInfo> infos = new HashMap<>();
+ Map<IgfsPath, IgfsEntryInfo> infos = new HashMap<>();
- TreeMap<IgfsPath, IgfsFileInfo> created = new TreeMap<>();
+ TreeMap<IgfsPath, IgfsEntryInfo> created = new TreeMap<>();
for (IgfsPath path : paths) {
IgfsPath parentPath = path.parent();
@@ -2781,7 +2812,7 @@ public class IgfsMetaManager extends IgfsManager {
assert firstParentPath != null;
assert pathToId.get(firstParentPath) != null;
- IgfsFileInfo info = synchronize(fs,
+ IgfsEntryInfo info = synchronize(fs,
firstParentPath,
idToInfo.get(pathToId.get(firstParentPath)),
path,
@@ -2899,15 +2930,15 @@ public class IgfsMetaManager extends IgfsManager {
IgniteInternalTx tx = startTx();
try {
- Map<IgniteUuid, IgfsFileInfo> infoMap = lockIds(fileId, parentId);
+ Map<IgniteUuid, IgfsEntryInfo> infoMap = lockIds(fileId, parentId);
- IgfsFileInfo fileInfo = infoMap.get(fileId);
+ IgfsEntryInfo fileInfo = infoMap.get(fileId);
if (fileInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to update times " +
"(path was not found): " + fileName));
- IgfsFileInfo parentInfo = infoMap.get(parentId);
+ IgfsEntryInfo parentInfo = infoMap.get(parentId);
if (parentInfo == null)
throw fsException(new IgfsPathNotFoundException("Failed to update times " +
@@ -2967,7 +2998,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Task result.
* @throws Exception If failed.
*/
- public T onSuccess(Map<IgfsPath, IgfsFileInfo> infos) throws Exception;
+ public T onSuccess(Map<IgfsPath, IgfsEntryInfo> infos) throws Exception;
/**
* Callback handler in case synchronization failed.
@@ -2993,7 +3024,7 @@ public class IgfsMetaManager extends IgfsManager {
private IgfsPath parentPath;
/** Parent path info. */
- private IgfsFileInfo parentInfo;
+ private IgfsEntryInfo parentInfo;
/**
* Constructor.
@@ -3003,7 +3034,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param parentPath Parent path.
* @param parentInfo Parent info.
*/
- PathDescriptor(IgfsPath path, List<IgniteUuid> ids, IgfsPath parentPath, IgfsFileInfo parentInfo) {
+ PathDescriptor(IgfsPath path, List<IgniteUuid> ids, IgfsPath parentPath, IgfsEntryInfo parentInfo) {
assert path != null;
assert ids != null && !ids.isEmpty();
assert parentPath == null && parentInfo == null || parentPath != null && parentInfo != null;
@@ -3040,7 +3071,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param newParentPath New parent path.
* @param newParentInfo New parent info.
*/
- private void updateParent(IgfsPath newParentPath, IgfsFileInfo newParentInfo) {
+ private void updateParent(IgfsPath newParentPath, IgfsEntryInfo newParentInfo) {
assert newParentPath != null;
assert newParentInfo != null;
assert path.isSubDirectoryOf(newParentPath);
@@ -3065,7 +3096,7 @@ public class IgfsMetaManager extends IgfsManager {
*
* @return Parent path info.
*/
- private IgfsFileInfo parentInfo() {
+ private IgfsEntryInfo parentInfo() {
return parentInfo;
}
}
@@ -3074,7 +3105,7 @@ public class IgfsMetaManager extends IgfsManager {
* Remove entry from directory listing.
*/
@GridInternal
- private static final class ListingRemoveProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static final class ListingRemoveProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3104,9 +3135,9 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> e, Object... args)
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args)
throws EntryProcessorException {
- IgfsFileInfo fileInfo = e.getValue();
+ IgfsEntryInfo fileInfo = e.getValue();
assert fileInfo != null;
assert fileInfo.isDirectory();
@@ -3124,7 +3155,7 @@ public class IgfsMetaManager extends IgfsManager {
// Modify listing in-place.
listing.remove(fileName);
- e.setValue(new IgfsFileInfo(listing, fileInfo));
+ e.setValue(fileInfo.listing(listing));
return null;
}
@@ -3146,7 +3177,7 @@ public class IgfsMetaManager extends IgfsManager {
* Update directory listing closure.
*/
@GridInternal
- private static final class ListingAddProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static final class ListingAddProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3180,8 +3211,8 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> e, Object... args) {
- IgfsFileInfo fileInfo = e.getValue();
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) {
+ IgfsEntryInfo fileInfo = e.getValue();
assert fileInfo.isDirectory();
@@ -3195,7 +3226,7 @@ public class IgfsMetaManager extends IgfsManager {
" [listing=" + listing + ", fileName=" + fileName + ", entry=" + entry +
", oldEntry=" + oldEntry + ']');
- e.setValue(new IgfsFileInfo(listing, fileInfo));
+ e.setValue(fileInfo.listing(listing));
return null;
}
@@ -3221,7 +3252,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Listing replace processor.
*/
- private static final class ListingReplaceProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static final class ListingReplaceProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3251,9 +3282,9 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> e, Object... args)
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args)
throws EntryProcessorException {
- IgfsFileInfo fileInfo = e.getValue();
+ IgfsEntryInfo fileInfo = e.getValue();
assert fileInfo.isDirectory();
@@ -3267,7 +3298,7 @@ public class IgfsMetaManager extends IgfsManager {
listing.put(name, new IgfsListingEntry(id, oldEntry.isDirectory()));
- e.setValue(new IgfsFileInfo(listing, fileInfo));
+ e.setValue(fileInfo.listing(listing));
return null;
}
@@ -3289,7 +3320,7 @@ public class IgfsMetaManager extends IgfsManager {
* Update path closure.
*/
@GridInternal
- private static final class UpdatePathProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static final class UpdatePathProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3312,10 +3343,12 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> e, Object... args) {
- IgfsFileInfo info = e.getValue();
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> e, Object... args) {
+ IgfsEntryInfo info = e.getValue();
- e.setValue(builder(info).path(path).build());
+ IgfsEntryInfo newInfo = info.path(path);
+
+ e.setValue(newInfo);
return null;
}
@@ -3349,7 +3382,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Tuple containing the file info and its parent id.
* @throws IgniteCheckedException If failed.
*/
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> append(
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> append(
final IgfsPath path,
Map<String, String> dirProps,
final boolean create,
@@ -3379,7 +3412,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteInternalTx tx = startTx();
try {
- Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(lockIds);
+ Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (!pathIds.verifyIntegrity(lockInfos))
// Directory structure changed concurrently. So we simply re-try.
@@ -3387,7 +3420,7 @@ public class IgfsMetaManager extends IgfsManager {
if (pathIds.allExists()) {
// All participants are found. Simply open the stream.
- IgfsFileInfo info = lockInfos.get(pathIds.lastId());
+ IgfsEntryInfo info = lockInfos.get(pathIds.lastId());
// Check: is it a file?
if (!info.isFile())
@@ -3400,7 +3433,7 @@ public class IgfsMetaManager extends IgfsManager {
// At this point we can open the stream safely.
info = invokeLock(info.id(), false);
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(info, pathIds.lastParentId());
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = new T2<>(info, pathIds.lastParentId());
tx.commit();
@@ -3450,7 +3483,7 @@ public class IgfsMetaManager extends IgfsManager {
* @param simpleCreate Whether new file should be created in secondary FS using create(Path, boolean) method.
* @return Tuple containing the created file info and its parent id.
*/
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> create(
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> create(
final IgfsPath path,
Map<String, String> dirProps,
final boolean overwrite,
@@ -3488,7 +3521,7 @@ public class IgfsMetaManager extends IgfsManager {
IgniteInternalTx tx = startTx();
try {
- Map<IgniteUuid, IgfsFileInfo> lockInfos = lockIds(lockIds);
+ Map<IgniteUuid, IgfsEntryInfo> lockInfos = lockIds(lockIds);
if (!pathIds.verifyIntegrity(lockInfos))
// Directory structure changed concurrently. So we simply re-try.
@@ -3496,7 +3529,7 @@ public class IgfsMetaManager extends IgfsManager {
if (pathIds.allExists()) {
// All participants found.
- IgfsFileInfo oldInfo = lockInfos.get(pathIds.lastId());
+ IgfsEntryInfo oldInfo = lockInfos.get(pathIds.lastId());
// Check: is it a file?
if (!oldInfo.isFile())
@@ -3527,14 +3560,14 @@ public class IgfsMetaManager extends IgfsManager {
// Third step: create the file.
long createTime = System.currentTimeMillis();
- IgfsFileInfo newInfo = invokeAndGet(overwriteId, new FileCreateProcessor(createTime,
+ IgfsEntryInfo newInfo = invokeAndGet(overwriteId, new FileCreateProcessor(createTime,
fileProps, blockSize, affKey, createFileLockId(false), evictExclude));
// Fourth step: update path of remove file.
invokeUpdatePath(oldId, path);
// Prepare result and commit.
- IgniteBiTuple<IgfsFileInfo, IgniteUuid> t2 = new T2<>(newInfo, parentId);
+ IgniteBiTuple<IgfsEntryInfo, IgniteUuid> t2 = new T2<>(newInfo, parentId);
tx.commit();
@@ -3581,7 +3614,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Result or {@code} if the first parent already contained child with the same name.
* @throws IgniteCheckedException If failed.
*/
- @Nullable IgfsPathsCreateResult createDirectory(IgfsPathIds pathIds, Map<IgniteUuid, IgfsFileInfo> lockInfos,
+ @Nullable IgfsPathsCreateResult createDirectory(IgfsPathIds pathIds, Map<IgniteUuid, IgfsEntryInfo> lockInfos,
Map<String, String> dirProps) throws IgniteCheckedException {
// Check if entry we are going to write to is directory.
if (lockInfos.get(pathIds.lastExistingId()).isFile())
@@ -3604,7 +3637,7 @@ public class IgfsMetaManager extends IgfsManager {
* @return Result or {@code} if the first parent already contained child with the same name.
* @throws IgniteCheckedException If failed.
*/
- @Nullable private IgfsPathsCreateResult createFile(IgfsPathIds pathIds, Map<IgniteUuid, IgfsFileInfo> lockInfos,
+ @Nullable private IgfsPathsCreateResult createFile(IgfsPathIds pathIds, Map<IgniteUuid, IgfsEntryInfo> lockInfos,
Map<String, String> dirProps, Map<String, String> fileProps, int blockSize, @Nullable IgniteUuid affKey,
boolean evictExclude) throws IgniteCheckedException{
// Check if entry we are going to write to is directory.
@@ -3630,11 +3663,11 @@ public class IgfsMetaManager extends IgfsManager {
* @throws IgniteCheckedException If failed.
*/
private IgfsPathsCreateResult createFileOrDirectory(boolean dir, IgfsPathIds pathIds,
- Map<IgniteUuid, IgfsFileInfo> lockInfos, Map<String, String> dirProps, Map<String, String> fileProps,
+ Map<IgniteUuid, IgfsEntryInfo> lockInfos, Map<String, String> dirProps, Map<String, String> fileProps,
int blockSize, @Nullable IgniteUuid affKey, boolean evictExclude) throws IgniteCheckedException {
// This is our starting point.
int lastExistingIdx = pathIds.lastExistingIndex();
- IgfsFileInfo lastExistingInfo = lockInfos.get(pathIds.lastExistingId());
+ IgfsEntryInfo lastExistingInfo = lockInfos.get(pathIds.lastExistingId());
// If current info already contains entry with the same name as it's child, then something
// has changed concurrently. We must re-try because we cannot get info of this unexpected
@@ -3684,7 +3717,7 @@ public class IgfsMetaManager extends IgfsManager {
}
// Third step: create leaf.
- IgfsFileInfo info;
+ IgfsEntryInfo info;
if (dir)
info = invokeAndGet(curId, new DirectoryCreateProcessor(createTime, dirProps));
@@ -3723,7 +3756,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* File create processor.
*/
- private static class FileCreateProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class FileCreateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3774,12 +3807,19 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo info = new IgfsFileInfo(blockSize, 0L, affKey, lockId, evictExclude, props,
- createTime, createTime);
-
- info.id(entry.getKey());
+ IgfsEntryInfo info = IgfsUtils.createFile(
+ entry.getKey(),
+ blockSize,
+ 0L,
+ affKey,
+ lockId,
+ evictExclude,
+ props,
+ createTime,
+ createTime
+ );
entry.setValue(info);
@@ -3810,7 +3850,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Directory create processor.
*/
- private static class DirectoryCreateProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class DirectoryCreateProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3861,15 +3901,19 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo info = new IgfsFileInfo(true, props, createTime, createTime);
+ IgfsEntryInfo info = IgfsUtils.createDirectory(
+ entry.getKey(),
+ null,
+ props,
+ createTime,
+ createTime
+ );
if (childName != null)
- info = new IgfsFileInfo(Collections.singletonMap(childName, childEntry), info);
-
- info.id(entry.getKey());
+ info = info.listing(Collections.singletonMap(childName, childEntry));
entry.setValue(info);
@@ -3906,7 +3950,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* File lock entry processor.
*/
- private static class FileLockProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class FileLockProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3931,11 +3975,11 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo oldInfo = entry.getValue();
+ IgfsEntryInfo oldInfo = entry.getValue();
- IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, lockId, oldInfo.modificationTime());
+ IgfsEntryInfo newInfo = oldInfo.lock(lockId);
entry.setValue(newInfo);
@@ -3956,7 +4000,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* File unlock entry processor.
*/
- private static class FileUnlockProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static class FileUnlockProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -3981,11 +4025,11 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo old = entry.getValue();
+ IgfsEntryInfo old = entry.getValue();
- entry.setValue(new IgfsFileInfo(old, null, modificationTime));
+ entry.setValue(old.unlock(modificationTime));
return null;
}
@@ -4004,7 +4048,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* File reserve space entry processor.
*/
- private static class FileReserveSpaceProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class FileReserveSpaceProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -4034,17 +4078,15 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo oldInfo = entry.getValue();
+ IgfsEntryInfo oldInfo = entry.getValue();
IgfsFileMap newMap = new IgfsFileMap(oldInfo.fileMap());
newMap.addRange(affRange);
- IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, oldInfo.length() + space);
-
- newInfo.fileMap(newMap);
+ IgfsEntryInfo newInfo = oldInfo.length(oldInfo.length() + space).fileMap(newMap);
entry.setValue(newInfo);
@@ -4067,7 +4109,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Update properties processor.
*/
- private static class UpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, IgfsFileInfo>,
+ private static class UpdatePropertiesProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, IgfsEntryInfo>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -4092,9 +4134,9 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public IgfsFileInfo process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public IgfsEntryInfo process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo oldInfo = entry.getValue();
+ IgfsEntryInfo oldInfo = entry.getValue();
Map<String, String> tmp = oldInfo.properties();
@@ -4109,7 +4151,7 @@ public class IgfsMetaManager extends IgfsManager {
tmp.put(e.getKey(), e.getValue());
}
- IgfsFileInfo newInfo = new IgfsFileInfo(oldInfo, tmp);
+ IgfsEntryInfo newInfo = oldInfo.properties(tmp);
entry.setValue(newInfo);
@@ -4130,7 +4172,7 @@ public class IgfsMetaManager extends IgfsManager {
/**
* Update times entry processor.
*/
- private static class UpdateTimesProcessor implements EntryProcessor<IgniteUuid, IgfsFileInfo, Void>,
+ private static class UpdateTimesProcessor implements EntryProcessor<IgniteUuid, IgfsEntryInfo, Void>,
Externalizable {
/** */
private static final long serialVersionUID = 0L;
@@ -4160,12 +4202,12 @@ public class IgfsMetaManager extends IgfsManager {
}
/** {@inheritDoc} */
- @Override public Void process(MutableEntry<IgniteUuid, IgfsFileInfo> entry, Object... args)
+ @Override public Void process(MutableEntry<IgniteUuid, IgfsEntryInfo> entry, Object... args)
throws EntryProcessorException {
- IgfsFileInfo oldInfo = entry.getValue();
+ IgfsEntryInfo oldInfo = entry.getValue();
- entry.setValue(new IgfsFileInfo(oldInfo, accessTime, modificationTime));
+ entry.setValue(oldInfo.accessModificationTime(accessTime, modificationTime));
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
index 3bf1011..ef2826b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsOutputStreamImpl.java
@@ -17,10 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.DataInput;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.igfs.IgfsException;
import org.apache.ignite.igfs.IgfsMode;
@@ -33,6 +29,11 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
+import java.io.DataInput;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.concurrent.atomic.AtomicBoolean;
+
import static org.apache.ignite.igfs.IgfsMode.DUAL_SYNC;
import static org.apache.ignite.igfs.IgfsMode.PRIMARY;
import static org.apache.ignite.igfs.IgfsMode.PROXY;
@@ -55,7 +56,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
/** File descriptor. */
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
- private IgfsFileInfo fileInfo;
+ private IgfsEntryInfo fileInfo;
/** Parent ID. */
private final IgniteUuid parentId;
@@ -102,7 +103,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
* @param batch Optional secondary file system batch.
* @param metrics Local IGFS metrics.
*/
- IgfsOutputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsFileInfo fileInfo, IgniteUuid parentId,
+ IgfsOutputStreamImpl(IgfsContext igfsCtx, IgfsPath path, IgfsEntryInfo fileInfo, IgniteUuid parentId,
int bufSize, IgfsMode mode, @Nullable IgfsFileWorkerBatch batch, IgfsLocalMetrics metrics) {
super(path, optimizeBufferSize(bufSize, fileInfo));
@@ -143,7 +144,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
* @return Optimized buffer size.
*/
@SuppressWarnings("IfMayBeConditional")
- private static int optimizeBufferSize(int bufSize, IgfsFileInfo fileInfo) {
+ private static int optimizeBufferSize(int bufSize, IgfsEntryInfo fileInfo) {
assert bufSize > 0;
if (fileInfo == null)
@@ -292,7 +293,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
if (space > 0) {
data.awaitAllAcksReceived(fileInfo.id());
- IgfsFileInfo fileInfo0 = meta.reserveSpace(path, fileInfo.id(), space, streamRange);
+ IgfsEntryInfo fileInfo0 = meta.reserveSpace(path, fileInfo.id(), space, streamRange);
if (fileInfo0 == null)
throw new IOException("File was concurrently deleted: " + path);
@@ -407,7 +408,7 @@ class IgfsOutputStreamImpl extends IgfsOutputStreamAdapter {
* @param fileInfo File info to build initial range for.
* @return Affinity range.
*/
- private IgfsFileAffinityRange initialStreamRange(IgfsFileInfo fileInfo) {
+ private IgfsFileAffinityRange initialStreamRange(IgfsEntryInfo fileInfo) {
if (!igfsCtx.configuration().isFragmentizerEnabled())
return null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
index 1f669b0..2903239 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathIds.java
@@ -267,10 +267,10 @@ public class IgfsPathIds {
* @param infos Info.
* @return {@code True} if full integrity is preserved.
*/
- public boolean verifyIntegrity(Map<IgniteUuid, IgfsFileInfo> infos) {
+ public boolean verifyIntegrity(Map<IgniteUuid, IgfsEntryInfo> infos) {
for (int i = 0; i <= lastExistingIdx; i++) {
IgniteUuid curId = ids[i];
- IgfsFileInfo curInfo = infos.get(curId);
+ IgfsEntryInfo curInfo = infos.get(curId);
// Check if required ID is there.
if (curInfo == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
index 3b620f8..9462aa4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPathsCreateResult.java
@@ -31,7 +31,7 @@ public class IgfsPathsCreateResult {
private final List<IgfsPath> paths;
/** Info of the last created file. */
- private final IgfsFileInfo info;
+ private final IgfsEntryInfo info;
/** Parent ID. */
private final IgniteUuid parentId;
@@ -43,7 +43,7 @@ public class IgfsPathsCreateResult {
* @param info Info of the last created file.
* @param parentId Parent ID.
*/
- public IgfsPathsCreateResult(List<IgfsPath> paths, IgfsFileInfo info, IgniteUuid parentId) {
+ public IgfsPathsCreateResult(List<IgfsPath> paths, IgfsEntryInfo info, IgniteUuid parentId) {
this.paths = paths;
this.info = info;
this.parentId = parentId;
@@ -59,7 +59,7 @@ public class IgfsPathsCreateResult {
/**
* @return Info of the last created file.
*/
- public IgfsFileInfo info() {
+ public IgfsEntryInfo info() {
return info;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java
index 54c0525..76d6be8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryInputStreamDescriptor.java
@@ -24,7 +24,7 @@ import org.apache.ignite.igfs.secondary.IgfsSecondaryFileSystemPositionedReadabl
*/
public class IgfsSecondaryInputStreamDescriptor {
/** File info in the primary file system. */
- private final IgfsFileInfo info;
+ private final IgfsEntryInfo info;
/** Secondary file system input stream wrapper. */
private final IgfsSecondaryFileSystemPositionedReadable secReader;
@@ -35,7 +35,7 @@ public class IgfsSecondaryInputStreamDescriptor {
* @param info File info in the primary file system.
* @param secReader Secondary file system reader.
*/
- IgfsSecondaryInputStreamDescriptor(IgfsFileInfo info, IgfsSecondaryFileSystemPositionedReadable secReader) {
+ IgfsSecondaryInputStreamDescriptor(IgfsEntryInfo info, IgfsSecondaryFileSystemPositionedReadable secReader) {
assert info != null;
assert secReader != null;
@@ -46,7 +46,7 @@ public class IgfsSecondaryInputStreamDescriptor {
/**
* @return File info in the primary file system.
*/
- IgfsFileInfo info() {
+ IgfsEntryInfo info() {
return info;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java
index dd6372f..507ccfc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsSecondaryOutputStreamDescriptor.java
@@ -17,9 +17,10 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.OutputStream;
import org.apache.ignite.lang.IgniteUuid;
+import java.io.OutputStream;
+
/**
* Descriptor of an output stream opened to the secondary file system.
*/
@@ -28,7 +29,7 @@ public class IgfsSecondaryOutputStreamDescriptor {
private final IgniteUuid parentId;
/** File info in the primary file system. */
- private final IgfsFileInfo info;
+ private final IgfsEntryInfo info;
/** Output stream to the secondary file system. */
private final OutputStream out;
@@ -40,7 +41,7 @@ public class IgfsSecondaryOutputStreamDescriptor {
* @param info File info in the primary file system.
* @param out Output stream to the secondary file system.
*/
- IgfsSecondaryOutputStreamDescriptor(IgniteUuid parentId, IgfsFileInfo info, OutputStream out) {
+ IgfsSecondaryOutputStreamDescriptor(IgniteUuid parentId, IgfsEntryInfo info, OutputStream out) {
assert parentId != null;
assert info != null;
assert out != null;
@@ -60,7 +61,7 @@ public class IgfsSecondaryOutputStreamDescriptor {
/**
* @return File info in the primary file system.
*/
- IgfsFileInfo info() {
+ IgfsEntryInfo info() {
return info;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
index ef7d5c7..325f636 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsUtils.java
@@ -43,6 +43,7 @@ import org.apache.ignite.transactions.Transaction;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Constructor;
+import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
@@ -321,4 +322,71 @@ public class IgfsUtils {
}
}
}
+
+ /**
+ * Create empty directory with the given ID.
+ *
+ * @param id ID.
+ * @return File info.
+ */
+ public static IgfsDirectoryInfo createDirectory(IgniteUuid id) {
+ return createDirectory(id, null, null);
+ }
+
+ /**
+ * Create directory.
+ *
+ * @param id ID.
+ * @param listing Listing.
+ * @param props Properties.
+ * @return File info.
+ */
+ public static IgfsDirectoryInfo createDirectory(
+ IgniteUuid id,
+ @Nullable Map<String, IgfsListingEntry> listing,
+ @Nullable Map<String, String> props) {
+ long time = System.currentTimeMillis();
+
+ return createDirectory(id, listing, props, time, time);
+ }
+
+ /**
+ * Create directory.
+ *
+ * @param id ID.
+ * @param listing Listing.
+ * @param props Properties.
+ * @param createTime Create time.
+ * @param modificationTime Modification time.
+ * @return File info.
+ */
+ public static IgfsDirectoryInfo createDirectory(
+ IgniteUuid id,
+ @Nullable Map<String, IgfsListingEntry> listing,
+ @Nullable Map<String,String> props,
+ long createTime,
+ long modificationTime) {
+ return new IgfsDirectoryInfo(id, listing, props, createTime, modificationTime);
+ }
+
+ /**
+ * Create file.
+ *
+ * @param id File ID.
+ * @param blockSize Block size.
+ * @param len Length.
+ * @param affKey Affinity key.
+ * @param lockId Lock ID.
+ * @param evictExclude Evict exclude flag.
+ * @param props Properties.
+ * @param accessTime Access time.
+ * @param modificationTime Modification time.
+ * @return File info.
+ */
+ public static IgfsFileInfo createFile(IgniteUuid id, int blockSize, long len, @Nullable IgniteUuid affKey,
+ @Nullable IgniteUuid lockId, boolean evictExclude, @Nullable Map<String, String> props, long accessTime,
+ long modificationTime) {
+ return new IgfsFileInfo(id, blockSize, len, affKey, props, null, lockId, accessTime, modificationTime,
+ evictExclude);
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/package-info.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/package-info.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/package-info.java
index ea70f49..20051ce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/package-info.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/package-info.java
@@ -17,6 +17,6 @@
/**
* <!-- Package description. -->
- * Contains high performance file system processer.
+ * Contains high performance file system processor.
*/
package org.apache.ignite.internal.processors.igfs;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java
index 22f427a..d52a918 100644
--- a/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/igfs/IgfsFragmentizerAbstractSelfTest.java
@@ -22,8 +22,8 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.processors.igfs.IgfsCommonAbstractTest;
+import org.apache.ignite.internal.processors.igfs.IgfsEntryInfo;
import org.apache.ignite.internal.processors.igfs.IgfsEx;
-import org.apache.ignite.internal.processors.igfs.IgfsFileInfo;
import org.apache.ignite.internal.processors.igfs.IgfsMetaManager;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -139,7 +139,7 @@ public class IgfsFragmentizerAbstractSelfTest extends IgfsCommonAbstractTest {
if (fileId == null)
throw new IgfsPathNotFoundException("File not found: " + path);
- IgfsFileInfo fileInfo = meta.info(fileId);
+ IgfsEntryInfo fileInfo = meta.info(fileId);
do {
if (fileInfo == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/bfa7bf6c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
index 2acf59c..edec572 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsAbstractSelfTest.java
@@ -3081,7 +3081,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
* @param igfs The IGFS instance.
* @return The data cache.
*/
- protected static GridCacheAdapter<IgniteUuid, IgfsFileInfo> getMetaCache(IgniteFileSystem igfs) {
+ protected static GridCacheAdapter<IgniteUuid, IgfsEntryInfo> getMetaCache(IgniteFileSystem igfs) {
String dataCacheName = igfs.configuration().getMetaCacheName();
IgniteEx igniteEx = ((IgfsEx)igfs).context().kernalContext().grid();
@@ -3111,7 +3111,7 @@ public abstract class IgfsAbstractSelfTest extends IgfsCommonAbstractTest {
entry.getValue().await();
}
catch (IgniteCheckedException e) {
- if (!entry.getValue().cancelled())
+ if (!(e instanceof IgfsFileWorkerBatchCancelledException))
throw e;
}
}