當前位置: 首頁>>代碼示例>>Java>>正文


Java MantaClient類代碼示例

本文整理匯總了Java中com.joyent.manta.client.MantaClient的典型用法代碼示例。如果您正苦於以下問題:Java MantaClient類的具體用法?Java MantaClient怎麽用?Java MantaClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MantaClient類屬於com.joyent.manta.client包,在下文中一共展示了MantaClient類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initialize

import com.joyent.manta.client.MantaClient; //導入依賴的package包/類
/**
 * Initialization method called after a new FileSystem instance is constructed.
 *
 * @param name a uri whose authority section names the host, port, etc.
 *             for this FileSystem. [Not used for Manta implementation]
 * @param conf Hadoop configuration object
 * @throws IOException thrown when we can't create a Manta Client
 */
@Override
public void initialize(final URI name, final Configuration conf) throws IOException {
    super.initialize(name, conf);

    ChainedConfigContext chained = new ChainedConfigContext(
            new EnvVarConfigContext(),
            new MapConfigContext(System.getProperties()),
            new HadoopConfigurationContext(conf),
            new DefaultsConfigContext()
    );

    dumpConfig(chained);

    this.config = chained;
    this.client = new MantaClient(this.config);

    this.workingDir = getInitialWorkingDirectory();
}
 
開發者ID:joyent,項目名稱:hadoop-manta,代碼行數:27,代碼來源:MantaFileSystem.java

示例2: canAddSmallFileToNonExistentPath

import com.joyent.manta.client.MantaClient; //導入依賴的package包/類
@Test
public void canAddSmallFileToNonExistentPath() throws IOException {
    Path file = new Path(testPathPrefix +
            "i-dont-exist" + MantaClient.SEPARATOR + UUID.randomUUID() +
            MantaClient.SEPARATOR +
            "upload-" + UUID.randomUUID() + ".txt");

    try (FSDataOutputStream out = fs.create(file)) {
        out.write(TEST_DATA.getBytes(Charsets.UTF_8));
    }

    boolean exists = client.existsAndIsAccessible(file.toString());
    assertTrue("File didn't get uploaded to path: " + file,
            exists);

    String actual = client.getAsString(file.toString());
    assertEquals("Uploaded contents didn't match", TEST_DATA, actual);
}
 
開發者ID:joyent,項目名稱:hadoop-manta,代碼行數:19,代碼來源:MantaFileSystemIT.java

示例3: canCopyFromMantaDirectoryToLocalDirectory

import com.joyent.manta.client.MantaClient; //導入依賴的package包/類
@Test
public void canCopyFromMantaDirectoryToLocalDirectory() throws IOException {
    String tempDirPath = FileUtils.getTempDirectoryPath() + File.separator
            + "manta-copy-" + UUID.randomUUID() + File.separator;
    File tempDir = new File(tempDirPath);
    String mantaPath = testPathPrefix + "test-dir" + MantaClient.SEPARATOR;
    client.putDirectory(mantaPath);
    client.put(mantaPath + "file-1.txt", TEST_DATA);
    client.put(mantaPath + "file-2.txt", TEST_DATA);

    try {
        fs.copyToLocalFile(true, new Path("manta://" + mantaPath),
                new Path(tempDir.toURI()), false);

        File file1 = new File(tempDirPath + "file-1.txt");
        String actual1 = FileUtils.readFileToString(file1);
        assertEquals("Downloaded contents didn't match", TEST_DATA, actual1);
        File file2 = new File(tempDirPath + "file-2.txt");
        String actual2 = FileUtils.readFileToString(file2);
        assertEquals("Downloaded contents didn't match", TEST_DATA, actual2);
    } finally {
        FileUtils.deleteDirectory(tempDir);
    }
}
 
開發者ID:joyent,項目名稱:hadoop-manta,代碼行數:25,代碼來源:MantaFileSystemIT.java

示例4: RangeJoiningInputStream

import com.joyent.manta.client.MantaClient; //導入依賴的package包/類
/**
 * Creates a new instance that uses multiple HTTP range requests to get
 * a single file and glue it all together as a single {@link InputStream}.
 *
 * @param path path to object in Manta
 * @param client reference to an open Manta client
 * @param size size of the object
 * @param noOfSections number of sections to split object into
 */
RangeJoiningInputStream(final String path,
                        final MantaClient client,
                        final long size,
                        final int noOfSections) {
    Objects.requireNonNull(path);
    Objects.requireNonNull(client);

    if (size <= 0) {
        throw new IllegalArgumentException("Size of test object must be greater than zero");
    }

    if (noOfSections <= 1) {
        throw new IllegalArgumentException("Number of sections for test object must be greater than one");
    }

    this.path = path;
    this.client = client;
    this.size = size;
    this.sections = splitIntoSections(size, noOfSections);
    this.streamSupplier = new MantaObjectInputStreamSupplier();

}
 
開發者ID:joyent,項目名稱:cosbench-manta,代碼行數:32,代碼來源:RangeJoiningInputStream.java

示例5: before

import com.joyent.manta.client.MantaClient; //導入依賴的package包/類
@BeforeClass
public static void before() throws IOException {

    // Let TestNG configuration take precedence over environment variables
    ConfigContext config = new SystemSettingsConfigContext();

    mantaClient = new MantaClient(config);
    testPathPrefix = String.format("/%s/stor/%s/",
            config.getMantaHomeDirectory(), UUID.randomUUID());
    mantaClient.putDirectory(testPathPrefix, null);
}
 
開發者ID:joyent,項目名稱:hadoop-manta,代碼行數:12,代碼來源:MantaSeekableInputStreamIT.java

示例6: canMakeMultipleDirectories

import com.joyent.manta.client.MantaClient; //導入依賴的package包/類
@Test
public void canMakeMultipleDirectories() throws IOException {
    Path newDirectory = new Path(testPathPrefix + "newDirectory-"  + UUID.randomUUID()
        + MantaClient.SEPARATOR + "subdir1" + MantaClient.SEPARATOR + "subdir2");
    boolean result = fs.mkdirs(newDirectory);

    assertTrue("Directory not indicated as created", result);
    boolean exists = client.existsAndIsAccessible(newDirectory.toString());
    assertTrue("Directory doesn't exist on Manta", exists);
}
 
開發者ID:joyent,項目名稱:hadoop-manta,代碼行數:11,代碼來源:MantaFileSystemIT.java

示例7: canCopyLocalDirectoryToManta

import com.joyent.manta.client.MantaClient; //導入依賴的package包/類
@Test
public void canCopyLocalDirectoryToManta() throws IOException {
    String mantaPath = testPathPrefix + "wildcard-upload";
    client.putDirectory(mantaPath);

    String tempDirPath = FileUtils.getTempDirectoryPath() + File.separator +
            UUID.randomUUID();
    File tempDir = new File(tempDirPath);
    Assert.assertTrue("Expected temp subdir to be created", tempDir.mkdir());

    try {
        File file1 = new File(tempDirPath + File.separator + "file-1.txt");
        File file2 = new File(tempDirPath + File.separator + "file-2.txt");

        Files.write(file1.toPath(), (TEST_DATA).getBytes(Charsets.UTF_8));
        Files.write(file2.toPath(), (TEST_DATA).getBytes(Charsets.UTF_8));

        fs.copyFromLocalFile(false, false,
                new Path(tempDir.toURI()),
                new Path("manta://" + mantaPath));

        String file1MantaPath = mantaPath + MantaClient.SEPARATOR +
                tempDir.getName() + MantaClient.SEPARATOR + file1.getName();
        Assert.assertEquals(client.getAsString(file1MantaPath), TEST_DATA);
        String file2MantaPath = mantaPath + MantaClient.SEPARATOR +
                tempDir.getName() + MantaClient.SEPARATOR + file2.getName();
        Assert.assertTrue(client.existsAndIsAccessible(file2MantaPath));
        Assert.assertEquals(client.getAsString(file2MantaPath), TEST_DATA);
    } finally {
        FileUtils.deleteDirectory(tempDir);
    }
}
 
開發者ID:joyent,項目名稱:hadoop-manta,代碼行數:33,代碼來源:MantaFileSystemIT.java

示例8: connect

import com.joyent.manta.client.MantaClient; //導入依賴的package包/類
@Override
protected MantaClient connect(final HostKeyCallback key, final LoginCallback prompt) throws BackgroundException {
    return new MantaClient(config, new MantaConnectionFactoryConfigurator(builder.build(this, prompt)));
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:5,代碼來源:MantaSession.java

示例9: init

import com.joyent.manta.client.MantaClient; //導入依賴的package包/類
@Override
public void init(final Config config, final Logger logger) {
    logger.debug("Manta client has started initialization");
    super.init(config, logger);

    // We change the default number of connections to something more
    // fitting for COSBench.
    StandardConfigContext defaults = new StandardConfigContext();
    defaults.overwriteWithContext(new DefaultsConfigContext());
    defaults.setMaximumConnections(MAX_CONNECTIONS);

    final CosbenchMantaConfigContext cosbenchConfig = new CosbenchMantaConfigContext(config);
    final ChainedConfigContext context = new ChainedConfigContext(defaults, new EnvVarConfigContext(),
            new SystemSettingsConfigContext(), cosbenchConfig);

    this.durabilityLevel = cosbenchConfig.getDurabilityLevel();
    this.logging = cosbenchConfig.logging();
    this.sections = cosbenchConfig.getNumberOfSections();
    this.objectSize = cosbenchConfig.getObjectSize();
    this.multipart = cosbenchConfig.isMultipart();

    this.splitSize = cosbenchConfig.getSplitSize();
    if (splitSize == null) {
        splitSize = DEFAULT_SPLIT;
    }
    if (cosbenchConfig.chunked() == null) {
        if (logging) {
            logger.info("Chunked mode is disabled");
        }

        this.chunked = false;
    } else {
        final String status;
        if (cosbenchConfig.chunked()) {
            status = "enabled";
        } else {
            status = "disabled";
        }

        if (logging) {
            logger.info("Chunked mode is " + status);
        }
        this.chunked = cosbenchConfig.chunked();
    }

    if (logging) {
        logger.info(String.format("Client configuration: %s", context));
    }

    try {
        client = new MantaClient(context);

        final String baseDir = Objects.toString(cosbenchConfig.getBaseDirectory(), DEFAULT_COSBENCH_BASE_DIR);

        // We rely on COSBench properly cleaning up after itself.
        currentTestDirectory = String.format("%s/%s", context.getMantaHomeDirectory(), baseDir);

        client.putDirectory(currentTestDirectory, true);

        if (!client.existsAndIsAccessible(currentTestDirectory)) {
            String msg = "Unable to create base test directory";
            throw new StorageException(msg);
        }
    } catch (IOException e) {
        logger.error("Error in initialization", e);
        throw new StorageException(e);
    }

    if (logging) {
        logger.debug("Manta client has been initialized");
    }
    if (cosbenchConfig.isClientEncryptionEnabled()) {
        encryptedMultipartManager = new EncryptedServerSideMultipartManager(client);
    }
    serverMultipartManager = new ServerSideMultipartManager(client);
}
 
開發者ID:joyent,項目名稱:cosbench-manta,代碼行數:77,代碼來源:MantaStorage.java

示例10: getMantaClient

import com.joyent.manta.client.MantaClient; //導入依賴的package包/類
/**
 * Package private visibility method for getting the Manta SDK client
 * used for testing.
 *
 * @return reference to the backing Manta client
 */
@VisibleForTesting
MantaClient getMantaClient() {
    return this.client;
}
 
開發者ID:joyent,項目名稱:hadoop-manta,代碼行數:11,代碼來源:MantaFileSystem.java


注:本文中的com.joyent.manta.client.MantaClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。