Search in sources :

Example 56 with CreateFileOptions

use of alluxio.client.file.options.CreateFileOptions in project SSM by Intel-bigdata.

the class AlluxioStatesUpdateService method checkAndMarkRunning.

private FileOutStream checkAndMarkRunning(FileSystem fs) throws IOException {
    AlluxioURI moverIdPath = new AlluxioURI(ALLUXIO_MOVER_ID_PATH);
    try {
        if (fs.exists(moverIdPath)) {
            // Alluxio does not support append operation (ALLUXIO-25), here just delete it
            fs.delete(moverIdPath, DeleteOptions.defaults().setRecursive(true));
        }
        CreateFileOptions options = CreateFileOptions.defaults().setWriteType(WriteType.MUST_CACHE);
        FileOutStream fos = fs.createFile(moverIdPath, options);
        fos.write(InetAddress.getLocalHost().getHostName().getBytes());
        fos.flush();
        return fos;
    } catch (IOException | AlluxioException e) {
        LOG.error("Unable to lock alluxio 'mover', please stop alluxio 'mover' first.");
        throw new IOException(e.getMessage());
    }
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) FileOutStream(alluxio.client.file.FileOutStream) IOException(java.io.IOException) AlluxioURI(alluxio.AlluxioURI) AlluxioException(alluxio.exception.AlluxioException)

Example 57 with CreateFileOptions

use of alluxio.client.file.options.CreateFileOptions in project SSM by Intel-bigdata.

the class TestAlluxioNamespaceFetcher method createFile.

private void createFile(String path) {
    CreateFileOptions options = CreateFileOptions.defaults().setWriteType(WriteType.MUST_CACHE);
    FileOutStream fos = null;
    try {
        fos = fs.createFile(new AlluxioURI(path), options);
        fos.write(new byte[] { 1 });
    } catch (IOException | AlluxioException e) {
        e.printStackTrace();
    } finally {
        if (fos != null) {
            try {
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : CreateFileOptions(alluxio.client.file.options.CreateFileOptions) FileOutStream(alluxio.client.file.FileOutStream) IOException(java.io.IOException) AlluxioURI(alluxio.AlluxioURI) AlluxioException(alluxio.exception.AlluxioException)

Aggregations

CreateFileOptions (alluxio.client.file.options.CreateFileOptions)57 AlluxioURI (alluxio.AlluxioURI)51 Test (org.junit.Test)45 FileInStream (alluxio.client.file.FileInStream)21 FileOutStream (alluxio.client.file.FileOutStream)16 URIStatus (alluxio.client.file.URIStatus)11 HashMap (java.util.HashMap)5 CreateDirectoryOptions (alluxio.client.file.options.CreateDirectoryOptions)4 BeforeClass (org.junit.BeforeClass)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 AlluxioException (alluxio.exception.AlluxioException)2 UnderFileSystem (alluxio.underfs.UnderFileSystem)2 IOException (java.io.IOException)2 Before (org.junit.Before)2 Matchers.anyString (org.mockito.Matchers.anyString)2 DeleteOptions (alluxio.client.file.options.DeleteOptions)1 OpenFileOptions (alluxio.client.file.options.OpenFileOptions)1 SetAttributeOptions (alluxio.client.file.options.SetAttributeOptions)1 LineageFileSystem (alluxio.client.lineage.LineageFileSystem)1 LineageMasterClient (alluxio.client.lineage.LineageMasterClient)1