private void processBatch() throws IOException { TableBatchOperation batch = new TableBatchOperation(); batch.addAll(batchOperations); // try { tableservice.executeOperation(tableName, batch); handleSuccess(null, batchOperationsCount); } catch (StorageException e) { LOGGER.error(i18nMessages.getMessage("error.ProcessBatch", actionData, e.getLocalizedMessage())); handleReject(null, e, batchOperationsCount); if (dieOnError) { throw new ComponentException(e); } } catch (URISyntaxException | InvalidKeyException e) { throw new ComponentException(e); // connection problem so next operation will also fail, we stop the process } // reset operations, count and marker batchOperations.clear(); batchRecords.clear(); batchOperationsCount = 0; latestPartitionKey = ""; }
private void processBatch() throws IOException { TableBatchOperation batch = new TableBatchOperation(); batch.addAll(batchOperations); // try { tableservice.executeOperation(tableName, batch); handleSuccess(null, batchOperationsCount); } catch (StorageException e) { LOGGER.error(i18nMessages.getMessage("error.ProcessBatch", actionData, e.getLocalizedMessage())); handleReject(null, e, batchOperationsCount); if (dieOnError) { throw new ComponentException(e); } } catch (URISyntaxException | InvalidKeyException e) { throw new ComponentException(e); // connection problem so next operation will also fail, we stop the process } // reset operations, count and marker batchOperations.clear(); batchRecords.clear(); batchOperationsCount = 0; latestPartitionKey = ""; }
boolean added = batch.addAll(ops); assertTrue(added); ops.add(TableOperation.retrieve(ref.partitionKey, ref.rowKey, ref.getClass())); try { batch.addAll(ops); fail(SR.RETRIEVE_MUST_BE_ONLY_OPERATION_IN_BATCH); ops.add(TableOperation.insert(ref)); try { batch.addAll(ops); fail(SR.OPS_IN_BATCH_MUST_HAVE_SAME_PARTITION_KEY);
boolean added = batch.addAll(0, ops); assertTrue(added); ops.add(TableOperation.retrieve(ref.partitionKey, ref.rowKey, ref.getClass())); try { batch.addAll(0, ops); fail(SR.RETRIEVE_MUST_BE_ONLY_OPERATION_IN_BATCH); ops.add(TableOperation.insert(ref)); try { batch.addAll(0, ops); fail(SR.OPS_IN_BATCH_MUST_HAVE_SAME_PARTITION_KEY);
@Test public void testBatchAddAllWithRetrieveShouldThrow() throws StorageException { ArrayList<TableOperation> ops = allOpsList(); TableBatchOperation batch = new TableBatchOperation(); // Insert entity to retrieve Class1 baseEntity = TableTestHelper.generateRandomEntity("jxscl_odata"); this.table.execute(TableOperation.insert(baseEntity), null, null); ops.add(TableOperation.retrieve(baseEntity.getPartitionKey(), baseEntity.getRowKey(), Class1.class)); try { batch.addAll(ops); fail(SR.RETRIEVE_MUST_BE_ONLY_OPERATION_IN_BATCH); } catch (IllegalArgumentException e) { assertEquals(SR.RETRIEVE_MUST_BE_ONLY_OPERATION_IN_BATCH, e.getMessage()); } }
@Test @Category(SecondaryTests.class) public void testBatchRemoveRange() throws StorageException { ArrayList<TableOperation> ops = allOpsList(); TableBatchOperation batch = new TableBatchOperation(); batch.addAll(ops); batch.removeRange(0, ops.size()); assertEquals(0, batch.size()); // should be able to add an entity with a different partition key Class1 baseEntity = TableTestHelper.generateRandomEntity("jxscl_odata_2"); batch.insert(baseEntity); batch.removeRange(0, 1); batch.addAll(ops); batch.removeRange(0, ops.size() - 1); // should be not be able to add an entity with a different partition key baseEntity = TableTestHelper.generateRandomEntity("jxscl_odata_2"); try { batch.insert(baseEntity); fail(SR.OPS_IN_BATCH_MUST_HAVE_SAME_PARTITION_KEY); } catch (IllegalArgumentException e) { assertEquals(SR.OPS_IN_BATCH_MUST_HAVE_SAME_PARTITION_KEY, e.getMessage()); } batch.removeRange(0, 1); // should be able to add a retrieve to the batch Class1 ref = TableTestHelper.generateRandomEntity("jxscl_odata"); TableOperation queryOp = TableOperation.retrieve(ref.getPartitionKey(), ref.getRowKey(), ref.getClass()); batch.add(queryOp); }
@Test public void testBatchRemoveAll() throws StorageException { ArrayList<TableOperation> ops = allOpsList(); TableBatchOperation batch = new TableBatchOperation(); batch.addAll(ops); assertTrue(batch.removeAll(ops)); assertEquals(0, batch.size()); // should be able to add an entity with a different partition key Class1 baseEntity = TableTestHelper.generateRandomEntity("jxscl_odata_2"); batch.insert(baseEntity); }