.credentials(accessId, secretKey) .modules(MODULES) .overrides(overrides) .buildView(BlobStoreContext.class); BlobStore blobStore = context.getBlobStore();
.credentials(accessId, secretKey) .modules(MODULES) .overrides(overrides) .buildView(BlobStoreContext.class); BlobStore blobStore = context.getBlobStore();
.credentials(accessId, secretKey) .modules(MODULES) .overrides(overrides) .buildView(BlobStoreContext.class);
public void deleteBucket() { String accessId = System.getProperty( SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR ); String secretKey = System.getProperty( SDKGlobalConfiguration.SECRET_KEY_ENV_VAR ); Properties overrides = new Properties(); overrides.setProperty( "s3" + ".identity", accessId ); overrides.setProperty( "s3" + ".credential", secretKey ); Blob bo = null; BlobStore blobStore = null; final Iterable<? extends Module> MODULES = ImmutableSet .of(new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(), new NettyPayloadModule()); BlobStoreContext context = ContextBuilder.newBuilder("s3").credentials( accessId, secretKey ).modules( MODULES ) .overrides( overrides ).buildView( BlobStoreContext.class ); blobStore = context.getBlobStore(); blobStore.deleteContainer( bucketName ); }
properties.setProperty(LocationConstants.PROPERTY_ZONES, keysSetToStr(zones)); ctxBuilder.overrides(properties);
/** * Delete the configured s3 bucket. */ public void deleteBucket() { logger.debug("\n\nDelete bucket\n"); String accessId = System.getProperty(SDKGlobalConfiguration.ACCESS_KEY_ENV_VAR); String secretKey = System.getProperty(SDKGlobalConfiguration.SECRET_KEY_ENV_VAR); Properties overrides = new Properties(); overrides.setProperty("s3" + ".identity", accessId); overrides.setProperty("s3" + ".credential", secretKey); final Iterable<? extends Module> MODULES = ImmutableSet .of(new JavaUrlHttpCommandExecutorServiceModule(), new Log4JLoggingModule(), new NettyPayloadModule()); BlobStoreContext context = ContextBuilder.newBuilder("s3").credentials(accessId, secretKey).modules(MODULES) .overrides(overrides).buildView(BlobStoreContext.class); BlobStore blobStore = context.getBlobStore(); blobStore.deleteContainer( bucketName ); }
.overrides(overrides).buildView(BlobStoreContext.class);
.credentials( accessKey, secretKey ) .modules( MODULES ) .overrides( overrides ) .buildView( BlobStoreContext.class );
.credentials(accessId, secretKey) .modules(MODULES) .overrides(overrides) .buildView(BlobStoreContext.class);
.credentials( accessId, secretKey ) .modules( MODULES ) .overrides( overrides ) .buildView( BlobStoreContext.class );
.credentials(accessId, secretKey ) .modules(MODULES ) .overrides(overrides ) .buildView(BlobStoreContext.class );
public CloudFilesPublisher() { Properties overrides = new Properties(); overrides.setProperty(LocationConstants.PROPERTY_ZONE, ZONE); BlobStoreContext context = ContextBuilder.newBuilder(PROVIDER) .credentials(USERNAME, API_KEY) .overrides(overrides) .buildView(BlobStoreContext.class); blobStore = context.getBlobStore(); }
new SLF4JLoggingModule(), new ExecutorServiceModule(executorService))) .overrides(properties); if (!Strings.isNullOrEmpty(endpoint)) { builder = builder.endpoint(endpoint);
public synchronized void downloadNewFiles(File downloadDir) { log.info("Downloading new files since {}", lastMarker); BlobStoreContext ctx = ContextBuilder.newBuilder(provider) .credentials(user, key) .overrides(new Properties() {{ setProperty(LocationConstants.PROPERTY_ZONE, zone); }}) .buildView(BlobStoreContext.class); // threadsafe according to https://jclouds.apache.org/documentation/userguide/blobstore-guide/ BlobStore store = ctx.getBlobStore(); ListContainerOptions options = new ListContainerOptions().maxResults(batchSize).afterMarker(lastMarker); PageSet<? extends StorageMetadata> pages = store.list(container, options); //Gets key within the time range specified NavigableMap<Long, String> mapWithinRange = getBlobsWithinRange(pages); //Download only for keys within that range for(Map.Entry<Long, String> blobMeta : mapWithinRange.entrySet()) { log.info("Downloading file: " + blobMeta.getValue()); downloadWorkers.submit(new BlobDownload(downloadDir, store, container, blobMeta.getValue())); lastMarker = blobMeta.getValue(); synchronized (CloudFilesManager.this) { // this is where we resume from. MarkerUtils.writeLastMarker(blobMeta.getValue()); } } log.info("Updated the last marker value as " + lastMarker); }
builder.blobStoreProvider) .credentials(accessKey, secretKey) .overrides(properties).build(BlobStoreContext.class);
public synchronized boolean hasNewFiles() { // see if there are any files since lastMarker. BlobStoreContext ctx = ContextBuilder.newBuilder(provider) .credentials(user, key) .overrides(new Properties() {{ setProperty(LocationConstants.PROPERTY_ZONE, zone); }}) .buildView(BlobStoreContext.class); BlobStore store = ctx.getBlobStore(); ListContainerOptions options = new ListContainerOptions().maxResults(batchSize).afterMarker(lastMarker); PageSet<? extends StorageMetadata> pages = store.list(container, options); log.debug("Saw {} new files since {}", pages.size() == batchSize ? "many" : Integer.toString(pages.size()), lastMarker); boolean emptiness = getBlobsWithinRange(pages).isEmpty(); if(emptiness) { log.warn("No file found within range {}", new Range(START_TIME, STOP_TIME)); } else { log.debug("New files found within range {}", new Range(START_TIME, STOP_TIME)); } return !emptiness; }
public void testOverrideInitStatusProperties() { Properties overrides = new Properties(); overrides.setProperty(ComputeServiceProperties.INIT_STATUS_INITIAL_PERIOD, "501"); overrides.setProperty(ComputeServiceProperties.INIT_STATUS_MAX_PERIOD, "5001"); InitStatusProperties props = ContextBuilder.newBuilder("stub").overrides(overrides).buildInjector() .getInstance(InitStatusProperties.class); assertEquals(props.initStatusInitialPeriod, 501); assertEquals(props.initStatusMaxPeriod, 5001); }
public static ContextBuilder newBuilder(int testPort, Properties properties, Module... connectionModules) { properties.setProperty(PROPERTY_TRUST_ALL_CERTS, "true"); properties.setProperty(PROPERTY_RELAX_HOSTNAME, "true"); return ContextBuilder .newBuilder( AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost:" + testPort)) .modules(ImmutableSet.<Module> copyOf(connectionModules)).overrides(properties); }
static DynECTApi mockDynectApi(String uri) { Properties overrides = new Properties(); overrides.setProperty(PROPERTY_MAX_RETRIES, "1"); return ContextBuilder.newBuilder("dynect") .credentials("jclouds:joe", "letmein") .endpoint(uri) .overrides(overrides) .modules(modules) .buildApi(DynECTApi.class); }
protected Injector createInjector() { ProviderMetadata pm = createProviderMetadata(); ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder.newBuilder(ApiMetadata.class .cast(checkNotNull(createApiMetadata(), "either createApiMetadata or createProviderMetadata must be overridden"))); return builder.credentials(identity, credential) .modules(ImmutableSet.of(new MockModule(), new NullLoggingModule(), createModule())) .overrides(setupProperties()).buildInjector(); }