Skip to content

Commit

Permalink
Update options and completefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinjia committed Jan 12, 2016
1 parent c624157 commit f08fe13
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 119 deletions.
Expand Up @@ -83,26 +83,6 @@ protected void afterConnect() throws IOException {
mClient = new FileSystemMasterClientService.Client(mProtocol);
}

/**
* Creates a new file.
*
* @param path the file path
* @param options method options
* @return the file id referencing the newly created file
* @throws IOException if an I/O error occurs
* @throws TachyonException if a Tachyon error occurs
*/
// TODO(calvin): Remove this
public synchronized long create(final String path, final CreateOptions options)
throws IOException, TachyonException {
return retryRPC(new RpcCallableThrowsTachyonTException<Long>() {
@Override
public Long call() throws TachyonTException, TException {
return mClient.create(path, options.toThrift());
}
});
}

/**
* Creates a new directory.
*
Expand All @@ -113,10 +93,11 @@ public Long call() throws TachyonTException, TException {
*/
public synchronized void createDirectory(final TachyonURI path,
final CreateDirectoryOptions options) throws IOException, TachyonException {
retryRPC(new RpcCallableThrowsTachyonTException<Boolean>() {
retryRPC(new RpcCallableThrowsTachyonTException<Void>() {
@Override
public Boolean call() throws TachyonTException, TException {
return mClient.mkdir(path.getPath(), options.toThrift());
public Void call() throws TachyonTException, TException {
mClient.createDirectory(path.getPath(), options.toThrift());
return null;
}
});
}
Expand All @@ -135,7 +116,7 @@ public synchronized TachyonURI createFile(final TachyonURI path, final CreateFil
return retryRPC(new RpcCallableThrowsTachyonTException<TachyonURI>() {
@Override
public TachyonURI call() throws TachyonTException, TException {
mClient.create(path.getPath(), options.toThrift());
mClient.createFile(path.getPath(), options.toThrift());
// TODO(calvin): Look into changing the master side implementation
return path;
}
Expand Down
Expand Up @@ -20,7 +20,7 @@
import tachyon.client.ClientContext;
import tachyon.client.UnderStorageType;
import tachyon.client.WriteType;
import tachyon.thrift.MkdirTOptions;
import tachyon.thrift.CreateDirectoryTOptions;

@PublicApi
public final class CreateDirectoryOptions {
Expand Down Expand Up @@ -111,9 +111,8 @@ public String toString() {
/**
* @return Thrift representation of the options
*/
// TODO(calvin): Rename the mkdir options to CreateDirectoryTOptions
public MkdirTOptions toThrift() {
MkdirTOptions options = new MkdirTOptions();
public CreateDirectoryTOptions toThrift() {
CreateDirectoryTOptions options = new CreateDirectoryTOptions();
options.setAllowExists(mAllowExists);
options.setRecursive(mRecursive);
options.setPersisted(mUnderStorageType.isSyncPersist());
Expand Down
Expand Up @@ -24,7 +24,7 @@
import tachyon.client.UnderStorageType;
import tachyon.client.WriteType;
import tachyon.client.file.policy.FileWriteLocationPolicy;
import tachyon.thrift.CreateTOptions;
import tachyon.thrift.CreateFileTOptions;
import tachyon.util.CommonUtils;

@PublicApi
Expand Down Expand Up @@ -187,9 +187,8 @@ public String toString() {
/**
* @return Thrift representation of the options
*/
// TODO(calvin): Rename CreateTOptions to CreateFileTOptions
public CreateTOptions toThrift() {
CreateTOptions options = new CreateTOptions();
public CreateFileTOptions toThrift() {
CreateFileTOptions options = new CreateFileTOptions();
options.setBlockSizeBytes(mBlockSizeBytes);
options.setPersisted(mUnderStorageType.isSyncPersist());
options.setRecursive(mRecursive);
Expand Down
Expand Up @@ -19,6 +19,7 @@

import tachyon.annotation.PublicApi;
import tachyon.exception.PreconditionMessage;
import tachyon.thrift.SetAttributeTOptions;
import tachyon.thrift.SetStateTOptions;

/**
Expand All @@ -38,15 +39,15 @@ public static SetAttributeOptions defaults() {
* @param options the thrift options to convert from
* @return a {@link SetAttributeOptions} logically equivalent to the given thrift options
*/
public static SetAttributeOptions fromThriftOptions(SetStateTOptions options) {
public static SetAttributeOptions fromThriftOptions(SetAttributeTOptions options) {
return new SetAttributeOptions(options);
}

private Boolean mPinned;
private Long mTTL;
private Boolean mPersisted;

private SetAttributeOptions(SetStateTOptions options) {
private SetAttributeOptions(SetAttributeTOptions options) {
mPinned = options.isSetPinned() ? options.isPinned() : null;
mTTL = options.isSetTtl() ? options.getTtl() : null;
mPersisted = options.isSetPersisted() ? options.isPersisted() : null;
Expand Down Expand Up @@ -141,8 +142,8 @@ public SetAttributeOptions setPersisted(boolean persisted) {
/**
* @return Thrift representation of the options
*/
public SetStateTOptions toThrift() {
SetStateTOptions options = new SetStateTOptions();
public SetAttributeTOptions toThrift() {
SetAttributeTOptions options = new SetAttributeTOptions();
if (mPinned != null) {
options.setPinned(mPinned);
}
Expand Down

0 comments on commit f08fe13

Please sign in to comment.