Loading kinetic-client/src/main/java/kinetic/client/BatchAbortedException.java +1 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ public class BatchAbortedException extends KineticException { * @return the failed command index number starting with 0 for the first * command */ public int getFiledOperationIndex() { public int getFailedOperationIndex() { return index; } Loading kinetic-simulator/src/main/java/com/seagate/kinetic/simulator/internal/BatchOperationHandler.java +26 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ package com.seagate.kinetic.simulator.internal; import java.util.ArrayList; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; Loading Loading @@ -63,6 +65,9 @@ public class BatchOperationHandler { private BatchOperation<ByteString, KVValue> batch = null; // private Map<ByteString, ByteString> map = new ConcurrentHashMap<ByteString, ByteString>(); // sequence list private ArrayList<Long> sequenceList = new ArrayList<Long>(); Loading Loading @@ -102,6 +107,9 @@ public class BatchOperationHandler { // clear seq list sequenceList.clear(); // clear version map map.clear(); // clear exception this.batchException = null; } catch (KVStoreException e) { Loading Loading @@ -399,10 +407,13 @@ public class BatchOperationHandler { // check version if required if (requestKeyValue.getForce() == false) { checkVersion(requestKeyValue); checkVersion(km); } batch.delete(key); // delete entry from map. map.remove(key); } private void batchPut(KineticMessage km) throws KVStoreException, Loading @@ -426,7 +437,7 @@ public class BatchOperationHandler { // check version if required if (requestKeyValue.getForce() == false) { checkVersion(requestKeyValue); checkVersion(km); } // construct store KV Loading @@ -441,6 +452,9 @@ public class BatchOperationHandler { // batch put batch.put(key, data); // put to batch map for version comparison map.put(requestKeyValue.getKey(), requestKeyValue.getNewVersion()); } private synchronized void commitBatch(RequestContext context) { Loading Loading @@ -513,7 +527,9 @@ public class BatchOperationHandler { return s.size(); } private void checkVersion(KeyValue requestKeyValue) throws KVStoreException { private void checkVersion(KineticMessage km) throws KVStoreException { KeyValue requestKeyValue = km.getCommand().getBody().getKeyValue(); ByteString requestDbVersion = requestKeyValue.getDbVersion(); Loading @@ -521,7 +537,14 @@ public class BatchOperationHandler { ByteString storeDbVersion = this.getDbVersion(key); // compare version with store compareVersion(storeDbVersion, requestDbVersion); // compare version with batch map ByteString mapVersion = this.map.get(key); if (mapVersion != null) { compareVersion(mapVersion, requestDbVersion); } } @SuppressWarnings("unchecked") Loading kinetic-test/src/test/java/com/seagate/kinetic/batchOp/BatchOpAPITest.java +6 −6 Original line number Diff line number Diff line Loading @@ -2598,8 +2598,8 @@ public class BatchOpAPITest extends IntegrationTestCase { } catch (BatchAbortedException e) { assertTrue(e.getResponseMessage().getCommand().getStatus() .getCode().equals(StatusCode.INVALID_BATCH)); System.out.println(e.getFiledOperationIndex()); assertTrue(e.getFiledOperationIndex() == 0); System.out.println(e.getFailedOperationIndex()); assertTrue(e.getFailedOperationIndex() == 0); } catch (KineticException e) { Assert.fail("received unexpected exception: " + e.getMessage()); Loading Loading @@ -2660,7 +2660,7 @@ public class BatchOpAPITest extends IntegrationTestCase { } catch (BatchAbortedException e) { assertTrue(e.getResponseMessage().getCommand().getStatus() .getCode().equals(StatusCode.INVALID_BATCH)); assertTrue(e.getFiledOperationIndex() == 0); assertTrue(e.getFailedOperationIndex() == 0); } catch (KineticException e) { Assert.fail("received unexpected exception: " + e.getMessage()); Loading Loading @@ -2694,7 +2694,7 @@ public class BatchOpAPITest extends IntegrationTestCase { } catch (BatchAbortedException e) { assertTrue(e.getResponseMessage().getCommand().getStatus() .getCode().equals(StatusCode.INVALID_BATCH)); assertTrue(e.getFiledOperationIndex() == 0); assertTrue(e.getFailedOperationIndex() == 0); } catch (KineticException e) { Assert.fail("received unexpected exception: " + e.getMessage()); Loading Loading @@ -2733,7 +2733,7 @@ public class BatchOpAPITest extends IntegrationTestCase { } catch (BatchAbortedException e) { assertTrue(e.getResponseMessage().getCommand().getStatus() .getCode().equals(StatusCode.INVALID_BATCH)); assertTrue(e.getFiledOperationIndex() == 0); assertTrue(e.getFailedOperationIndex() == 0); } catch (KineticException e) { Assert.fail("received unexpected exception: " + e.getMessage()); Loading Loading @@ -2783,7 +2783,7 @@ public class BatchOpAPITest extends IntegrationTestCase { } catch (BatchAbortedException e) { assertTrue(e.getResponseMessage().getCommand().getStatus() .getCode().equals(StatusCode.INVALID_BATCH)); assertTrue(e.getFiledOperationIndex() == 0); assertTrue(e.getFailedOperationIndex() == 0); } catch (KineticException e) { Assert.fail("received unexpected exception: " + e.getMessage()); Loading kinetic-test/src/test/java/com/seagate/kinetic/example/batchop/BatchOperationFailedExample.java +2 −2 Original line number Diff line number Diff line Loading @@ -21,10 +21,10 @@ import java.io.UnsupportedEncodingException; import java.util.logging.Level; import java.util.logging.Logger; import kinetic.client.BatchAbortedException; import kinetic.client.BatchOperation; import kinetic.client.ClientConfiguration; import kinetic.client.Entry; import kinetic.client.BatchAbortedException; import kinetic.client.KineticClient; import kinetic.client.KineticClientFactory; import kinetic.client.KineticException; Loading Loading @@ -95,7 +95,7 @@ public class BatchOperationFailedExample { // get status Status status = e.getResponseMessage().getCommand().getStatus(); int index = e.getFiledOperationIndex(); int index = e.getFailedOperationIndex(); logger.info("received expected exception: " + status.getCode() + ":" + status.getStatusMessage() + ", index=" + index); Loading Loading
kinetic-client/src/main/java/kinetic/client/BatchAbortedException.java +1 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ public class BatchAbortedException extends KineticException { * @return the failed command index number starting with 0 for the first * command */ public int getFiledOperationIndex() { public int getFailedOperationIndex() { return index; } Loading
kinetic-simulator/src/main/java/com/seagate/kinetic/simulator/internal/BatchOperationHandler.java +26 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ package com.seagate.kinetic.simulator.internal; import java.util.ArrayList; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; Loading Loading @@ -63,6 +65,9 @@ public class BatchOperationHandler { private BatchOperation<ByteString, KVValue> batch = null; // private Map<ByteString, ByteString> map = new ConcurrentHashMap<ByteString, ByteString>(); // sequence list private ArrayList<Long> sequenceList = new ArrayList<Long>(); Loading Loading @@ -102,6 +107,9 @@ public class BatchOperationHandler { // clear seq list sequenceList.clear(); // clear version map map.clear(); // clear exception this.batchException = null; } catch (KVStoreException e) { Loading Loading @@ -399,10 +407,13 @@ public class BatchOperationHandler { // check version if required if (requestKeyValue.getForce() == false) { checkVersion(requestKeyValue); checkVersion(km); } batch.delete(key); // delete entry from map. map.remove(key); } private void batchPut(KineticMessage km) throws KVStoreException, Loading @@ -426,7 +437,7 @@ public class BatchOperationHandler { // check version if required if (requestKeyValue.getForce() == false) { checkVersion(requestKeyValue); checkVersion(km); } // construct store KV Loading @@ -441,6 +452,9 @@ public class BatchOperationHandler { // batch put batch.put(key, data); // put to batch map for version comparison map.put(requestKeyValue.getKey(), requestKeyValue.getNewVersion()); } private synchronized void commitBatch(RequestContext context) { Loading Loading @@ -513,7 +527,9 @@ public class BatchOperationHandler { return s.size(); } private void checkVersion(KeyValue requestKeyValue) throws KVStoreException { private void checkVersion(KineticMessage km) throws KVStoreException { KeyValue requestKeyValue = km.getCommand().getBody().getKeyValue(); ByteString requestDbVersion = requestKeyValue.getDbVersion(); Loading @@ -521,7 +537,14 @@ public class BatchOperationHandler { ByteString storeDbVersion = this.getDbVersion(key); // compare version with store compareVersion(storeDbVersion, requestDbVersion); // compare version with batch map ByteString mapVersion = this.map.get(key); if (mapVersion != null) { compareVersion(mapVersion, requestDbVersion); } } @SuppressWarnings("unchecked") Loading
kinetic-test/src/test/java/com/seagate/kinetic/batchOp/BatchOpAPITest.java +6 −6 Original line number Diff line number Diff line Loading @@ -2598,8 +2598,8 @@ public class BatchOpAPITest extends IntegrationTestCase { } catch (BatchAbortedException e) { assertTrue(e.getResponseMessage().getCommand().getStatus() .getCode().equals(StatusCode.INVALID_BATCH)); System.out.println(e.getFiledOperationIndex()); assertTrue(e.getFiledOperationIndex() == 0); System.out.println(e.getFailedOperationIndex()); assertTrue(e.getFailedOperationIndex() == 0); } catch (KineticException e) { Assert.fail("received unexpected exception: " + e.getMessage()); Loading Loading @@ -2660,7 +2660,7 @@ public class BatchOpAPITest extends IntegrationTestCase { } catch (BatchAbortedException e) { assertTrue(e.getResponseMessage().getCommand().getStatus() .getCode().equals(StatusCode.INVALID_BATCH)); assertTrue(e.getFiledOperationIndex() == 0); assertTrue(e.getFailedOperationIndex() == 0); } catch (KineticException e) { Assert.fail("received unexpected exception: " + e.getMessage()); Loading Loading @@ -2694,7 +2694,7 @@ public class BatchOpAPITest extends IntegrationTestCase { } catch (BatchAbortedException e) { assertTrue(e.getResponseMessage().getCommand().getStatus() .getCode().equals(StatusCode.INVALID_BATCH)); assertTrue(e.getFiledOperationIndex() == 0); assertTrue(e.getFailedOperationIndex() == 0); } catch (KineticException e) { Assert.fail("received unexpected exception: " + e.getMessage()); Loading Loading @@ -2733,7 +2733,7 @@ public class BatchOpAPITest extends IntegrationTestCase { } catch (BatchAbortedException e) { assertTrue(e.getResponseMessage().getCommand().getStatus() .getCode().equals(StatusCode.INVALID_BATCH)); assertTrue(e.getFiledOperationIndex() == 0); assertTrue(e.getFailedOperationIndex() == 0); } catch (KineticException e) { Assert.fail("received unexpected exception: " + e.getMessage()); Loading Loading @@ -2783,7 +2783,7 @@ public class BatchOpAPITest extends IntegrationTestCase { } catch (BatchAbortedException e) { assertTrue(e.getResponseMessage().getCommand().getStatus() .getCode().equals(StatusCode.INVALID_BATCH)); assertTrue(e.getFiledOperationIndex() == 0); assertTrue(e.getFailedOperationIndex() == 0); } catch (KineticException e) { Assert.fail("received unexpected exception: " + e.getMessage()); Loading
kinetic-test/src/test/java/com/seagate/kinetic/example/batchop/BatchOperationFailedExample.java +2 −2 Original line number Diff line number Diff line Loading @@ -21,10 +21,10 @@ import java.io.UnsupportedEncodingException; import java.util.logging.Level; import java.util.logging.Logger; import kinetic.client.BatchAbortedException; import kinetic.client.BatchOperation; import kinetic.client.ClientConfiguration; import kinetic.client.Entry; import kinetic.client.BatchAbortedException; import kinetic.client.KineticClient; import kinetic.client.KineticClientFactory; import kinetic.client.KineticException; Loading Loading @@ -95,7 +95,7 @@ public class BatchOperationFailedExample { // get status Status status = e.getResponseMessage().getCommand().getStatus(); int index = e.getFiledOperationIndex(); int index = e.getFailedOperationIndex(); logger.info("received expected exception: " + status.getCode() + ":" + status.getStatusMessage() + ", index=" + index); Loading