@Test public void testInsertBatch1() throws StorageException { TableRequestOptions options = new TableRequestOptions(); options.setTablePayloadFormat(TablePayloadFormat.JsonFullMetadata); insertAndDeleteBatchWithX(1, options); options.setTablePayloadFormat(TablePayloadFormat.Json); insertAndDeleteBatchWithX(1, options); options.setTablePayloadFormat(TablePayloadFormat.JsonNoMetadata); insertAndDeleteBatchWithX(1, options); }
/** * Creates an instance of the <code>RequestOptions</code> class by copying values from another * <code>TableRequestOptions</code> instance. * * @param other * A <code>TableRequestOptions</code> object that represents the request options to copy. */ public TableRequestOptions(final TableRequestOptions other) { super(other); if (other != null) { this.setTablePayloadFormat(other.getTablePayloadFormat()); this.setPropertyResolver(other.getPropertyResolver()); this.setDateBackwardCompatibility(other.getDateBackwardCompatibility()); this.setEncryptionPolicy(other.getEncryptionPolicy()); this.setEncryptionResolver(other.getEncryptionResolver()); } }
/** * Queries the given storage service for the {@link ServiceStats}. * * @param options * A {@link BlobRequestOptions} object that specifies any additional options for the request. Specifying * <code>null</code> will use the default request options from the associated service client ( * {@link CloudBlobClient}). * @param opContext * An {@link OperationContext} object that represents the context for the current operation. This object * is used to track requests to the storage service, and to provide additional runtime information about * the operation. * @return {@link ServiceStats} for the given storage service * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public ServiceStats getServiceStats(TableRequestOptions options, OperationContext opContext) throws StorageException { if (opContext == null) { opContext = new OperationContext(); } opContext.initialize(); options = TableRequestOptions.populateAndApplyDefaults(options, this); return ExecutionEngine.executeWithRetry(this, null, this.getServiceStatsImpl(options, true), options.getRetryPolicyFactory(), opContext); }
/** * Creates an instance of the <code>RequestOptions</code> class by copying values from another * <code>TableRequestOptions</code> instance. * * @param other * A <code>TableRequestOptions</code> object that represents the request options to copy. */ public TableRequestOptions(final TableRequestOptions other) { super(other); if (other != null) { this.setTablePayloadFormat(other.getTablePayloadFormat()); this.setPropertyResolver(other.getPropertyResolver()); this.setDateBackwardCompatibility(other.getDateBackwardCompatibility()); } }
/** * Applies defaults to the options passed in. * * @param modifiedOptions * The options to apply defaults to. */ protected static void applyDefaults(final TableRequestOptions modifiedOptions) { Utility.assertNotNull("modifiedOptions", modifiedOptions); RequestOptions.applyBaseDefaultsInternal(modifiedOptions); if (modifiedOptions.getTablePayloadFormat() == null) { modifiedOptions.setTablePayloadFormat(TablePayloadFormat.Json); } if (modifiedOptions.getDateBackwardCompatibility() == null) { modifiedOptions.setDateBackwardCompatibility(false); } }
private void doEscapeTest(String data, boolean useBatch, boolean includeInKey) throws StorageException { TableRequestOptions options = new TableRequestOptions(); options.setTablePayloadFormat(TablePayloadFormat.JsonFullMetadata); doEscapeTestHelper(data, useBatch, includeInKey, options); options.setTablePayloadFormat(TablePayloadFormat.Json); doEscapeTestHelper(data, useBatch, includeInKey, options); options.setTablePayloadFormat(TablePayloadFormat.JsonNoMetadata); doEscapeTestHelper(data, useBatch, includeInKey, options); options.setTablePayloadFormat(TablePayloadFormat.JsonNoMetadata); options.setPropertyResolver(new Class1()); doEscapeTestHelper(data, useBatch, includeInKey, options); }
tableClient.getDefaultRequestOptions().setLocationMode(LocationMode.PRIMARY_THEN_SECONDARY); tableClient.getDefaultRequestOptions().setTimeoutIntervalInMs(1000); tableClient.getDefaultRequestOptions().setTablePayloadFormat(TablePayloadFormat.JsonNoMetadata); tableClient.getDefaultRequestOptions().setRetryPolicyFactory(new RetryNoRetry()); .getCredentials().getClass().toString()); assertEquals(tableClient.getDefaultRequestOptions().getLocationMode(), tableFromUri.getServiceClient() .getDefaultRequestOptions().getLocationMode()); assertEquals(tableClient.getDefaultRequestOptions().getTimeoutIntervalInMs(), tableFromUri.getServiceClient() .getDefaultRequestOptions().getTimeoutIntervalInMs()); assertEquals(tableClient.getDefaultRequestOptions().getTablePayloadFormat(), tableFromUri.getServiceClient() .getDefaultRequestOptions().getTablePayloadFormat()); assertEquals(tableClient.getDefaultRequestOptions().getRetryPolicyFactory().getClass(), tableFromUri .getServiceClient().getDefaultRequestOptions().getRetryPolicyFactory().getClass());
@Test @Category(SecondaryTests.class) public void testBatchSecondaryNoWrite() throws StorageException { // create and insert an entity Class1 ref = TableTestHelper.generateRandomEntity("jxscl_odata"); this.table.execute(TableOperation.insert(ref)); // create a batch and add a query for this entity TableBatchOperation batch = new TableBatchOperation(); TableOperation queryOp = TableOperation.retrieve(ref.getPartitionKey(), ref.getRowKey(), ref.getClass()); batch.add(queryOp); // should be able to make a request to secondary as there are no writes TableRequestOptions options = new TableRequestOptions(); options.setLocationMode(LocationMode.SECONDARY_ONLY); options.setRetryPolicyFactory(new RetryNoRetry()); this.table.execute(batch, options, null); }
TableRequestOptions options = new TableRequestOptions(); options.setDateBackwardCompatibility(dateBackwardCompatibility); options.setTablePayloadFormat(format);
public TableClient create() { try { final CloudStorageAccount storageAccount = new CloudStorageAccount(azureTableConfiguration.getStorageCredentialsAccountAndKey(), true); final CloudTableClient cloudTableClient = storageAccount.createCloudTableClient(); final TableRequestOptions defaultOptions = new TableRequestOptions(); defaultOptions.setRetryPolicyFactory(new RetryLinearRetry( Ints.checkedCast(azureTableConfiguration.getRetryInterval().toMilliseconds()), azureTableConfiguration.getRetryAttempts())); defaultOptions.setTimeoutIntervalInMs(Ints.checkedCast(azureTableConfiguration.getTimeout().toMilliseconds())); cloudTableClient.setDefaultRequestOptions(defaultOptions); return new TableClient(cloudTableClient); } catch (URISyntaxException err) { LOGGER.error("Failed to create a TableClient", err); throw new IllegalArgumentException(err); } } }
private void executeQueryAndAssertResults(String filter, int expectedResults, TableRequestOptions options, boolean usePropertyResolver) { // instantiate class to use property resolver ComplexEntity ent = new ComplexEntity(); if (usePropertyResolver) { options.setPropertyResolver(ent); } int count = 0; TableQuery<ComplexEntity> query = TableQuery.from(ComplexEntity.class).where(filter); for (@SuppressWarnings("unused") ComplexEntity e : table.execute(query, options, null)) { count++; } assertEquals(expectedResults, count); }
TableRequestOptions tableOptions = new TableRequestOptions(); tableOptions.setRetryPolicyFactory(retryPolicy); tableClient.setDefaultRequestOptions(tableOptions); } catch (IllegalArgumentException | URISyntaxException e) {
opContext); setAcceptHeaderForHttpWebRequest(retConnection, tableOptions.getTablePayloadFormat()); retConnection.setRequestProperty(Constants.HeaderConstants.CONTENT_TYPE, String.format(TableConstants.HeaderConstants.MULTIPART_MIXED_FORMAT, batchID));
final TableRequestOptions options = new TableRequestOptions(); options.setDateBackwardCompatibility(true); entity = this.table.execute(get, options, null).getResultAsType(); assertEquals(date.getTime(), entity.getDate().getTime()); options.setDateBackwardCompatibility(true); dynamicEntity = this.table.execute(get, options, null).getResultAsType(); assertEquals(date.getTime(), dynamicEntity.getProperties().get(dateKey).getValueAsDate().getTime());
/** * Reserved for internal use. Performs an insert operation on the specified table, using the specified * {@link TableRequestOptions} and {@link OperationContext}. * <p> * This method will invoke the Insert Entity REST API to execute this table operation, using the Table service * endpoint and storage account credentials in the {@link CloudTableClient} object. * * @param client * A {@link CloudTableClient} instance specifying the Table service endpoint, storage account * credentials, and any additional query parameters. * @param tableName * A <code>String</code> which specifies the name of the table. * @param options * A {@link TableRequestOptions} object that specifies execution options such as retry policy and timeout * settings for the operation. * @param opContext * An {@link OperationContext} object for tracking the current operation. * * @return * A {@link TableResult} which represents the results of executing the operation. * * @throws StorageException * if an error occurs in the storage operation. */ private TableResult performInsert(final CloudTableClient client, final String tableName, final TableRequestOptions options, final OperationContext opContext) throws StorageException { return ExecutionEngine.executeWithRetry(client, this, this.insertImpl(client, tableName, options, opContext), options.getRetryPolicyFactory(), opContext); }
@Before public void tableODataTestBeforeMethodSetUp() throws StorageException, URISyntaxException { this.table = TableTestHelper.getRandomTableReference(); this.table.createIfNotExists(); final CloudTableClient tClient = TableTestHelper.createCloudTableClient(); this.options = TableRequestOptions.populateAndApplyDefaults(this.options, tClient); this.options.setTablePayloadFormat(TablePayloadFormat.JsonNoMetadata); // Insert Entity this.ent = new DynamicTableEntity(); this.ent.setPartitionKey("jxscl_odata"); this.ent.setRowKey(UUID.randomUUID().toString()); this.ent.getProperties().put("foo2", new EntityProperty("bar2")); this.ent.getProperties().put("foo", new EntityProperty("bar")); this.ent.getProperties().put("fooint", new EntityProperty(1234)); this.table.execute(TableOperation.insert(this.ent), this.options, null); }
options = TableRequestOptions.populateAndApplyDefaults(options, this.tableServiceClient);
public Iterable<String> listTables(final String prefix, final TableRequestOptions options, final OperationContext opContext) { TableRequestOptions modifiedOptions = TableRequestOptions.populateAndApplyDefaults(options, this); modifiedOptions.clearEncryption(); return (Iterable<String>) this.generateIteratorForQuery(this.generateListTablesQuery(prefix), this.tableNameResolver, modifiedOptions, opContext);
final TableRequestOptions options, final OperationContext opContext) throws StorageException { options.assertPolicyIfRequired(); options.getRetryPolicyFactory(), opContext);
private void doQueryEscapeTest(String data) throws StorageException { TableRequestOptions options = new TableRequestOptions(); options.setTablePayloadFormat(TablePayloadFormat.JsonFullMetadata); doQueryEscapeTestHelper(data, options); options.setTablePayloadFormat(TablePayloadFormat.Json); doQueryEscapeTestHelper(data, options); options.setTablePayloadFormat(TablePayloadFormat.JsonNoMetadata); doQueryEscapeTestHelper(data, options); options.setTablePayloadFormat(TablePayloadFormat.JsonNoMetadata); options.setPropertyResolver(new Class1()); doQueryEscapeTestHelper(data, options); }