当前位置: 首页>>代码示例>>Java>>正文


Java BlobStoreContext类代码示例

本文整理汇总了Java中org.jclouds.blobstore.BlobStoreContext的典型用法代码示例。如果您正苦于以下问题:Java BlobStoreContext类的具体用法?Java BlobStoreContext怎么用?Java BlobStoreContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BlobStoreContext类属于org.jclouds.blobstore包,在下文中一共展示了BlobStoreContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerAddress

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
private void registerAddress(String cluster, InetSocketAddress address) throws HekateException {
    try (BlobStoreContext ctx = createContext()) {
        BlobStore store = ctx.getBlobStore();

        String file = cluster + '/' + AddressUtils.toFileName(address);

        try {
            if (!store.blobExists(container, file)) {
                Blob blob = store.blobBuilder(file)
                    .type(StorageType.BLOB)
                    .payload(new byte[]{1})
                    .build();

                store.putBlob(container, blob);

                if (log.isInfoEnabled()) {
                    log.info("Registered address to the cloud store [container={}, file={}]", container, file);
                }
            }
        } catch (ResourceNotFoundException | HttpResponseException e) {
            throw new HekateException("Failed to register the seed node address to the cloud store "
                + "[container=" + container + ", file=" + file + ']', e);
        }
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:26,代码来源:CloudStoreSeedNodeProvider.java

示例2: unregisterAddress

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
private void unregisterAddress(String cluster, InetSocketAddress address) {
    try (BlobStoreContext ctx = createContext()) {
        BlobStore store = ctx.getBlobStore();

        String file = cluster + '/' + AddressUtils.toFileName(address);

        try {
            if (store.blobExists(container, file)) {
                store.removeBlob(container, file);

                if (log.isInfoEnabled()) {
                    log.info("Unregistered address from the cloud store [container={}, file={}]", container, file);
                }
            }
        } catch (ResourceNotFoundException | HttpResponseException e) {
            if (log.isWarnEnabled()) {
                log.warn("Failed to unregister the seed node address from the cloud store "
                    + "[container={}, file={}, cause={}]", container, file, e.toString());
            }
        }
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:23,代码来源:CloudStoreSeedNodeProvider.java

示例3: newByteChannel

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
/**
 * File access is checked using {@link #checkAccess(BlobStoreContext, CloudPath, Set)}
 * always with {@link AclEntryPermission#WRITE_DATA} and {@link AclEntryPermission#ADD_FILE},
 * and optionally with {@link AclEntryPermission#APPEND_DATA} if <em>options</em> contains
 * {@link StandardOpenOption#APPEND}.
 * @see	CloudFileChannel
 */
@Override
public CloudFileChannel newByteChannel(BlobStoreContext context, CloudPath path,
		Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
	EnumSet<AclEntryPermission> channelPerms = EnumSet.noneOf(AclEntryPermission.class);
	options.forEach(o -> {
		AclEntryPermission aclPerm = openOptionToAclEntryPermission(o);
		if (aclPerm != null) {
			channelPerms.add(aclPerm);
		}
	});

	// Check the parent path for file add
	if (channelPerms.remove(AclEntryPermission.ADD_FILE)) {
		checkAccess(context, path.getParent(), CREATE_NEW_FILE_PERMS);
	}

	// Check file access if the file exists
	if (path.exists()) {
		checkAccess(context, path, channelPerms);
	}
	
	// Create the channel
	return new CloudFileChannel(context, path, getCloudFileChannelTransport(), options, attrs);
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:32,代码来源:DefaultCloudFileSystemImplementation.java

示例4: delete

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
/**
 * A non-optimised delete method using vanilla JClouds functionality which invokes
 * {@link #delete(BlobStoreContext, CloudPath, EnumSet)} for each entry.
 * Implementors can override this method to provide vendor-specific operations
 * where applicable.
 * 
 * @param context
 * @param paths
 * @param options
 * @throws IOException
 */
@Override
public void delete(BlobStoreContext context, Collection<CloudPath> paths, EnumSet<DeleteOption> options)
		throws IOException {
	for (CloudPath path : paths) {
		try {
			delete(context, path, options);
		} catch (IOException e) {
			if (options.contains(CloudCopyOption.FAIL_SILENTLY)) {
				LOG.warn("Delete failed for {}, slient failure specified, continuing", path, e);
			} else {
				throw e;
			}
		}
	}
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:27,代码来源:DefaultCloudFileSystemImplementation.java

示例5: copy

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
@Override
public Map<CloudPath,CloudMethod> copy(BlobStoreContext context, Set<CloudPath> sources, Path target, Set<CopyOption> options)
		throws IOException {
	boolean copyMethodReturns = !options.contains(CloudCopyOption.DONT_RETURN_COPY_METHOD);
	Map<CloudPath,CloudMethod> copyMethodsMap = copyMethodReturns ? new HashMap<>() : null;

	for (CloudPath source : sources) {
		try {
			copy(context, source, target, options);
		} catch (IOException e) {
			if (options.contains(CloudCopyOption.FAIL_SILENTLY)) {
				LOG.warn("Copy from {} to {} failed, slient failure specified, continuing", source, target, e);
			} else {
				throw e;
			}
		}
	}

	return copyMethodsMap;
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:21,代码来源:DefaultCloudFileSystemImplementation.java

示例6: copyAcls

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
/**
 * Copies the ACL's from the source to the target paths.
 * @param context
 * @param source
 * @param target
 * @throws IOException
 */
protected void copyAcls(BlobStoreContext context, CloudPath source, CloudPath target) throws IOException {
	// Set the ACL's
	CloudFileAttributesView fileAttributeView =
			getFileAttributeView(context, CloudFileAttributesView.class, source);
	if (fileAttributeView != null) {
		CloudAclFileAttributes fileAttributes = fileAttributeView.readAttributes();

		if (fileAttributes != null) {
			LOG.debug("Setting ACL's for {} to {}", target, fileAttributes);
			setAttribute(context, target, ACL_SET_ATTRIBUTE, fileAttributes.getAclSet());
		} else {
			LOG.warn("Cannot set ACL's for {}, no ACL file attributes are available", target);
		}

	} else {
		LOG.warn("Cannot set ACL's for {}, no file attributes view available", target);
	}
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:26,代码来源:DefaultCloudFileSystemImplementation.java

示例7: testCreateCloudFileSystemInternalWillCreateTheFileSystemIfItHasntBeenCreatedYet

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
@Test
public void testCreateCloudFileSystemInternalWillCreateTheFileSystemIfItHasntBeenCreatedYet() {
	CloudHostConfiguration config = context.mock(CloudHostConfiguration.class);
	FileSystemProvider provider = context.mock(FileSystemProvider.class);
	BlobStoreContext blobStoreContext = context.mock(BlobStoreContext.class);

	context.checking(new Expectations() {{
		allowing(config).getName();
		will(returnValue("test-config"));
		
		exactly(1).of(config).createBlobStoreContext();
		will(returnValue(blobStoreContext));
	}});

	Assert.assertTrue(((Map<?,?>)WhiteboxImpl.getInternalState(impl, "cloudFileSystems")).isEmpty());
	impl.createCloudFilesystemInternal(provider, config);
	Map<String,CloudFileSystem> cloudFileSystemsMap =
			((Map<String,CloudFileSystem>)WhiteboxImpl.getInternalState(impl, "cloudFileSystems"));
	Assert.assertTrue(cloudFileSystemsMap.containsKey("test-config"));
	Assert.assertNotNull(cloudFileSystemsMap.get("test-config"));
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:22,代码来源:JCloudsCloudHostProviderTest.java

示例8: testCreateCloudFileSystemInternalWillThrowAnErrorIfAnAttemptIsMadeToCreateTheFilesystemMoreThanOnce

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
@Test
public void testCreateCloudFileSystemInternalWillThrowAnErrorIfAnAttemptIsMadeToCreateTheFilesystemMoreThanOnce() {
	CloudHostConfiguration config = context.mock(CloudHostConfiguration.class);
	FileSystemProvider provider = context.mock(FileSystemProvider.class);
	BlobStoreContext blobStoreContext = context.mock(BlobStoreContext.class);

	context.checking(new Expectations() {{
		allowing(config).getName();
		will(returnValue("test-config"));
		
		exactly(1).of(config).createBlobStoreContext();
		will(returnValue(blobStoreContext));
	}});

	impl.createCloudFilesystemInternal(provider, config);
	
	try {
		impl.createCloudFilesystemInternal(provider, config);
		Assert.fail("Expected an exception");
	} catch (DuplicateCloudHostnameException e) {
		// OK
	}
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:24,代码来源:JCloudsCloudHostProviderTest.java

示例9: testCreateCloudFileSystemInternalWillAllowTheFileSystemToBeCreatedAgainAfterItHasBeenClosed

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
@Test
public void testCreateCloudFileSystemInternalWillAllowTheFileSystemToBeCreatedAgainAfterItHasBeenClosed() throws IOException {
	CloudHostConfiguration config = context.mock(CloudHostConfiguration.class);
	FileSystemProvider provider = context.mock(FileSystemProvider.class);
	BlobStoreContext blobStoreContext = context.mock(BlobStoreContext.class);

	context.checking(new Expectations() {{
		allowing(config).getName();
		will(returnValue("test-config"));
		
		exactly(2).of(config).createBlobStoreContext();
		will(returnValue(blobStoreContext));
		
		exactly(1).of(blobStoreContext).close();
	}});

	// Create and close
	CloudFileSystem fs = impl.createCloudFilesystemInternal(provider, config);
	fs.close();
	
	// Should now be able to create again
	CloudFileSystem fs2 = impl.createCloudFilesystemInternal(provider, config);
	Assert.assertNotEquals(fs, fs2);
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:25,代码来源:JCloudsCloudHostProviderTest.java

示例10: testCreateDirectoryFailsIfThePathExists

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
@Test
public void testCreateDirectoryFailsIfThePathExists() throws IOException {
	CloudPath path = context.mock(CloudPath.class, "path");
	BlobStoreContext blobStoreContext = context.mock(BlobStoreContext.class);

	context.checking(new Expectations() {{
		allowing(path).exists();
		will(returnValue(true));
		
		allowing(path).toAbsolutePath();
		will(returnValue(path));
	}});

	try {
		impl.createDirectory(blobStoreContext, path, new FileAttribute[0]);
		Assert.fail("Did not expect to be able to create the directory when path exists");
	} catch (FileAlreadyExistsException e) {
		// OK
	}
}
 
开发者ID:brdara,项目名称:java-cloud-filesystem-provider,代码行数:21,代码来源:DefaultCloudFileSystemImplementationTest.java

示例11: S3ProxyImpl

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
public S3ProxyImpl(String endpoint, S3Config s3Config) {
    URI uri = URI.create(endpoint);

    Properties properties = new Properties();
    properties.setProperty("s3proxy.authorization", "none");
    properties.setProperty("s3proxy.endpoint", endpoint);
    properties.setProperty("jclouds.provider", "filesystem");
    properties.setProperty("jclouds.filesystem.basedir", "/tmp/s3proxy");

    ContextBuilder builder = ContextBuilder
            .newBuilder("filesystem")
            .credentials("x", "x")
            .modules(ImmutableList.<Module>of(new SLF4JLoggingModule()))
            .overrides(properties);
    BlobStoreContext context = builder.build(BlobStoreContext.class);
    BlobStore blobStore = context.getBlobStore();
    s3Proxy = S3Proxy.builder().awsAuthentication(AuthenticationType.AWS_V2_OR_V4, "x", "x")
                     .endpoint(uri)
                     .keyStore("", "")
                     .blobStore(blobStore)
                     .ignoreUnknownHeaders(true)
                     .build();
    client = new S3JerseyCopyPartClient(s3Config);
}
 
开发者ID:pravega,项目名称:pravega,代码行数:25,代码来源:S3ProxyImpl.java

示例12: init

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
@Before
public void init() {
    initMocks(this);
    uploadS3Stream.retry = 5;
    uploadS3Stream.s3Client = fakeS3Client;
    fakeS3Client.setMakeItFailUpload(false);
    fakeS3Client.setBaseFolder(baseDirectory);
    fakeS3Client.setMakeItFailCompleteUpload(false);
    Properties properties = new Properties();
    properties.setProperty(FilesystemConstants.PROPERTY_BASEDIR, baseDirectory);
    BlobStoreContext blobStoreContext = ContextBuilder.newBuilder("filesystem")
            .overrides(properties)
            .buildView(BlobStoreContext.class);
    this.springCloudBlobStoreContext = new SpringCloudBlobStoreContext(blobStoreContext, bucketName);
    uploadS3Stream.blobStoreContext = this.springCloudBlobStoreContext;
    blobStoreContext.getBlobStore().createContainerInLocation(null, bucketName);
    this.uploadS3Stream.setChunkSize(UploadS3StreamImpl.DEFAULT_CHUNK_SIZE);
    BlobStore blobStore = springCloudBlobStoreContext.getBlobStore();
    blob = blobStore.blobBuilder(fileName).build();
}
 
开发者ID:orange-cloudfoundry,项目名称:db-dumper-service,代码行数:21,代码来源:UploadS3StreamImplTest.java

示例13: setUp

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    containerName = createRandomContainerName();

    nearContext = ContextBuilder
            .newBuilder("transient")
            .credentials("identity", "credential")
            .modules(ImmutableList.<Module>of(new SLF4JLoggingModule()))
            .build(BlobStoreContext.class);
    nearBlobStore = nearContext.getBlobStore();
    nearBlobStore.createContainerInLocation(null, containerName);

    farContext = ContextBuilder
            .newBuilder("transient")
            .credentials("identity", "credential")
            .modules(ImmutableList.<Module>of(new SLF4JLoggingModule()))
            .build(BlobStoreContext.class);
    farBlobStore = farContext.getBlobStore();
    farBlobStore.createContainerInLocation(null, containerName);

    executorService = Executors.newScheduledThreadPool(1);

    eventualBlobStore = EventualBlobStore.newEventualBlobStore(
            nearBlobStore, farBlobStore, executorService, DELAY,
            DELAY_UNIT, 1.0);
}
 
开发者ID:gaul,项目名称:s3proxy,代码行数:27,代码来源:EventualBlobStoreTest.java

示例14: addProviderFromConfig

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
private void addProviderFromConfig(String prefix, String provider) {
    String id = prefix.substring(prefix.lastIndexOf('.')).substring(1);
    logger.info("adding provider from {} id: {}", prefix, id);
    Configuration c = config.subset(prefix);
    BlobStoreContext context;
    try {
        ContextBuilder builder = ContextBuilder.newBuilder(provider);
        String identity = c.getString(Constants.PROPERTY_IDENTITY);
        if (identity != null) {
            builder.credentials(identity, c.getString(Constants.PROPERTY_CREDENTIAL));
        }
        c.addProperty(Constants.PROPERTY_STRIP_EXPECT_HEADER, "true");
        context = builder.overrides(new ConfigurationPropertiesView(c))
                .modules(ImmutableList.of(new SLF4JLoggingModule()))
                .build(BlobStoreContext.class);
        logger.info("added provider {} id {}", context.unwrap().getId(), id);
    } catch (CreationException e) {
        e.printStackTrace();
        throw propagate(e);
    }

    BlobStore blobStore = new LoggingBlobStore(context.getBlobStore(), id, this);
    providers.put(Integer.valueOf(id), blobStore);
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:25,代码来源:BounceApplication.java

示例15: testS3ProxyStartup

import org.jclouds.blobstore.BlobStoreContext; //导入依赖的package包/类
@Test
public void testS3ProxyStartup() throws Exception {
    initializeDefaultProperties();
    startApp();

    String identity = app.getConfiguration().getString(S3ProxyConstants.PROPERTY_IDENTITY);
    String credential = app.getConfiguration().getString(S3ProxyConstants.PROPERTY_CREDENTIAL);
    configureBlobStore(identity, credential);
    BlobStoreContext context = ContextBuilder.newBuilder("s3")
            .endpoint("http://127.0.0.1:" + app.getS3ProxyPort())
            .credentials(app.getConfiguration().getString(S3ProxyConstants.PROPERTY_IDENTITY),
                    app.getConfiguration().getString(S3ProxyConstants.PROPERTY_CREDENTIAL))
            .build(BlobStoreContext.class);
    BlobStore blobStore = context.getBlobStore();
    PageSet<? extends StorageMetadata> res = blobStore.list();
    assertThat(res).isEmpty();
}
 
开发者ID:bouncestorage,项目名称:bouncestorage,代码行数:18,代码来源:BounceApplicationTest.java


注:本文中的org.jclouds.blobstore.BlobStoreContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。