id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
18,500
|
Alluxio/alluxio
|
integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseFileSystem.java
|
AlluxioFuseFileSystem.truncate
|
@Override
public int truncate(String path, long size) {
LOG.error("Truncate is not supported {}", path);
return -ErrorCodes.EOPNOTSUPP();
}
|
java
|
@Override
public int truncate(String path, long size) {
LOG.error("Truncate is not supported {}", path);
return -ErrorCodes.EOPNOTSUPP();
}
|
[
"@",
"Override",
"public",
"int",
"truncate",
"(",
"String",
"path",
",",
"long",
"size",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Truncate is not supported {}\"",
",",
"path",
")",
";",
"return",
"-",
"ErrorCodes",
".",
"EOPNOTSUPP",
"(",
")",
";",
"}"
] |
Changes the size of a file. This operation would not succeed because of Alluxio's write-once
model.
|
[
"Changes",
"the",
"size",
"of",
"a",
"file",
".",
"This",
"operation",
"would",
"not",
"succeed",
"because",
"of",
"Alluxio",
"s",
"write",
"-",
"once",
"model",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseFileSystem.java#L639-L643
|
18,501
|
Alluxio/alluxio
|
integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseFileSystem.java
|
AlluxioFuseFileSystem.rmInternal
|
private int rmInternal(String path) {
final AlluxioURI turi = mPathResolverCache.getUnchecked(path);
try {
mFileSystem.delete(turi);
} catch (FileDoesNotExistException | InvalidPathException e) {
LOG.debug("Failed to remove {}, file does not exist or is invalid", path);
return -ErrorCodes.ENOENT();
} catch (Throwable t) {
LOG.error("Failed to remove {}", path, t);
return AlluxioFuseUtils.getErrorCode(t);
}
return 0;
}
|
java
|
private int rmInternal(String path) {
final AlluxioURI turi = mPathResolverCache.getUnchecked(path);
try {
mFileSystem.delete(turi);
} catch (FileDoesNotExistException | InvalidPathException e) {
LOG.debug("Failed to remove {}, file does not exist or is invalid", path);
return -ErrorCodes.ENOENT();
} catch (Throwable t) {
LOG.error("Failed to remove {}", path, t);
return AlluxioFuseUtils.getErrorCode(t);
}
return 0;
}
|
[
"private",
"int",
"rmInternal",
"(",
"String",
"path",
")",
"{",
"final",
"AlluxioURI",
"turi",
"=",
"mPathResolverCache",
".",
"getUnchecked",
"(",
"path",
")",
";",
"try",
"{",
"mFileSystem",
".",
"delete",
"(",
"turi",
")",
";",
"}",
"catch",
"(",
"FileDoesNotExistException",
"|",
"InvalidPathException",
"e",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Failed to remove {}, file does not exist or is invalid\"",
",",
"path",
")",
";",
"return",
"-",
"ErrorCodes",
".",
"ENOENT",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to remove {}\"",
",",
"path",
",",
"t",
")",
";",
"return",
"AlluxioFuseUtils",
".",
"getErrorCode",
"(",
"t",
")",
";",
"}",
"return",
"0",
";",
"}"
] |
Convenience internal method to remove files or non-empty directories.
@param path The path to remove
@return 0 on success, a negative value on error
|
[
"Convenience",
"internal",
"method",
"to",
"remove",
"files",
"or",
"non",
"-",
"empty",
"directories",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseFileSystem.java#L725-L739
|
18,502
|
Alluxio/alluxio
|
integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseFileSystem.java
|
AlluxioFuseFileSystem.waitForFileCompleted
|
private boolean waitForFileCompleted(AlluxioURI uri) {
try {
CommonUtils.waitFor("file completed", () -> {
try {
return mFileSystem.getStatus(uri).isCompleted();
} catch (Exception e) {
throw new RuntimeException(e);
}
}, WaitForOptions.defaults().setTimeoutMs(MAX_OPEN_WAITTIME_MS));
return true;
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
return false;
} catch (TimeoutException te) {
return false;
}
}
|
java
|
private boolean waitForFileCompleted(AlluxioURI uri) {
try {
CommonUtils.waitFor("file completed", () -> {
try {
return mFileSystem.getStatus(uri).isCompleted();
} catch (Exception e) {
throw new RuntimeException(e);
}
}, WaitForOptions.defaults().setTimeoutMs(MAX_OPEN_WAITTIME_MS));
return true;
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
return false;
} catch (TimeoutException te) {
return false;
}
}
|
[
"private",
"boolean",
"waitForFileCompleted",
"(",
"AlluxioURI",
"uri",
")",
"{",
"try",
"{",
"CommonUtils",
".",
"waitFor",
"(",
"\"file completed\"",
",",
"(",
")",
"->",
"{",
"try",
"{",
"return",
"mFileSystem",
".",
"getStatus",
"(",
"uri",
")",
".",
"isCompleted",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
",",
"WaitForOptions",
".",
"defaults",
"(",
")",
".",
"setTimeoutMs",
"(",
"MAX_OPEN_WAITTIME_MS",
")",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"InterruptedException",
"ie",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"return",
"false",
";",
"}",
"catch",
"(",
"TimeoutException",
"te",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Waits for the file to complete before opening it.
@param uri the file path to check
@return whether the file is completed or not
|
[
"Waits",
"for",
"the",
"file",
"to",
"complete",
"before",
"opening",
"it",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseFileSystem.java#L747-L763
|
18,503
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/file/BaseFileSystem.java
|
BaseFileSystem.close
|
@Override
public synchronized void close() throws IOException {
// TODO(zac) Determine the behavior when closing the context during operations.
if (!mClosed) {
mClosed = true;
if (mCachingEnabled) {
Factory.FILESYSTEM_CACHE.remove(new FileSystemKey(mFsContext.getClientContext()));
}
mFsContext.close();
}
}
|
java
|
@Override
public synchronized void close() throws IOException {
// TODO(zac) Determine the behavior when closing the context during operations.
if (!mClosed) {
mClosed = true;
if (mCachingEnabled) {
Factory.FILESYSTEM_CACHE.remove(new FileSystemKey(mFsContext.getClientContext()));
}
mFsContext.close();
}
}
|
[
"@",
"Override",
"public",
"synchronized",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"// TODO(zac) Determine the behavior when closing the context during operations.",
"if",
"(",
"!",
"mClosed",
")",
"{",
"mClosed",
"=",
"true",
";",
"if",
"(",
"mCachingEnabled",
")",
"{",
"Factory",
".",
"FILESYSTEM_CACHE",
".",
"remove",
"(",
"new",
"FileSystemKey",
"(",
"mFsContext",
".",
"getClientContext",
"(",
")",
")",
")",
";",
"}",
"mFsContext",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
Shuts down the FileSystem. Closes all thread pools and resources used to perform operations. If
any operations are called after closing the context the behavior is undefined.
@throws IOException
|
[
"Shuts",
"down",
"the",
"FileSystem",
".",
"Closes",
"all",
"thread",
"pools",
"and",
"resources",
"used",
"to",
"perform",
"operations",
".",
"If",
"any",
"operations",
"are",
"called",
"after",
"closing",
"the",
"context",
"the",
"behavior",
"is",
"undefined",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/file/BaseFileSystem.java#L131-L141
|
18,504
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/ShortCircuitBlockWriteHandler.java
|
ShortCircuitBlockWriteHandler.onNext
|
@Override
public void onNext(CreateLocalBlockRequest request) {
final String methodName = request.getOnlyReserveSpace() ? "ReserveSpace" : "CreateBlock";
RpcUtils.streamingRPCAndLog(LOG, new RpcUtils.StreamingRpcCallable<CreateLocalBlockResponse>() {
@Override
public CreateLocalBlockResponse call() throws Exception {
if (request.getOnlyReserveSpace()) {
mBlockWorker.requestSpace(mSessionId, request.getBlockId(), request.getSpaceToReserve());
return CreateLocalBlockResponse.newBuilder().build();
} else {
Preconditions.checkState(mRequest == null);
mRequest = request;
if (mSessionId == INVALID_SESSION_ID) {
mSessionId = IdUtils.createSessionId();
String path = mBlockWorker.createBlock(mSessionId, request.getBlockId(),
mStorageTierAssoc.getAlias(request.getTier()), request.getSpaceToReserve());
CreateLocalBlockResponse response =
CreateLocalBlockResponse.newBuilder().setPath(path).build();
return response;
} else {
LOG.warn("Create block {} without closing the previous session {}.",
request.getBlockId(), mSessionId);
throw new InvalidWorkerStateException(
ExceptionMessage.SESSION_NOT_CLOSED.getMessage(mSessionId));
}
}
}
@Override
public void exceptionCaught(Throwable throwable) {
if (mSessionId != INVALID_SESSION_ID) {
// In case the client is a UfsFallbackDataWriter, DO NOT clean the temp blocks.
if (throwable instanceof alluxio.exception.WorkerOutOfSpaceException
&& request.hasCleanupOnFailure() && !request.getCleanupOnFailure()) {
mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(throwable));
return;
}
mBlockWorker.cleanupSession(mSessionId);
mSessionId = INVALID_SESSION_ID;
}
mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(throwable));
}
}, methodName, true, false, mResponseObserver, "Session=%d, Request=%s", mSessionId, request);
}
|
java
|
@Override
public void onNext(CreateLocalBlockRequest request) {
final String methodName = request.getOnlyReserveSpace() ? "ReserveSpace" : "CreateBlock";
RpcUtils.streamingRPCAndLog(LOG, new RpcUtils.StreamingRpcCallable<CreateLocalBlockResponse>() {
@Override
public CreateLocalBlockResponse call() throws Exception {
if (request.getOnlyReserveSpace()) {
mBlockWorker.requestSpace(mSessionId, request.getBlockId(), request.getSpaceToReserve());
return CreateLocalBlockResponse.newBuilder().build();
} else {
Preconditions.checkState(mRequest == null);
mRequest = request;
if (mSessionId == INVALID_SESSION_ID) {
mSessionId = IdUtils.createSessionId();
String path = mBlockWorker.createBlock(mSessionId, request.getBlockId(),
mStorageTierAssoc.getAlias(request.getTier()), request.getSpaceToReserve());
CreateLocalBlockResponse response =
CreateLocalBlockResponse.newBuilder().setPath(path).build();
return response;
} else {
LOG.warn("Create block {} without closing the previous session {}.",
request.getBlockId(), mSessionId);
throw new InvalidWorkerStateException(
ExceptionMessage.SESSION_NOT_CLOSED.getMessage(mSessionId));
}
}
}
@Override
public void exceptionCaught(Throwable throwable) {
if (mSessionId != INVALID_SESSION_ID) {
// In case the client is a UfsFallbackDataWriter, DO NOT clean the temp blocks.
if (throwable instanceof alluxio.exception.WorkerOutOfSpaceException
&& request.hasCleanupOnFailure() && !request.getCleanupOnFailure()) {
mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(throwable));
return;
}
mBlockWorker.cleanupSession(mSessionId);
mSessionId = INVALID_SESSION_ID;
}
mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(throwable));
}
}, methodName, true, false, mResponseObserver, "Session=%d, Request=%s", mSessionId, request);
}
|
[
"@",
"Override",
"public",
"void",
"onNext",
"(",
"CreateLocalBlockRequest",
"request",
")",
"{",
"final",
"String",
"methodName",
"=",
"request",
".",
"getOnlyReserveSpace",
"(",
")",
"?",
"\"ReserveSpace\"",
":",
"\"CreateBlock\"",
";",
"RpcUtils",
".",
"streamingRPCAndLog",
"(",
"LOG",
",",
"new",
"RpcUtils",
".",
"StreamingRpcCallable",
"<",
"CreateLocalBlockResponse",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"CreateLocalBlockResponse",
"call",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"request",
".",
"getOnlyReserveSpace",
"(",
")",
")",
"{",
"mBlockWorker",
".",
"requestSpace",
"(",
"mSessionId",
",",
"request",
".",
"getBlockId",
"(",
")",
",",
"request",
".",
"getSpaceToReserve",
"(",
")",
")",
";",
"return",
"CreateLocalBlockResponse",
".",
"newBuilder",
"(",
")",
".",
"build",
"(",
")",
";",
"}",
"else",
"{",
"Preconditions",
".",
"checkState",
"(",
"mRequest",
"==",
"null",
")",
";",
"mRequest",
"=",
"request",
";",
"if",
"(",
"mSessionId",
"==",
"INVALID_SESSION_ID",
")",
"{",
"mSessionId",
"=",
"IdUtils",
".",
"createSessionId",
"(",
")",
";",
"String",
"path",
"=",
"mBlockWorker",
".",
"createBlock",
"(",
"mSessionId",
",",
"request",
".",
"getBlockId",
"(",
")",
",",
"mStorageTierAssoc",
".",
"getAlias",
"(",
"request",
".",
"getTier",
"(",
")",
")",
",",
"request",
".",
"getSpaceToReserve",
"(",
")",
")",
";",
"CreateLocalBlockResponse",
"response",
"=",
"CreateLocalBlockResponse",
".",
"newBuilder",
"(",
")",
".",
"setPath",
"(",
"path",
")",
".",
"build",
"(",
")",
";",
"return",
"response",
";",
"}",
"else",
"{",
"LOG",
".",
"warn",
"(",
"\"Create block {} without closing the previous session {}.\"",
",",
"request",
".",
"getBlockId",
"(",
")",
",",
"mSessionId",
")",
";",
"throw",
"new",
"InvalidWorkerStateException",
"(",
"ExceptionMessage",
".",
"SESSION_NOT_CLOSED",
".",
"getMessage",
"(",
"mSessionId",
")",
")",
";",
"}",
"}",
"}",
"@",
"Override",
"public",
"void",
"exceptionCaught",
"(",
"Throwable",
"throwable",
")",
"{",
"if",
"(",
"mSessionId",
"!=",
"INVALID_SESSION_ID",
")",
"{",
"// In case the client is a UfsFallbackDataWriter, DO NOT clean the temp blocks.",
"if",
"(",
"throwable",
"instanceof",
"alluxio",
".",
"exception",
".",
"WorkerOutOfSpaceException",
"&&",
"request",
".",
"hasCleanupOnFailure",
"(",
")",
"&&",
"!",
"request",
".",
"getCleanupOnFailure",
"(",
")",
")",
"{",
"mResponseObserver",
".",
"onError",
"(",
"GrpcExceptionUtils",
".",
"fromThrowable",
"(",
"throwable",
")",
")",
";",
"return",
";",
"}",
"mBlockWorker",
".",
"cleanupSession",
"(",
"mSessionId",
")",
";",
"mSessionId",
"=",
"INVALID_SESSION_ID",
";",
"}",
"mResponseObserver",
".",
"onError",
"(",
"GrpcExceptionUtils",
".",
"fromThrowable",
"(",
"throwable",
")",
")",
";",
"}",
"}",
",",
"methodName",
",",
"true",
",",
"false",
",",
"mResponseObserver",
",",
"\"Session=%d, Request=%s\"",
",",
"mSessionId",
",",
"request",
")",
";",
"}"
] |
Handles request to create local block. No exceptions should be thrown.
@param request a create request
|
[
"Handles",
"request",
"to",
"create",
"local",
"block",
".",
"No",
"exceptions",
"should",
"be",
"thrown",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/ShortCircuitBlockWriteHandler.java#L76-L119
|
18,505
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/ShortCircuitBlockWriteHandler.java
|
ShortCircuitBlockWriteHandler.handleBlockCompleteRequest
|
public void handleBlockCompleteRequest(boolean isCanceled) {
final String methodName = isCanceled ? "AbortBlock" : "CommitBlock";
RpcUtils.streamingRPCAndLog(LOG, new RpcUtils.StreamingRpcCallable<CreateLocalBlockResponse>() {
@Override
public CreateLocalBlockResponse call() throws Exception {
if (mRequest == null) {
return null;
}
Context newContext = Context.current().fork();
Context previousContext = newContext.attach();
try {
if (isCanceled) {
mBlockWorker.abortBlock(mSessionId, mRequest.getBlockId());
} else {
mBlockWorker.commitBlock(mSessionId, mRequest.getBlockId());
}
} finally {
newContext.detach(previousContext);
}
mSessionId = INVALID_SESSION_ID;
return null;
}
@Override
public void exceptionCaught(Throwable throwable) {
mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(throwable));
mSessionId = INVALID_SESSION_ID;
}
}, methodName, false, !isCanceled, mResponseObserver, "Session=%d, Request=%s", mSessionId,
mRequest);
}
|
java
|
public void handleBlockCompleteRequest(boolean isCanceled) {
final String methodName = isCanceled ? "AbortBlock" : "CommitBlock";
RpcUtils.streamingRPCAndLog(LOG, new RpcUtils.StreamingRpcCallable<CreateLocalBlockResponse>() {
@Override
public CreateLocalBlockResponse call() throws Exception {
if (mRequest == null) {
return null;
}
Context newContext = Context.current().fork();
Context previousContext = newContext.attach();
try {
if (isCanceled) {
mBlockWorker.abortBlock(mSessionId, mRequest.getBlockId());
} else {
mBlockWorker.commitBlock(mSessionId, mRequest.getBlockId());
}
} finally {
newContext.detach(previousContext);
}
mSessionId = INVALID_SESSION_ID;
return null;
}
@Override
public void exceptionCaught(Throwable throwable) {
mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(throwable));
mSessionId = INVALID_SESSION_ID;
}
}, methodName, false, !isCanceled, mResponseObserver, "Session=%d, Request=%s", mSessionId,
mRequest);
}
|
[
"public",
"void",
"handleBlockCompleteRequest",
"(",
"boolean",
"isCanceled",
")",
"{",
"final",
"String",
"methodName",
"=",
"isCanceled",
"?",
"\"AbortBlock\"",
":",
"\"CommitBlock\"",
";",
"RpcUtils",
".",
"streamingRPCAndLog",
"(",
"LOG",
",",
"new",
"RpcUtils",
".",
"StreamingRpcCallable",
"<",
"CreateLocalBlockResponse",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"CreateLocalBlockResponse",
"call",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"mRequest",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Context",
"newContext",
"=",
"Context",
".",
"current",
"(",
")",
".",
"fork",
"(",
")",
";",
"Context",
"previousContext",
"=",
"newContext",
".",
"attach",
"(",
")",
";",
"try",
"{",
"if",
"(",
"isCanceled",
")",
"{",
"mBlockWorker",
".",
"abortBlock",
"(",
"mSessionId",
",",
"mRequest",
".",
"getBlockId",
"(",
")",
")",
";",
"}",
"else",
"{",
"mBlockWorker",
".",
"commitBlock",
"(",
"mSessionId",
",",
"mRequest",
".",
"getBlockId",
"(",
")",
")",
";",
"}",
"}",
"finally",
"{",
"newContext",
".",
"detach",
"(",
"previousContext",
")",
";",
"}",
"mSessionId",
"=",
"INVALID_SESSION_ID",
";",
"return",
"null",
";",
"}",
"@",
"Override",
"public",
"void",
"exceptionCaught",
"(",
"Throwable",
"throwable",
")",
"{",
"mResponseObserver",
".",
"onError",
"(",
"GrpcExceptionUtils",
".",
"fromThrowable",
"(",
"throwable",
")",
")",
";",
"mSessionId",
"=",
"INVALID_SESSION_ID",
";",
"}",
"}",
",",
"methodName",
",",
"false",
",",
"!",
"isCanceled",
",",
"mResponseObserver",
",",
"\"Session=%d, Request=%s\"",
",",
"mSessionId",
",",
"mRequest",
")",
";",
"}"
] |
Handles complete block request. No exceptions should be thrown.
|
[
"Handles",
"complete",
"block",
"request",
".",
"No",
"exceptions",
"should",
"be",
"thrown",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/ShortCircuitBlockWriteHandler.java#L155-L185
|
18,506
|
Alluxio/alluxio
|
underfs/wasb/src/main/java/alluxio/underfs/wasb/WasbUnderFileSystem.java
|
WasbUnderFileSystem.createConfiguration
|
public static Configuration createConfiguration(UnderFileSystemConfiguration conf) {
Configuration wasbConf = HdfsUnderFileSystem.createConfiguration(conf);
for (Map.Entry<String, String> entry : conf.toMap().entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (PropertyKey.Template.UNDERFS_AZURE_ACCOUNT_KEY.matches(key)) {
wasbConf.set(key, value);
}
}
wasbConf.set("fs.AbstractFileSystem.wasb.impl", "org.apache.hadoop.fs.azure.Wasb");
wasbConf.set("fs.wasb.impl", "org.apache.hadoop.fs.azure.NativeAzureFileSystem");
return wasbConf;
}
|
java
|
public static Configuration createConfiguration(UnderFileSystemConfiguration conf) {
Configuration wasbConf = HdfsUnderFileSystem.createConfiguration(conf);
for (Map.Entry<String, String> entry : conf.toMap().entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (PropertyKey.Template.UNDERFS_AZURE_ACCOUNT_KEY.matches(key)) {
wasbConf.set(key, value);
}
}
wasbConf.set("fs.AbstractFileSystem.wasb.impl", "org.apache.hadoop.fs.azure.Wasb");
wasbConf.set("fs.wasb.impl", "org.apache.hadoop.fs.azure.NativeAzureFileSystem");
return wasbConf;
}
|
[
"public",
"static",
"Configuration",
"createConfiguration",
"(",
"UnderFileSystemConfiguration",
"conf",
")",
"{",
"Configuration",
"wasbConf",
"=",
"HdfsUnderFileSystem",
".",
"createConfiguration",
"(",
"conf",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"conf",
".",
"toMap",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"String",
"value",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"PropertyKey",
".",
"Template",
".",
"UNDERFS_AZURE_ACCOUNT_KEY",
".",
"matches",
"(",
"key",
")",
")",
"{",
"wasbConf",
".",
"set",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
"wasbConf",
".",
"set",
"(",
"\"fs.AbstractFileSystem.wasb.impl\"",
",",
"\"org.apache.hadoop.fs.azure.Wasb\"",
")",
";",
"wasbConf",
".",
"set",
"(",
"\"fs.wasb.impl\"",
",",
"\"org.apache.hadoop.fs.azure.NativeAzureFileSystem\"",
")",
";",
"return",
"wasbConf",
";",
"}"
] |
Prepares the configuration for this Wasb as an HDFS configuration.
@param conf the configuration for this UFS
@return the created configuration
|
[
"Prepares",
"the",
"configuration",
"for",
"this",
"Wasb",
"as",
"an",
"HDFS",
"configuration",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/wasb/src/main/java/alluxio/underfs/wasb/WasbUnderFileSystem.java#L48-L60
|
18,507
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.supplyAsync
|
public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier, Executor executor) {
return asyncSupplyStage(screenExecutor(executor), supplier);
}
|
java
|
public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier, Executor executor) {
return asyncSupplyStage(screenExecutor(executor), supplier);
}
|
[
"public",
"static",
"<",
"U",
">",
"CompletableFuture",
"<",
"U",
">",
"supplyAsync",
"(",
"Supplier",
"<",
"U",
">",
"supplier",
",",
"Executor",
"executor",
")",
"{",
"return",
"asyncSupplyStage",
"(",
"screenExecutor",
"(",
"executor",
")",
",",
"supplier",
")",
";",
"}"
] |
Returns a new CompletableFuture that is asynchronously completed by a task running in the given
executor with the value obtained by calling the given Supplier.
@param supplier a function returning the value to be used to complete the returned
CompletableFuture
@param executor the executor to use for asynchronous execution
@param <U> the function's return type
@return the new CompletableFuture
|
[
"Returns",
"a",
"new",
"CompletableFuture",
"that",
"is",
"asynchronously",
"completed",
"by",
"a",
"task",
"running",
"in",
"the",
"given",
"executor",
"with",
"the",
"value",
"obtained",
"by",
"calling",
"the",
"given",
"Supplier",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L410-L412
|
18,508
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.runAsync
|
public static CompletableFuture<Void> runAsync(Runnable runnable, Executor executor) {
return asyncRunStage(screenExecutor(executor), runnable);
}
|
java
|
public static CompletableFuture<Void> runAsync(Runnable runnable, Executor executor) {
return asyncRunStage(screenExecutor(executor), runnable);
}
|
[
"public",
"static",
"CompletableFuture",
"<",
"Void",
">",
"runAsync",
"(",
"Runnable",
"runnable",
",",
"Executor",
"executor",
")",
"{",
"return",
"asyncRunStage",
"(",
"screenExecutor",
"(",
"executor",
")",
",",
"runnable",
")",
";",
"}"
] |
Returns a new CompletableFuture that is asynchronously completed by a task running in the given
executor after it runs the given action.
@param runnable the action to run before completing the returned CompletableFuture
@param executor the executor to use for asynchronous execution
@return the new CompletableFuture
|
[
"Returns",
"a",
"new",
"CompletableFuture",
"that",
"is",
"asynchronously",
"completed",
"by",
"a",
"task",
"running",
"in",
"the",
"given",
"executor",
"after",
"it",
"runs",
"the",
"given",
"action",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L433-L435
|
18,509
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.completedFuture
|
public static <U> CompletableFuture<U> completedFuture(U value) {
return new CompletableFuture<U>((value == null) ? NIL : value);
}
|
java
|
public static <U> CompletableFuture<U> completedFuture(U value) {
return new CompletableFuture<U>((value == null) ? NIL : value);
}
|
[
"public",
"static",
"<",
"U",
">",
"CompletableFuture",
"<",
"U",
">",
"completedFuture",
"(",
"U",
"value",
")",
"{",
"return",
"new",
"CompletableFuture",
"<",
"U",
">",
"(",
"(",
"value",
"==",
"null",
")",
"?",
"NIL",
":",
"value",
")",
";",
"}"
] |
Returns a new CompletableFuture that is already completed with the given value.
@param value the value
@param <U> the type of the value
@return the completed CompletableFuture
|
[
"Returns",
"a",
"new",
"CompletableFuture",
"that",
"is",
"already",
"completed",
"with",
"the",
"given",
"value",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L444-L446
|
18,510
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.anyOf
|
public static CompletableFuture<Object> anyOf(CompletableFuture<?>... cfs) {
int n;
Object r;
if ((n = cfs.length) <= 1)
return (n == 0) ? new CompletableFuture<Object>()
: (CompletableFuture<Object>) uniCopyStage(cfs[0]);
for (CompletableFuture<?> cf : cfs)
if ((r = cf.result) != null)
return new CompletableFuture<Object>(encodeRelay(r));
cfs = cfs.clone();
CompletableFuture<Object> d = new CompletableFuture<Object>();
for (CompletableFuture<?> cf : cfs)
cf.unipush(new AnyOf(d, cf, cfs));
// If d was completed while we were adding completions, we should
// clean the stack of any sources that may have had completions
// pushed on their stack after d was completed.
if (d.result != null)
for (int i = 0, len = cfs.length; i < len; i++)
if (cfs[i].result != null)
for (i++; i < len; i++)
if (cfs[i].result == null)
cfs[i].cleanStack();
return d;
}
|
java
|
public static CompletableFuture<Object> anyOf(CompletableFuture<?>... cfs) {
int n;
Object r;
if ((n = cfs.length) <= 1)
return (n == 0) ? new CompletableFuture<Object>()
: (CompletableFuture<Object>) uniCopyStage(cfs[0]);
for (CompletableFuture<?> cf : cfs)
if ((r = cf.result) != null)
return new CompletableFuture<Object>(encodeRelay(r));
cfs = cfs.clone();
CompletableFuture<Object> d = new CompletableFuture<Object>();
for (CompletableFuture<?> cf : cfs)
cf.unipush(new AnyOf(d, cf, cfs));
// If d was completed while we were adding completions, we should
// clean the stack of any sources that may have had completions
// pushed on their stack after d was completed.
if (d.result != null)
for (int i = 0, len = cfs.length; i < len; i++)
if (cfs[i].result != null)
for (i++; i < len; i++)
if (cfs[i].result == null)
cfs[i].cleanStack();
return d;
}
|
[
"public",
"static",
"CompletableFuture",
"<",
"Object",
">",
"anyOf",
"(",
"CompletableFuture",
"<",
"?",
">",
"...",
"cfs",
")",
"{",
"int",
"n",
";",
"Object",
"r",
";",
"if",
"(",
"(",
"n",
"=",
"cfs",
".",
"length",
")",
"<=",
"1",
")",
"return",
"(",
"n",
"==",
"0",
")",
"?",
"new",
"CompletableFuture",
"<",
"Object",
">",
"(",
")",
":",
"(",
"CompletableFuture",
"<",
"Object",
">",
")",
"uniCopyStage",
"(",
"cfs",
"[",
"0",
"]",
")",
";",
"for",
"(",
"CompletableFuture",
"<",
"?",
">",
"cf",
":",
"cfs",
")",
"if",
"(",
"(",
"r",
"=",
"cf",
".",
"result",
")",
"!=",
"null",
")",
"return",
"new",
"CompletableFuture",
"<",
"Object",
">",
"(",
"encodeRelay",
"(",
"r",
")",
")",
";",
"cfs",
"=",
"cfs",
".",
"clone",
"(",
")",
";",
"CompletableFuture",
"<",
"Object",
">",
"d",
"=",
"new",
"CompletableFuture",
"<",
"Object",
">",
"(",
")",
";",
"for",
"(",
"CompletableFuture",
"<",
"?",
">",
"cf",
":",
"cfs",
")",
"cf",
".",
"unipush",
"(",
"new",
"AnyOf",
"(",
",",
",",
"cfs",
")",
")",
";",
"// If d was completed while we were adding completions, we should",
"// clean the stack of any sources that may have had completions",
"// pushed on their stack after d was completed.",
"if",
"(",
"d",
".",
"result",
"!=",
"null",
")",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"len",
"=",
"cfs",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"if",
"(",
"cfs",
"[",
"i",
"]",
".",
"result",
"!=",
"null",
")",
"for",
"(",
"i",
"++",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"if",
"(",
"cfs",
"[",
"i",
"]",
".",
"result",
"==",
"null",
")",
"cfs",
"[",
"i",
"]",
".",
"cleanStack",
"(",
")",
";",
"return",
"d",
";",
"}"
] |
Returns a new CompletableFuture that is completed when any of the given CompletableFutures
complete, with the same result. Otherwise, if it completed exceptionally, the returned
CompletableFuture also does so, with a CompletionException holding this exception as its cause.
If no CompletableFutures are provided, returns an incomplete CompletableFuture.
@param cfs the CompletableFutures
@return a new CompletableFuture that is completed with the result or exception of any of the
given CompletableFutures when one completes
@throws NullPointerException if the array or any of its elements are {@code null}
|
[
"Returns",
"a",
"new",
"CompletableFuture",
"that",
"is",
"completed",
"when",
"any",
"of",
"the",
"given",
"CompletableFutures",
"complete",
"with",
"the",
"same",
"result",
".",
"Otherwise",
"if",
"it",
"completed",
"exceptionally",
"the",
"returned",
"CompletableFuture",
"also",
"does",
"so",
"with",
"a",
"CompletionException",
"holding",
"this",
"exception",
"as",
"its",
"cause",
".",
"If",
"no",
"CompletableFutures",
"are",
"provided",
"returns",
"an",
"incomplete",
"CompletableFuture",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L484-L507
|
18,511
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.failedFuture
|
public static <U> CompletableFuture<U> failedFuture(Throwable ex) {
return new CompletableFuture<U>(new AltResult(Objects.requireNonNull(ex)));
}
|
java
|
public static <U> CompletableFuture<U> failedFuture(Throwable ex) {
return new CompletableFuture<U>(new AltResult(Objects.requireNonNull(ex)));
}
|
[
"public",
"static",
"<",
"U",
">",
"CompletableFuture",
"<",
"U",
">",
"failedFuture",
"(",
"Throwable",
"ex",
")",
"{",
"return",
"new",
"CompletableFuture",
"<",
"U",
">",
"(",
"new",
"AltResult",
"(",
"Objects",
".",
"requireNonNull",
"(",
"ex",
")",
")",
")",
";",
"}"
] |
Returns a new CompletableFuture that is already completed exceptionally with the given
exception.
@param ex the exception
@param <U> the type of the value
@return the exceptionally completed CompletableFuture
@since 9
|
[
"Returns",
"a",
"new",
"CompletableFuture",
"that",
"is",
"already",
"completed",
"exceptionally",
"with",
"the",
"given",
"exception",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L562-L564
|
18,512
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.tryPushStack
|
final boolean tryPushStack(Completion c) {
Completion h = stack;
lazySetNext(c, h);
return U.compareAndSwapObject(this, STACK, h, c);
}
|
java
|
final boolean tryPushStack(Completion c) {
Completion h = stack;
lazySetNext(c, h);
return U.compareAndSwapObject(this, STACK, h, c);
}
|
[
"final",
"boolean",
"tryPushStack",
"(",
"Completion",
"c",
")",
"{",
"Completion",
"h",
"=",
"stack",
";",
"lazySetNext",
"(",
"c",
",",
"h",
")",
";",
"return",
"U",
".",
"compareAndSwapObject",
"(",
"this",
",",
"STACK",
",",
"h",
",",
"c",
")",
";",
"}"
] |
Returns true if successfully pushed c onto stack.
|
[
"Returns",
"true",
"if",
"successfully",
"pushed",
"c",
"onto",
"stack",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L588-L592
|
18,513
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.completeValue
|
final boolean completeValue(T t) {
return U.compareAndSwapObject(this, RESULT, null, (t == null) ? NIL : t);
}
|
java
|
final boolean completeValue(T t) {
return U.compareAndSwapObject(this, RESULT, null, (t == null) ? NIL : t);
}
|
[
"final",
"boolean",
"completeValue",
"(",
"T",
"t",
")",
"{",
"return",
"U",
".",
"compareAndSwapObject",
"(",
"this",
",",
"RESULT",
",",
"null",
",",
"(",
"t",
"==",
"null",
")",
"?",
"NIL",
":",
"t",
")",
";",
"}"
] |
Completes with a non-exceptional result, unless already completed.
|
[
"Completes",
"with",
"a",
"non",
"-",
"exceptional",
"result",
"unless",
"already",
"completed",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L611-L613
|
18,514
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.cleanStack
|
final void cleanStack() {
boolean unlinked = false;
Completion p;
while ((p = stack) != null && !p.isLive()) // ensure head of stack live
unlinked = casStack(p, p.next);
if (p != null && !unlinked) { // try to unlink first nonlive
for (Completion q = p.next; q != null;) {
Completion s = q.next;
if (q.isLive()) {
p = q;
q = s;
} else {
casNext(p, q, s);
break;
}
}
}
}
|
java
|
final void cleanStack() {
boolean unlinked = false;
Completion p;
while ((p = stack) != null && !p.isLive()) // ensure head of stack live
unlinked = casStack(p, p.next);
if (p != null && !unlinked) { // try to unlink first nonlive
for (Completion q = p.next; q != null;) {
Completion s = q.next;
if (q.isLive()) {
p = q;
q = s;
} else {
casNext(p, q, s);
break;
}
}
}
}
|
[
"final",
"void",
"cleanStack",
"(",
")",
"{",
"boolean",
"unlinked",
"=",
"false",
";",
"Completion",
"p",
";",
"while",
"(",
"(",
"p",
"=",
"stack",
")",
"!=",
"null",
"&&",
"!",
"p",
".",
"isLive",
"(",
")",
")",
"// ensure head of stack live",
"unlinked",
"=",
"casStack",
"(",
"p",
",",
"p",
".",
"next",
")",
";",
"if",
"(",
"p",
"!=",
"null",
"&&",
"!",
"unlinked",
")",
"{",
"// try to unlink first nonlive",
"for",
"(",
"Completion",
"q",
"=",
"p",
".",
"next",
";",
"q",
"!=",
"null",
";",
")",
"{",
"Completion",
"s",
"=",
"q",
".",
"next",
";",
"if",
"(",
"q",
".",
"isLive",
"(",
")",
")",
"{",
"p",
"=",
"q",
";",
"q",
"=",
"s",
";",
"}",
"else",
"{",
"casNext",
"(",
"p",
",",
"q",
",",
"s",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
Traverses stack and unlinks one or more dead Completions, if found.
|
[
"Traverses",
"stack",
"and",
"unlinks",
"one",
"or",
"more",
"dead",
"Completions",
"if",
"found",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L673-L690
|
18,515
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.unipush
|
final void unipush(Completion c) {
if (c != null) {
while (!tryPushStack(c)) {
if (result != null) {
lazySetNext(c, null);
break;
}
}
if (result != null)
c.tryFire(SYNC);
}
}
|
java
|
final void unipush(Completion c) {
if (c != null) {
while (!tryPushStack(c)) {
if (result != null) {
lazySetNext(c, null);
break;
}
}
if (result != null)
c.tryFire(SYNC);
}
}
|
[
"final",
"void",
"unipush",
"(",
"Completion",
"c",
")",
"{",
"if",
"(",
"c",
"!=",
"null",
")",
"{",
"while",
"(",
"!",
"tryPushStack",
"(",
"c",
")",
")",
"{",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"lazySetNext",
"(",
"c",
",",
"null",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"result",
"!=",
"null",
")",
"c",
".",
"tryFire",
"(",
"SYNC",
")",
";",
"}",
"}"
] |
Pushes the given completion unless it completes while trying. Caller should first check that
result is null.
|
[
"Pushes",
"the",
"given",
"completion",
"unless",
"it",
"completes",
"while",
"trying",
".",
"Caller",
"should",
"first",
"check",
"that",
"result",
"is",
"null",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L696-L707
|
18,516
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.bipush
|
final void bipush(CompletableFuture<?> b, BiCompletion<?, ?, ?> c) {
if (c != null) {
while (result == null) {
if (tryPushStack(c)) {
if (b.result == null)
b.unipush(new CoCompletion(c));
else if (result != null)
c.tryFire(SYNC);
return;
}
}
b.unipush(c);
}
}
|
java
|
final void bipush(CompletableFuture<?> b, BiCompletion<?, ?, ?> c) {
if (c != null) {
while (result == null) {
if (tryPushStack(c)) {
if (b.result == null)
b.unipush(new CoCompletion(c));
else if (result != null)
c.tryFire(SYNC);
return;
}
}
b.unipush(c);
}
}
|
[
"final",
"void",
"bipush",
"(",
"CompletableFuture",
"<",
"?",
">",
"b",
",",
"BiCompletion",
"<",
"?",
",",
"?",
",",
"?",
">",
"c",
")",
"{",
"if",
"(",
"c",
"!=",
"null",
")",
"{",
"while",
"(",
"result",
"==",
"null",
")",
"{",
"if",
"(",
"tryPushStack",
"(",
"c",
")",
")",
"{",
"if",
"(",
"b",
".",
"result",
"==",
"null",
")",
"b",
".",
"unipush",
"(",
"new",
"CoCompletion",
"(",
"c",
")",
")",
";",
"else",
"if",
"(",
"result",
"!=",
"null",
")",
"c",
".",
"tryFire",
"(",
"SYNC",
")",
";",
"return",
";",
"}",
"}",
"b",
".",
"unipush",
"(",
"c",
")",
";",
"}",
"}"
] |
Pushes completion to this and b unless both done. Caller should first check that either result
or b.result is null.
|
[
"Pushes",
"completion",
"to",
"this",
"and",
"b",
"unless",
"both",
"done",
".",
"Caller",
"should",
"first",
"check",
"that",
"either",
"result",
"or",
"b",
".",
"result",
"is",
"null",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L1006-L1019
|
18,517
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.postFire
|
final CompletableFuture<T> postFire(CompletableFuture<?> a, CompletableFuture<?> b, int mode) {
if (b != null && b.stack != null) { // clean second source
Object r;
if ((r = b.result) == null)
b.cleanStack();
if (mode >= 0 && (r != null || b.result != null))
b.postComplete();
}
return postFire(a, mode);
}
|
java
|
final CompletableFuture<T> postFire(CompletableFuture<?> a, CompletableFuture<?> b, int mode) {
if (b != null && b.stack != null) { // clean second source
Object r;
if ((r = b.result) == null)
b.cleanStack();
if (mode >= 0 && (r != null || b.result != null))
b.postComplete();
}
return postFire(a, mode);
}
|
[
"final",
"CompletableFuture",
"<",
"T",
">",
"postFire",
"(",
"CompletableFuture",
"<",
"?",
">",
"a",
",",
"CompletableFuture",
"<",
"?",
">",
"b",
",",
"int",
"mode",
")",
"{",
"if",
"(",
"b",
"!=",
"null",
"&&",
"b",
".",
"stack",
"!=",
"null",
")",
"{",
"// clean second source",
"Object",
"r",
";",
"if",
"(",
"(",
"r",
"=",
"b",
".",
"result",
")",
"==",
"null",
")",
"b",
".",
"cleanStack",
"(",
")",
";",
"if",
"(",
"mode",
">=",
"0",
"&&",
"(",
"r",
"!=",
"null",
"||",
"b",
".",
"result",
"!=",
"null",
")",
")",
"b",
".",
"postComplete",
"(",
")",
";",
"}",
"return",
"postFire",
"(",
"a",
",",
"mode",
")",
";",
"}"
] |
Post-processing after successful BiCompletion tryFire.
|
[
"Post",
"-",
"processing",
"after",
"successful",
"BiCompletion",
"tryFire",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L1022-L1031
|
18,518
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.orpush
|
final void orpush(CompletableFuture<?> b, BiCompletion<?, ?, ?> c) {
if (c != null) {
while (!tryPushStack(c)) {
if (result != null) {
lazySetNext(c, null);
break;
}
}
if (result != null)
c.tryFire(SYNC);
else
b.unipush(new CoCompletion(c));
}
}
|
java
|
final void orpush(CompletableFuture<?> b, BiCompletion<?, ?, ?> c) {
if (c != null) {
while (!tryPushStack(c)) {
if (result != null) {
lazySetNext(c, null);
break;
}
}
if (result != null)
c.tryFire(SYNC);
else
b.unipush(new CoCompletion(c));
}
}
|
[
"final",
"void",
"orpush",
"(",
"CompletableFuture",
"<",
"?",
">",
"b",
",",
"BiCompletion",
"<",
"?",
",",
"?",
",",
"?",
">",
"c",
")",
"{",
"if",
"(",
"c",
"!=",
"null",
")",
"{",
"while",
"(",
"!",
"tryPushStack",
"(",
"c",
")",
")",
"{",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"lazySetNext",
"(",
"c",
",",
"null",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"result",
"!=",
"null",
")",
"c",
".",
"tryFire",
"(",
"SYNC",
")",
";",
"else",
"b",
".",
"unipush",
"(",
"new",
"CoCompletion",
"(",
"c",
")",
")",
";",
"}",
"}"
] |
Pushes completion to this and b unless either done. Caller should first check that result and
b.result are both null.
|
[
"Pushes",
"completion",
"to",
"this",
"and",
"b",
"unless",
"either",
"done",
".",
"Caller",
"should",
"first",
"check",
"that",
"result",
"and",
"b",
".",
"result",
"are",
"both",
"null",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L1185-L1198
|
18,519
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.get
|
public T get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
long nanos = unit.toNanos(timeout);
Object r;
if ((r = result) == null)
r = timedGet(nanos);
return (T) reportGet(r);
}
|
java
|
public T get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
long nanos = unit.toNanos(timeout);
Object r;
if ((r = result) == null)
r = timedGet(nanos);
return (T) reportGet(r);
}
|
[
"public",
"T",
"get",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
",",
"ExecutionException",
",",
"TimeoutException",
"{",
"long",
"nanos",
"=",
"unit",
".",
"toNanos",
"(",
"timeout",
")",
";",
"Object",
"r",
";",
"if",
"(",
"(",
"r",
"=",
"result",
")",
"==",
"null",
")",
"r",
"=",
"timedGet",
"(",
"nanos",
")",
";",
"return",
"(",
"T",
")",
"reportGet",
"(",
"r",
")",
";",
"}"
] |
Waits if necessary for at most the given time for this future to complete, and then returns its
result, if available.
@param timeout the maximum time to wait
@param unit the time unit of the timeout argument
@return the result value
@throws CancellationException if this future was cancelled
@throws ExecutionException if this future completed exceptionally
@throws InterruptedException if the current thread was interrupted while waiting
@throws TimeoutException if the wait timed out
|
[
"Waits",
"if",
"necessary",
"for",
"at",
"most",
"the",
"given",
"time",
"for",
"this",
"future",
"to",
"complete",
"and",
"then",
"returns",
"its",
"result",
"if",
"available",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L1367-L1374
|
18,520
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.getNumberOfDependents
|
public int getNumberOfDependents() {
int count = 0;
for (Completion p = stack; p != null; p = p.next)
++count;
return count;
}
|
java
|
public int getNumberOfDependents() {
int count = 0;
for (Completion p = stack; p != null; p = p.next)
++count;
return count;
}
|
[
"public",
"int",
"getNumberOfDependents",
"(",
")",
"{",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"Completion",
"p",
"=",
"stack",
";",
"p",
"!=",
"null",
";",
"p",
"=",
"p",
".",
"next",
")",
"",
"++",
"count",
";",
"return",
"count",
";",
"}"
] |
Returns the estimated number of CompletableFutures whose completions are awaiting completion of
this CompletableFuture. This method is designed for use in monitoring system state, not for
synchronization control.
@return the number of dependent CompletableFutures
|
[
"Returns",
"the",
"estimated",
"number",
"of",
"CompletableFutures",
"whose",
"completions",
"are",
"awaiting",
"completion",
"of",
"this",
"CompletableFuture",
".",
"This",
"method",
"is",
"designed",
"for",
"use",
"in",
"monitoring",
"system",
"state",
"not",
"for",
"synchronization",
"control",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L1707-L1712
|
18,521
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.completeAsync
|
public CompletableFuture<T> completeAsync(Supplier<? extends T> supplier, Executor executor) {
if (supplier == null || executor == null)
throw new NullPointerException();
executor.execute(new AsyncSupply<T>(this, supplier));
return this;
}
|
java
|
public CompletableFuture<T> completeAsync(Supplier<? extends T> supplier, Executor executor) {
if (supplier == null || executor == null)
throw new NullPointerException();
executor.execute(new AsyncSupply<T>(this, supplier));
return this;
}
|
[
"public",
"CompletableFuture",
"<",
"T",
">",
"completeAsync",
"(",
"Supplier",
"<",
"?",
"extends",
"T",
">",
"supplier",
",",
"Executor",
"executor",
")",
"{",
"if",
"(",
"supplier",
"==",
"null",
"||",
"executor",
"==",
"null",
")",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"executor",
".",
"execute",
"(",
"new",
"AsyncSupply",
"<",
"T",
">",
"(",
"this",
",",
"supplier",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Completes this CompletableFuture with the result of the given Supplier function invoked from an
asynchronous task using the given executor.
@param supplier a function returning the value to be used to complete this CompletableFuture
@param executor the executor to use for asynchronous execution
@return this CompletableFuture
@since 9
|
[
"Completes",
"this",
"CompletableFuture",
"with",
"the",
"result",
"of",
"the",
"given",
"Supplier",
"function",
"invoked",
"from",
"an",
"asynchronous",
"task",
"using",
"the",
"given",
"executor",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L1808-L1813
|
18,522
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java
|
CompletableFuture.completeOnTimeout
|
public CompletableFuture<T> completeOnTimeout(T value, long timeout, TimeUnit unit) {
Objects.requireNonNull(unit);
if (result == null)
whenComplete(
new Canceller(Delayer.delay(new DelayedCompleter<T>(this, value), timeout, unit)));
return this;
}
|
java
|
public CompletableFuture<T> completeOnTimeout(T value, long timeout, TimeUnit unit) {
Objects.requireNonNull(unit);
if (result == null)
whenComplete(
new Canceller(Delayer.delay(new DelayedCompleter<T>(this, value), timeout, unit)));
return this;
}
|
[
"public",
"CompletableFuture",
"<",
"T",
">",
"completeOnTimeout",
"(",
"T",
"value",
",",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"unit",
")",
";",
"if",
"(",
"result",
"==",
"null",
")",
"whenComplete",
"(",
"new",
"Canceller",
"(",
"Delayer",
".",
"delay",
"(",
"new",
"DelayedCompleter",
"<",
"T",
">",
"(",
"this",
",",
"value",
")",
",",
"timeout",
",",
"unit",
")",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Completes this CompletableFuture with the given value if not otherwise completed before the
given timeout.
@param value the value to use upon timeout
@param timeout how long to wait before completing normally with the given value, in units of
{@code unit}
@param unit a {@code TimeUnit} determining how to interpret the {@code timeout} parameter
@return this CompletableFuture
@since 9
|
[
"Completes",
"this",
"CompletableFuture",
"with",
"the",
"given",
"value",
"if",
"not",
"otherwise",
"completed",
"before",
"the",
"given",
"timeout",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CompletableFuture.java#L1860-L1866
|
18,523
|
Alluxio/alluxio
|
core/server/proxy/src/main/java/alluxio/proxy/AlluxioProxy.java
|
AlluxioProxy.main
|
public static void main(String[] args) {
if (args.length != 0) {
LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR,
AlluxioProxy.class.getCanonicalName());
System.exit(-1);
}
if (!ConfigurationUtils.masterHostConfigured(ServerConfiguration.global())) {
ProcessUtils.fatalError(LOG,
ConfigurationUtils.getMasterHostNotConfiguredMessage("Alluxio proxy"));
}
CommonUtils.PROCESS_TYPE.set(CommonUtils.ProcessType.PROXY);
ProxyProcess process = ProxyProcess.Factory.create();
ProcessUtils.run(process);
}
|
java
|
public static void main(String[] args) {
if (args.length != 0) {
LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR,
AlluxioProxy.class.getCanonicalName());
System.exit(-1);
}
if (!ConfigurationUtils.masterHostConfigured(ServerConfiguration.global())) {
ProcessUtils.fatalError(LOG,
ConfigurationUtils.getMasterHostNotConfiguredMessage("Alluxio proxy"));
}
CommonUtils.PROCESS_TYPE.set(CommonUtils.ProcessType.PROXY);
ProxyProcess process = ProxyProcess.Factory.create();
ProcessUtils.run(process);
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"if",
"(",
"args",
".",
"length",
"!=",
"0",
")",
"{",
"LOG",
".",
"info",
"(",
"\"java -cp {} {}\"",
",",
"RuntimeConstants",
".",
"ALLUXIO_JAR",
",",
"AlluxioProxy",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
";",
"System",
".",
"exit",
"(",
"-",
"1",
")",
";",
"}",
"if",
"(",
"!",
"ConfigurationUtils",
".",
"masterHostConfigured",
"(",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
")",
"{",
"ProcessUtils",
".",
"fatalError",
"(",
"LOG",
",",
"ConfigurationUtils",
".",
"getMasterHostNotConfiguredMessage",
"(",
"\"Alluxio proxy\"",
")",
")",
";",
"}",
"CommonUtils",
".",
"PROCESS_TYPE",
".",
"set",
"(",
"CommonUtils",
".",
"ProcessType",
".",
"PROXY",
")",
";",
"ProxyProcess",
"process",
"=",
"ProxyProcess",
".",
"Factory",
".",
"create",
"(",
")",
";",
"ProcessUtils",
".",
"run",
"(",
"process",
")",
";",
"}"
] |
Starts the Alluxio proxy.
@param args command line arguments, should be empty
|
[
"Starts",
"the",
"Alluxio",
"proxy",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/proxy/src/main/java/alluxio/proxy/AlluxioProxy.java#L37-L52
|
18,524
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/security/authorization/AclEntry.java
|
AclEntry.toDefault
|
public static String toDefault(String stringEntry) {
if (stringEntry == null) {
throw new IllegalArgumentException("Input acl string is null");
}
List<String> components = Arrays.stream(stringEntry.split(":")).map(String::trim).collect(
Collectors.toList());
if (components != null && components.size() > 0 && components.get(0).equals(DEFAULT_KEYWORD)) {
return stringEntry;
} else {
return DEFAULT_PREFIX + stringEntry;
}
}
|
java
|
public static String toDefault(String stringEntry) {
if (stringEntry == null) {
throw new IllegalArgumentException("Input acl string is null");
}
List<String> components = Arrays.stream(stringEntry.split(":")).map(String::trim).collect(
Collectors.toList());
if (components != null && components.size() > 0 && components.get(0).equals(DEFAULT_KEYWORD)) {
return stringEntry;
} else {
return DEFAULT_PREFIX + stringEntry;
}
}
|
[
"public",
"static",
"String",
"toDefault",
"(",
"String",
"stringEntry",
")",
"{",
"if",
"(",
"stringEntry",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Input acl string is null\"",
")",
";",
"}",
"List",
"<",
"String",
">",
"components",
"=",
"Arrays",
".",
"stream",
"(",
"stringEntry",
".",
"split",
"(",
"\":\"",
")",
")",
".",
"map",
"(",
"String",
"::",
"trim",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"if",
"(",
"components",
"!=",
"null",
"&&",
"components",
".",
"size",
"(",
")",
">",
"0",
"&&",
"components",
".",
"get",
"(",
"0",
")",
".",
"equals",
"(",
"DEFAULT_KEYWORD",
")",
")",
"{",
"return",
"stringEntry",
";",
"}",
"else",
"{",
"return",
"DEFAULT_PREFIX",
"+",
"stringEntry",
";",
"}",
"}"
] |
Convert a normal ACL to a string representing a default ACL.
@param stringEntry normal ACL, if it is already default ACL, then return the default ACL
@return a default ACL
|
[
"Convert",
"a",
"normal",
"ACL",
"to",
"a",
"string",
"representing",
"a",
"default",
"ACL",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/security/authorization/AclEntry.java#L148-L159
|
18,525
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/policy/RoundRobinPolicy.java
|
RoundRobinPolicy.getWorker
|
@Override
@Nullable
public WorkerNetAddress getWorker(GetWorkerOptions options) {
Set<WorkerNetAddress> eligibleAddresses = new HashSet<>();
for (BlockWorkerInfo info : options.getBlockWorkerInfos()) {
eligibleAddresses.add(info.getNetAddress());
}
WorkerNetAddress address = mBlockLocationCache.get(options.getBlockInfo().getBlockId());
if (address != null && eligibleAddresses.contains(address)) {
return address;
} else {
address = null;
}
if (!mInitialized) {
mWorkerInfoList = Lists.newArrayList(options.getBlockWorkerInfos());
Collections.shuffle(mWorkerInfoList);
mIndex = 0;
mInitialized = true;
}
// at most try all the workers
for (int i = 0; i < mWorkerInfoList.size(); i++) {
WorkerNetAddress candidate = mWorkerInfoList.get(mIndex).getNetAddress();
BlockWorkerInfo workerInfo = findBlockWorkerInfo(options.getBlockWorkerInfos(), candidate);
mIndex = (mIndex + 1) % mWorkerInfoList.size();
if (workerInfo != null
&& workerInfo.getCapacityBytes() >= options.getBlockInfo().getLength()
&& eligibleAddresses.contains(candidate)) {
address = candidate;
break;
}
}
mBlockLocationCache.put(options.getBlockInfo().getBlockId(), address);
return address;
}
|
java
|
@Override
@Nullable
public WorkerNetAddress getWorker(GetWorkerOptions options) {
Set<WorkerNetAddress> eligibleAddresses = new HashSet<>();
for (BlockWorkerInfo info : options.getBlockWorkerInfos()) {
eligibleAddresses.add(info.getNetAddress());
}
WorkerNetAddress address = mBlockLocationCache.get(options.getBlockInfo().getBlockId());
if (address != null && eligibleAddresses.contains(address)) {
return address;
} else {
address = null;
}
if (!mInitialized) {
mWorkerInfoList = Lists.newArrayList(options.getBlockWorkerInfos());
Collections.shuffle(mWorkerInfoList);
mIndex = 0;
mInitialized = true;
}
// at most try all the workers
for (int i = 0; i < mWorkerInfoList.size(); i++) {
WorkerNetAddress candidate = mWorkerInfoList.get(mIndex).getNetAddress();
BlockWorkerInfo workerInfo = findBlockWorkerInfo(options.getBlockWorkerInfos(), candidate);
mIndex = (mIndex + 1) % mWorkerInfoList.size();
if (workerInfo != null
&& workerInfo.getCapacityBytes() >= options.getBlockInfo().getLength()
&& eligibleAddresses.contains(candidate)) {
address = candidate;
break;
}
}
mBlockLocationCache.put(options.getBlockInfo().getBlockId(), address);
return address;
}
|
[
"@",
"Override",
"@",
"Nullable",
"public",
"WorkerNetAddress",
"getWorker",
"(",
"GetWorkerOptions",
"options",
")",
"{",
"Set",
"<",
"WorkerNetAddress",
">",
"eligibleAddresses",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"BlockWorkerInfo",
"info",
":",
"options",
".",
"getBlockWorkerInfos",
"(",
")",
")",
"{",
"eligibleAddresses",
".",
"add",
"(",
"info",
".",
"getNetAddress",
"(",
")",
")",
";",
"}",
"WorkerNetAddress",
"address",
"=",
"mBlockLocationCache",
".",
"get",
"(",
"options",
".",
"getBlockInfo",
"(",
")",
".",
"getBlockId",
"(",
")",
")",
";",
"if",
"(",
"address",
"!=",
"null",
"&&",
"eligibleAddresses",
".",
"contains",
"(",
"address",
")",
")",
"{",
"return",
"address",
";",
"}",
"else",
"{",
"address",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"mInitialized",
")",
"{",
"mWorkerInfoList",
"=",
"Lists",
".",
"newArrayList",
"(",
"options",
".",
"getBlockWorkerInfos",
"(",
")",
")",
";",
"Collections",
".",
"shuffle",
"(",
"mWorkerInfoList",
")",
";",
"mIndex",
"=",
"0",
";",
"mInitialized",
"=",
"true",
";",
"}",
"// at most try all the workers",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mWorkerInfoList",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"WorkerNetAddress",
"candidate",
"=",
"mWorkerInfoList",
".",
"get",
"(",
"mIndex",
")",
".",
"getNetAddress",
"(",
")",
";",
"BlockWorkerInfo",
"workerInfo",
"=",
"findBlockWorkerInfo",
"(",
"options",
".",
"getBlockWorkerInfos",
"(",
")",
",",
"candidate",
")",
";",
"mIndex",
"=",
"(",
"mIndex",
"+",
"1",
")",
"%",
"mWorkerInfoList",
".",
"size",
"(",
")",
";",
"if",
"(",
"workerInfo",
"!=",
"null",
"&&",
"workerInfo",
".",
"getCapacityBytes",
"(",
")",
">=",
"options",
".",
"getBlockInfo",
"(",
")",
".",
"getLength",
"(",
")",
"&&",
"eligibleAddresses",
".",
"contains",
"(",
"candidate",
")",
")",
"{",
"address",
"=",
"candidate",
";",
"break",
";",
"}",
"}",
"mBlockLocationCache",
".",
"put",
"(",
"options",
".",
"getBlockInfo",
"(",
")",
".",
"getBlockId",
"(",
")",
",",
"address",
")",
";",
"return",
"address",
";",
"}"
] |
The policy uses the first fetch of worker info list as the base, and visits each of them in a
round-robin manner in the subsequent calls. The policy doesn't assume the list of worker info
in the subsequent calls has the same order from the first, and it will skip the workers that
are no longer active.
@param options options
@return the address of the worker to write to
|
[
"The",
"policy",
"uses",
"the",
"first",
"fetch",
"of",
"worker",
"info",
"list",
"as",
"the",
"base",
"and",
"visits",
"each",
"of",
"them",
"in",
"a",
"round",
"-",
"robin",
"manner",
"in",
"the",
"subsequent",
"calls",
".",
"The",
"policy",
"doesn",
"t",
"assume",
"the",
"list",
"of",
"worker",
"info",
"in",
"the",
"subsequent",
"calls",
"has",
"the",
"same",
"order",
"from",
"the",
"first",
"and",
"it",
"will",
"skip",
"the",
"workers",
"that",
"are",
"no",
"longer",
"active",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/policy/RoundRobinPolicy.java#L60-L96
|
18,526
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/Inode.java
|
Inode.wrap
|
public static Inode wrap(InodeView delegate) {
if (delegate instanceof Inode) {
return (Inode) delegate;
}
if (delegate.isFile()) {
Preconditions.checkState(delegate instanceof InodeFileView);
return new InodeFile((InodeFileView) delegate);
} else {
Preconditions.checkState(delegate instanceof InodeDirectoryView);
return new InodeDirectory((InodeDirectoryView) delegate);
}
}
|
java
|
public static Inode wrap(InodeView delegate) {
if (delegate instanceof Inode) {
return (Inode) delegate;
}
if (delegate.isFile()) {
Preconditions.checkState(delegate instanceof InodeFileView);
return new InodeFile((InodeFileView) delegate);
} else {
Preconditions.checkState(delegate instanceof InodeDirectoryView);
return new InodeDirectory((InodeDirectoryView) delegate);
}
}
|
[
"public",
"static",
"Inode",
"wrap",
"(",
"InodeView",
"delegate",
")",
"{",
"if",
"(",
"delegate",
"instanceof",
"Inode",
")",
"{",
"return",
"(",
"Inode",
")",
"delegate",
";",
"}",
"if",
"(",
"delegate",
".",
"isFile",
"(",
")",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"delegate",
"instanceof",
"InodeFileView",
")",
";",
"return",
"new",
"InodeFile",
"(",
"(",
"InodeFileView",
")",
"delegate",
")",
";",
"}",
"else",
"{",
"Preconditions",
".",
"checkState",
"(",
"delegate",
"instanceof",
"InodeDirectoryView",
")",
";",
"return",
"new",
"InodeDirectory",
"(",
"(",
"InodeDirectoryView",
")",
"delegate",
")",
";",
"}",
"}"
] |
Wraps an InodeView, providing read-only access. Modifications to the underlying inode will
affect the created read-only inode.
@param delegate the delegate to wrap
@return the created read-only inode
|
[
"Wraps",
"an",
"InodeView",
"providing",
"read",
"-",
"only",
"access",
".",
"Modifications",
"to",
"the",
"underlying",
"inode",
"will",
"affect",
"the",
"created",
"read",
"-",
"only",
"inode",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/Inode.java#L211-L222
|
18,527
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/AbstractReadHandler.java
|
AbstractReadHandler.validateReadRequest
|
private void validateReadRequest(alluxio.grpc.ReadRequest request)
throws InvalidArgumentException {
if (request.getBlockId() < 0) {
throw new InvalidArgumentException(
String.format("Invalid blockId (%d) in read request.", request.getBlockId()));
}
if (request.getOffset() < 0 || request.getLength() <= 0) {
throw new InvalidArgumentException(
String.format("Invalid read bounds in read request %s.", request.toString()));
}
}
|
java
|
private void validateReadRequest(alluxio.grpc.ReadRequest request)
throws InvalidArgumentException {
if (request.getBlockId() < 0) {
throw new InvalidArgumentException(
String.format("Invalid blockId (%d) in read request.", request.getBlockId()));
}
if (request.getOffset() < 0 || request.getLength() <= 0) {
throw new InvalidArgumentException(
String.format("Invalid read bounds in read request %s.", request.toString()));
}
}
|
[
"private",
"void",
"validateReadRequest",
"(",
"alluxio",
".",
"grpc",
".",
"ReadRequest",
"request",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"request",
".",
"getBlockId",
"(",
")",
"<",
"0",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Invalid blockId (%d) in read request.\"",
",",
"request",
".",
"getBlockId",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"request",
".",
"getOffset",
"(",
")",
"<",
"0",
"||",
"request",
".",
"getLength",
"(",
")",
"<=",
"0",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Invalid read bounds in read request %s.\"",
",",
"request",
".",
"toString",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Validates a read request.
@param request the block read request
@throws InvalidArgumentException if the request is invalid
|
[
"Validates",
"a",
"read",
"request",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/AbstractReadHandler.java#L163-L173
|
18,528
|
Alluxio/alluxio
|
integration/yarn/src/main/java/alluxio/yarn/ContainerAllocator.java
|
ContainerAllocator.allocateContainers
|
public List<Container> allocateContainers() throws Exception {
for (int attempt = 0; attempt < MAX_WORKER_CONTAINER_REQUEST_ATTEMPTS; attempt++) {
LOG.debug("Attempt {} of {} to allocate containers",
attempt, MAX_WORKER_CONTAINER_REQUEST_ATTEMPTS);
int numContainersToRequest = mTargetNumContainers - mAllocatedContainerHosts.size();
LOG.debug("Requesting {} containers", numContainersToRequest);
mOutstandingContainerRequestsLatch = new CountDownLatch(numContainersToRequest);
requestContainers();
// Wait for all outstanding requests to be responded to before beginning the next round.
mOutstandingContainerRequestsLatch.await();
if (mAllocatedContainerHosts.size() == mTargetNumContainers) {
break;
}
}
if (mAllocatedContainers.size() != mTargetNumContainers) {
throw new RuntimeException(String.format("Failed to allocate %d %s containers",
mTargetNumContainers, mContainerName));
}
return mAllocatedContainers;
}
|
java
|
public List<Container> allocateContainers() throws Exception {
for (int attempt = 0; attempt < MAX_WORKER_CONTAINER_REQUEST_ATTEMPTS; attempt++) {
LOG.debug("Attempt {} of {} to allocate containers",
attempt, MAX_WORKER_CONTAINER_REQUEST_ATTEMPTS);
int numContainersToRequest = mTargetNumContainers - mAllocatedContainerHosts.size();
LOG.debug("Requesting {} containers", numContainersToRequest);
mOutstandingContainerRequestsLatch = new CountDownLatch(numContainersToRequest);
requestContainers();
// Wait for all outstanding requests to be responded to before beginning the next round.
mOutstandingContainerRequestsLatch.await();
if (mAllocatedContainerHosts.size() == mTargetNumContainers) {
break;
}
}
if (mAllocatedContainers.size() != mTargetNumContainers) {
throw new RuntimeException(String.format("Failed to allocate %d %s containers",
mTargetNumContainers, mContainerName));
}
return mAllocatedContainers;
}
|
[
"public",
"List",
"<",
"Container",
">",
"allocateContainers",
"(",
")",
"throws",
"Exception",
"{",
"for",
"(",
"int",
"attempt",
"=",
"0",
";",
"attempt",
"<",
"MAX_WORKER_CONTAINER_REQUEST_ATTEMPTS",
";",
"attempt",
"++",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Attempt {} of {} to allocate containers\"",
",",
"attempt",
",",
"MAX_WORKER_CONTAINER_REQUEST_ATTEMPTS",
")",
";",
"int",
"numContainersToRequest",
"=",
"mTargetNumContainers",
"-",
"mAllocatedContainerHosts",
".",
"size",
"(",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Requesting {} containers\"",
",",
"numContainersToRequest",
")",
";",
"mOutstandingContainerRequestsLatch",
"=",
"new",
"CountDownLatch",
"(",
"numContainersToRequest",
")",
";",
"requestContainers",
"(",
")",
";",
"// Wait for all outstanding requests to be responded to before beginning the next round.",
"mOutstandingContainerRequestsLatch",
".",
"await",
"(",
")",
";",
"if",
"(",
"mAllocatedContainerHosts",
".",
"size",
"(",
")",
"==",
"mTargetNumContainers",
")",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"mAllocatedContainers",
".",
"size",
"(",
")",
"!=",
"mTargetNumContainers",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"String",
".",
"format",
"(",
"\"Failed to allocate %d %s containers\"",
",",
"mTargetNumContainers",
",",
"mContainerName",
")",
")",
";",
"}",
"return",
"mAllocatedContainers",
";",
"}"
] |
Allocates the containers specified by the constructor.
@return the allocated containers
|
[
"Allocates",
"the",
"containers",
"specified",
"by",
"the",
"constructor",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/yarn/src/main/java/alluxio/yarn/ContainerAllocator.java#L109-L128
|
18,529
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/SleepUtils.java
|
SleepUtils.sleepMs
|
public static void sleepMs(Logger logger, long timeMs) {
try {
Thread.sleep(timeMs);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
if (logger != null) {
logger.warn(e.getMessage(), e);
}
}
}
|
java
|
public static void sleepMs(Logger logger, long timeMs) {
try {
Thread.sleep(timeMs);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
if (logger != null) {
logger.warn(e.getMessage(), e);
}
}
}
|
[
"public",
"static",
"void",
"sleepMs",
"(",
"Logger",
"logger",
",",
"long",
"timeMs",
")",
"{",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"timeMs",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"if",
"(",
"logger",
"!=",
"null",
")",
"{",
"logger",
".",
"warn",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Sleeps for the given number of milliseconds, reporting interruptions using the given logger.
Unlike Thread.sleep(), this method responds to interrupts by setting the thread interrupt
status. This means that callers must check the interrupt status if they need to handle
interrupts.
@param logger logger for reporting interruptions; no reporting is done if the logger is null
@param timeMs sleep duration in milliseconds
|
[
"Sleeps",
"for",
"the",
"given",
"number",
"of",
"milliseconds",
"reporting",
"interruptions",
"using",
"the",
"given",
"logger",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/SleepUtils.java#L45-L54
|
18,530
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/cli/ValidateEnv.java
|
ValidateEnv.validateRemote
|
private static boolean validateRemote(String node, String target, String name, CommandLine cmd)
throws InterruptedException {
System.out.format("Validating %s environment on %s...%n", target, node);
if (!Utils.isAddressReachable(node, 22)) {
System.err.format("Unable to reach ssh port 22 on node %s.%n", node);
return false;
}
// args is not null.
String argStr = String.join(" ", cmd.getArgs());
String homeDir = ServerConfiguration.get(PropertyKey.HOME);
String remoteCommand = String.format(
"%s/bin/alluxio validateEnv %s %s %s",
homeDir, target, name == null ? "" : name, argStr);
String localCommand = String.format(
"ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no -tt %s \"bash %s\"",
node, remoteCommand);
String[] command = {"bash", "-c", localCommand};
try {
ProcessBuilder builder = new ProcessBuilder(command);
builder.redirectErrorStream(true);
builder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
builder.redirectInput(ProcessBuilder.Redirect.INHERIT);
Process process = builder.start();
process.waitFor();
return process.exitValue() == 0;
} catch (IOException e) {
System.err.format("Unable to validate on node %s: %s.%n", node, e.getMessage());
return false;
}
}
|
java
|
private static boolean validateRemote(String node, String target, String name, CommandLine cmd)
throws InterruptedException {
System.out.format("Validating %s environment on %s...%n", target, node);
if (!Utils.isAddressReachable(node, 22)) {
System.err.format("Unable to reach ssh port 22 on node %s.%n", node);
return false;
}
// args is not null.
String argStr = String.join(" ", cmd.getArgs());
String homeDir = ServerConfiguration.get(PropertyKey.HOME);
String remoteCommand = String.format(
"%s/bin/alluxio validateEnv %s %s %s",
homeDir, target, name == null ? "" : name, argStr);
String localCommand = String.format(
"ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no -tt %s \"bash %s\"",
node, remoteCommand);
String[] command = {"bash", "-c", localCommand};
try {
ProcessBuilder builder = new ProcessBuilder(command);
builder.redirectErrorStream(true);
builder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
builder.redirectInput(ProcessBuilder.Redirect.INHERIT);
Process process = builder.start();
process.waitFor();
return process.exitValue() == 0;
} catch (IOException e) {
System.err.format("Unable to validate on node %s: %s.%n", node, e.getMessage());
return false;
}
}
|
[
"private",
"static",
"boolean",
"validateRemote",
"(",
"String",
"node",
",",
"String",
"target",
",",
"String",
"name",
",",
"CommandLine",
"cmd",
")",
"throws",
"InterruptedException",
"{",
"System",
".",
"out",
".",
"format",
"(",
"\"Validating %s environment on %s...%n\"",
",",
"target",
",",
"node",
")",
";",
"if",
"(",
"!",
"Utils",
".",
"isAddressReachable",
"(",
"node",
",",
"22",
")",
")",
"{",
"System",
".",
"err",
".",
"format",
"(",
"\"Unable to reach ssh port 22 on node %s.%n\"",
",",
"node",
")",
";",
"return",
"false",
";",
"}",
"// args is not null.",
"String",
"argStr",
"=",
"String",
".",
"join",
"(",
"\" \"",
",",
"cmd",
".",
"getArgs",
"(",
")",
")",
";",
"String",
"homeDir",
"=",
"ServerConfiguration",
".",
"get",
"(",
"PropertyKey",
".",
"HOME",
")",
";",
"String",
"remoteCommand",
"=",
"String",
".",
"format",
"(",
"\"%s/bin/alluxio validateEnv %s %s %s\"",
",",
"homeDir",
",",
"target",
",",
"name",
"==",
"null",
"?",
"\"\"",
":",
"name",
",",
"argStr",
")",
";",
"String",
"localCommand",
"=",
"String",
".",
"format",
"(",
"\"ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no -tt %s \\\"bash %s\\\"\"",
",",
"node",
",",
"remoteCommand",
")",
";",
"String",
"[",
"]",
"command",
"=",
"{",
"\"bash\"",
",",
"\"-c\"",
",",
"localCommand",
"}",
";",
"try",
"{",
"ProcessBuilder",
"builder",
"=",
"new",
"ProcessBuilder",
"(",
"command",
")",
";",
"builder",
".",
"redirectErrorStream",
"(",
"true",
")",
";",
"builder",
".",
"redirectOutput",
"(",
"ProcessBuilder",
".",
"Redirect",
".",
"INHERIT",
")",
";",
"builder",
".",
"redirectInput",
"(",
"ProcessBuilder",
".",
"Redirect",
".",
"INHERIT",
")",
";",
"Process",
"process",
"=",
"builder",
".",
"start",
"(",
")",
";",
"process",
".",
"waitFor",
"(",
")",
";",
"return",
"process",
".",
"exitValue",
"(",
")",
"==",
"0",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"System",
".",
"err",
".",
"format",
"(",
"\"Unable to validate on node %s: %s.%n\"",
",",
"node",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
validates environment on remote node
|
[
"validates",
"environment",
"on",
"remote",
"node"
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/cli/ValidateEnv.java#L206-L236
|
18,531
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/cli/ValidateEnv.java
|
ValidateEnv.validateLocal
|
private static boolean validateLocal(String target, String name, CommandLine cmd)
throws InterruptedException {
int validationCount = 0;
Map<ValidationTask.TaskResult, Integer> results = new HashMap<>();
Map<String, String> optionsMap = new HashMap<>();
for (Option opt : cmd.getOptions()) {
optionsMap.put(opt.getOpt(), opt.getValue());
}
Collection<ValidationTask> tasks = TARGET_TASKS.get(target);
System.out.format("Validating %s environment...%n", target);
for (ValidationTask task: tasks) {
String taskName = TASKS.get(task);
if (name != null && !taskName.startsWith(name)) {
continue;
}
System.out.format("Validating %s...%n", taskName);
ValidationTask.TaskResult result = task.validate(optionsMap);
results.put(result, results.getOrDefault(result, 0) + 1);
switch (result) {
case OK:
System.out.print(Constants.ANSI_GREEN);
break;
case WARNING:
System.out.print(Constants.ANSI_YELLOW);
break;
case FAILED:
System.out.print(Constants.ANSI_RED);
break;
case SKIPPED:
System.out.print(Constants.ANSI_PURPLE);
break;
default:
break;
}
System.out.print(result.name());
System.out.println(Constants.ANSI_RESET);
validationCount++;
}
if (results.containsKey(ValidationTask.TaskResult.FAILED)) {
System.err.format("%d failures ", results.get(ValidationTask.TaskResult.FAILED));
}
if (results.containsKey(ValidationTask.TaskResult.WARNING)) {
System.err.format("%d warnings ", results.get(ValidationTask.TaskResult.WARNING));
}
if (results.containsKey(ValidationTask.TaskResult.SKIPPED)) {
System.err.format("%d skipped ", results.get(ValidationTask.TaskResult.SKIPPED));
}
System.err.println();
if (validationCount == 0) {
System.err.format("No validation task matched name \"%s\".%n", name);
return false;
}
if (results.containsKey(ValidationTask.TaskResult.FAILED)) {
return false;
}
System.out.println("Validation succeeded.");
return true;
}
|
java
|
private static boolean validateLocal(String target, String name, CommandLine cmd)
throws InterruptedException {
int validationCount = 0;
Map<ValidationTask.TaskResult, Integer> results = new HashMap<>();
Map<String, String> optionsMap = new HashMap<>();
for (Option opt : cmd.getOptions()) {
optionsMap.put(opt.getOpt(), opt.getValue());
}
Collection<ValidationTask> tasks = TARGET_TASKS.get(target);
System.out.format("Validating %s environment...%n", target);
for (ValidationTask task: tasks) {
String taskName = TASKS.get(task);
if (name != null && !taskName.startsWith(name)) {
continue;
}
System.out.format("Validating %s...%n", taskName);
ValidationTask.TaskResult result = task.validate(optionsMap);
results.put(result, results.getOrDefault(result, 0) + 1);
switch (result) {
case OK:
System.out.print(Constants.ANSI_GREEN);
break;
case WARNING:
System.out.print(Constants.ANSI_YELLOW);
break;
case FAILED:
System.out.print(Constants.ANSI_RED);
break;
case SKIPPED:
System.out.print(Constants.ANSI_PURPLE);
break;
default:
break;
}
System.out.print(result.name());
System.out.println(Constants.ANSI_RESET);
validationCount++;
}
if (results.containsKey(ValidationTask.TaskResult.FAILED)) {
System.err.format("%d failures ", results.get(ValidationTask.TaskResult.FAILED));
}
if (results.containsKey(ValidationTask.TaskResult.WARNING)) {
System.err.format("%d warnings ", results.get(ValidationTask.TaskResult.WARNING));
}
if (results.containsKey(ValidationTask.TaskResult.SKIPPED)) {
System.err.format("%d skipped ", results.get(ValidationTask.TaskResult.SKIPPED));
}
System.err.println();
if (validationCount == 0) {
System.err.format("No validation task matched name \"%s\".%n", name);
return false;
}
if (results.containsKey(ValidationTask.TaskResult.FAILED)) {
return false;
}
System.out.println("Validation succeeded.");
return true;
}
|
[
"private",
"static",
"boolean",
"validateLocal",
"(",
"String",
"target",
",",
"String",
"name",
",",
"CommandLine",
"cmd",
")",
"throws",
"InterruptedException",
"{",
"int",
"validationCount",
"=",
"0",
";",
"Map",
"<",
"ValidationTask",
".",
"TaskResult",
",",
"Integer",
">",
"results",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"optionsMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Option",
"opt",
":",
"cmd",
".",
"getOptions",
"(",
")",
")",
"{",
"optionsMap",
".",
"put",
"(",
"opt",
".",
"getOpt",
"(",
")",
",",
"opt",
".",
"getValue",
"(",
")",
")",
";",
"}",
"Collection",
"<",
"ValidationTask",
">",
"tasks",
"=",
"TARGET_TASKS",
".",
"get",
"(",
"target",
")",
";",
"System",
".",
"out",
".",
"format",
"(",
"\"Validating %s environment...%n\"",
",",
"target",
")",
";",
"for",
"(",
"ValidationTask",
"task",
":",
"tasks",
")",
"{",
"String",
"taskName",
"=",
"TASKS",
".",
"get",
"(",
"task",
")",
";",
"if",
"(",
"name",
"!=",
"null",
"&&",
"!",
"taskName",
".",
"startsWith",
"(",
"name",
")",
")",
"{",
"continue",
";",
"}",
"System",
".",
"out",
".",
"format",
"(",
"\"Validating %s...%n\"",
",",
"taskName",
")",
";",
"ValidationTask",
".",
"TaskResult",
"result",
"=",
"task",
".",
"validate",
"(",
"optionsMap",
")",
";",
"results",
".",
"put",
"(",
"result",
",",
"results",
".",
"getOrDefault",
"(",
"result",
",",
"0",
")",
"+",
"1",
")",
";",
"switch",
"(",
"result",
")",
"{",
"case",
"OK",
":",
"System",
".",
"out",
".",
"print",
"(",
"Constants",
".",
"ANSI_GREEN",
")",
";",
"break",
";",
"case",
"WARNING",
":",
"System",
".",
"out",
".",
"print",
"(",
"Constants",
".",
"ANSI_YELLOW",
")",
";",
"break",
";",
"case",
"FAILED",
":",
"System",
".",
"out",
".",
"print",
"(",
"Constants",
".",
"ANSI_RED",
")",
";",
"break",
";",
"case",
"SKIPPED",
":",
"System",
".",
"out",
".",
"print",
"(",
"Constants",
".",
"ANSI_PURPLE",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"System",
".",
"out",
".",
"print",
"(",
"result",
".",
"name",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"Constants",
".",
"ANSI_RESET",
")",
";",
"validationCount",
"++",
";",
"}",
"if",
"(",
"results",
".",
"containsKey",
"(",
"ValidationTask",
".",
"TaskResult",
".",
"FAILED",
")",
")",
"{",
"System",
".",
"err",
".",
"format",
"(",
"\"%d failures \"",
",",
"results",
".",
"get",
"(",
"ValidationTask",
".",
"TaskResult",
".",
"FAILED",
")",
")",
";",
"}",
"if",
"(",
"results",
".",
"containsKey",
"(",
"ValidationTask",
".",
"TaskResult",
".",
"WARNING",
")",
")",
"{",
"System",
".",
"err",
".",
"format",
"(",
"\"%d warnings \"",
",",
"results",
".",
"get",
"(",
"ValidationTask",
".",
"TaskResult",
".",
"WARNING",
")",
")",
";",
"}",
"if",
"(",
"results",
".",
"containsKey",
"(",
"ValidationTask",
".",
"TaskResult",
".",
"SKIPPED",
")",
")",
"{",
"System",
".",
"err",
".",
"format",
"(",
"\"%d skipped \"",
",",
"results",
".",
"get",
"(",
"ValidationTask",
".",
"TaskResult",
".",
"SKIPPED",
")",
")",
";",
"}",
"System",
".",
"err",
".",
"println",
"(",
")",
";",
"if",
"(",
"validationCount",
"==",
"0",
")",
"{",
"System",
".",
"err",
".",
"format",
"(",
"\"No validation task matched name \\\"%s\\\".%n\"",
",",
"name",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"results",
".",
"containsKey",
"(",
"ValidationTask",
".",
"TaskResult",
".",
"FAILED",
")",
")",
"{",
"return",
"false",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"Validation succeeded.\"",
")",
";",
"return",
"true",
";",
"}"
] |
runs validation tasks in local environment
|
[
"runs",
"validation",
"tasks",
"in",
"local",
"environment"
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/cli/ValidateEnv.java#L239-L296
|
18,532
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/cli/ValidateEnv.java
|
ValidateEnv.validate
|
public static int validate(String... argv) throws InterruptedException {
if (argv.length < 1) {
printHelp("Target not specified.");
return -2;
}
String command = argv[0];
String name = null;
String[] args;
int argsLength = 0;
// Find all non-option command line arguments.
while (argsLength < argv.length && !argv[argsLength].startsWith("-")) {
argsLength++;
}
if (argsLength > 1) {
name = argv[1];
args = Arrays.copyOfRange(argv, 2, argv.length);
} else {
args = Arrays.copyOfRange(argv, 1, argv.length);
}
CommandLine cmd;
try {
cmd = parseArgsAndOptions(OPTIONS, args);
} catch (InvalidArgumentException e) {
System.err.format("Invalid argument: %s.%n", e.getMessage());
return -1;
}
if (command != null && command.equals("list")) {
printTasks();
return 0;
}
return runTasks(command, name, cmd);
}
|
java
|
public static int validate(String... argv) throws InterruptedException {
if (argv.length < 1) {
printHelp("Target not specified.");
return -2;
}
String command = argv[0];
String name = null;
String[] args;
int argsLength = 0;
// Find all non-option command line arguments.
while (argsLength < argv.length && !argv[argsLength].startsWith("-")) {
argsLength++;
}
if (argsLength > 1) {
name = argv[1];
args = Arrays.copyOfRange(argv, 2, argv.length);
} else {
args = Arrays.copyOfRange(argv, 1, argv.length);
}
CommandLine cmd;
try {
cmd = parseArgsAndOptions(OPTIONS, args);
} catch (InvalidArgumentException e) {
System.err.format("Invalid argument: %s.%n", e.getMessage());
return -1;
}
if (command != null && command.equals("list")) {
printTasks();
return 0;
}
return runTasks(command, name, cmd);
}
|
[
"public",
"static",
"int",
"validate",
"(",
"String",
"...",
"argv",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"argv",
".",
"length",
"<",
"1",
")",
"{",
"printHelp",
"(",
"\"Target not specified.\"",
")",
";",
"return",
"-",
"2",
";",
"}",
"String",
"command",
"=",
"argv",
"[",
"0",
"]",
";",
"String",
"name",
"=",
"null",
";",
"String",
"[",
"]",
"args",
";",
"int",
"argsLength",
"=",
"0",
";",
"// Find all non-option command line arguments.",
"while",
"(",
"argsLength",
"<",
"argv",
".",
"length",
"&&",
"!",
"argv",
"[",
"argsLength",
"]",
".",
"startsWith",
"(",
"\"-\"",
")",
")",
"{",
"argsLength",
"++",
";",
"}",
"if",
"(",
"argsLength",
">",
"1",
")",
"{",
"name",
"=",
"argv",
"[",
"1",
"]",
";",
"args",
"=",
"Arrays",
".",
"copyOfRange",
"(",
"argv",
",",
"2",
",",
"argv",
".",
"length",
")",
";",
"}",
"else",
"{",
"args",
"=",
"Arrays",
".",
"copyOfRange",
"(",
"argv",
",",
"1",
",",
"argv",
".",
"length",
")",
";",
"}",
"CommandLine",
"cmd",
";",
"try",
"{",
"cmd",
"=",
"parseArgsAndOptions",
"(",
"OPTIONS",
",",
"args",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"e",
")",
"{",
"System",
".",
"err",
".",
"format",
"(",
"\"Invalid argument: %s.%n\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"command",
"!=",
"null",
"&&",
"command",
".",
"equals",
"(",
"\"list\"",
")",
")",
"{",
"printTasks",
"(",
")",
";",
"return",
"0",
";",
"}",
"return",
"runTasks",
"(",
"command",
",",
"name",
",",
"cmd",
")",
";",
"}"
] |
Validates environment.
@param argv list of arguments
@return 0 on success, -1 on validation failures, -2 on invalid arguments
|
[
"Validates",
"environment",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/cli/ValidateEnv.java#L366-L398
|
18,533
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/TieredIdentityUtils.java
|
TieredIdentityUtils.matches
|
public static boolean matches(TieredIdentity.LocalityTier tier,
TieredIdentity.LocalityTier otherTier, boolean resolveIpAddress) {
String otherTierName = otherTier.getTierName();
if (!tier.getTierName().equals(otherTierName)) {
return false;
}
String otherTierValue = otherTier.getValue();
if (tier.getValue() != null && tier.getValue().equals(otherTierValue)) {
return true;
}
// For node tiers, attempt to resolve hostnames to IP addresses, this avoids common
// misconfiguration errors where a worker is using one hostname and the client is using
// another.
if (resolveIpAddress) {
if (Constants.LOCALITY_NODE.equals(tier.getTierName())) {
try {
String tierIpAddress = NetworkAddressUtils.resolveIpAddress(tier.getValue());
String otherTierIpAddress = NetworkAddressUtils.resolveIpAddress(otherTierValue);
if (tierIpAddress != null && tierIpAddress.equals(otherTierIpAddress)) {
return true;
}
} catch (UnknownHostException e) {
return false;
}
}
}
return false;
}
|
java
|
public static boolean matches(TieredIdentity.LocalityTier tier,
TieredIdentity.LocalityTier otherTier, boolean resolveIpAddress) {
String otherTierName = otherTier.getTierName();
if (!tier.getTierName().equals(otherTierName)) {
return false;
}
String otherTierValue = otherTier.getValue();
if (tier.getValue() != null && tier.getValue().equals(otherTierValue)) {
return true;
}
// For node tiers, attempt to resolve hostnames to IP addresses, this avoids common
// misconfiguration errors where a worker is using one hostname and the client is using
// another.
if (resolveIpAddress) {
if (Constants.LOCALITY_NODE.equals(tier.getTierName())) {
try {
String tierIpAddress = NetworkAddressUtils.resolveIpAddress(tier.getValue());
String otherTierIpAddress = NetworkAddressUtils.resolveIpAddress(otherTierValue);
if (tierIpAddress != null && tierIpAddress.equals(otherTierIpAddress)) {
return true;
}
} catch (UnknownHostException e) {
return false;
}
}
}
return false;
}
|
[
"public",
"static",
"boolean",
"matches",
"(",
"TieredIdentity",
".",
"LocalityTier",
"tier",
",",
"TieredIdentity",
".",
"LocalityTier",
"otherTier",
",",
"boolean",
"resolveIpAddress",
")",
"{",
"String",
"otherTierName",
"=",
"otherTier",
".",
"getTierName",
"(",
")",
";",
"if",
"(",
"!",
"tier",
".",
"getTierName",
"(",
")",
".",
"equals",
"(",
"otherTierName",
")",
")",
"{",
"return",
"false",
";",
"}",
"String",
"otherTierValue",
"=",
"otherTier",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"tier",
".",
"getValue",
"(",
")",
"!=",
"null",
"&&",
"tier",
".",
"getValue",
"(",
")",
".",
"equals",
"(",
"otherTierValue",
")",
")",
"{",
"return",
"true",
";",
"}",
"// For node tiers, attempt to resolve hostnames to IP addresses, this avoids common",
"// misconfiguration errors where a worker is using one hostname and the client is using",
"// another.",
"if",
"(",
"resolveIpAddress",
")",
"{",
"if",
"(",
"Constants",
".",
"LOCALITY_NODE",
".",
"equals",
"(",
"tier",
".",
"getTierName",
"(",
")",
")",
")",
"{",
"try",
"{",
"String",
"tierIpAddress",
"=",
"NetworkAddressUtils",
".",
"resolveIpAddress",
"(",
"tier",
".",
"getValue",
"(",
")",
")",
";",
"String",
"otherTierIpAddress",
"=",
"NetworkAddressUtils",
".",
"resolveIpAddress",
"(",
"otherTierValue",
")",
";",
"if",
"(",
"tierIpAddress",
"!=",
"null",
"&&",
"tierIpAddress",
".",
"equals",
"(",
"otherTierIpAddress",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"UnknownHostException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Locality comparison for wire type locality tiers, two locality tiers matches if both name and
values are equal, or for the "node" tier, if the node names resolve to the same IP address.
@param tier a wire type locality tier
@param otherTier a wire type locality tier to compare to
@param resolveIpAddress whether or not to resolve hostnames to IP addresses for node locality
@return true if the wire type locality tier matches the given tier
|
[
"Locality",
"comparison",
"for",
"wire",
"type",
"locality",
"tiers",
"two",
"locality",
"tiers",
"matches",
"if",
"both",
"name",
"and",
"values",
"are",
"equal",
"or",
"for",
"the",
"node",
"tier",
"if",
"the",
"node",
"names",
"resolve",
"to",
"the",
"same",
"IP",
"address",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/TieredIdentityUtils.java#L41-L68
|
18,534
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/JournalTool.java
|
JournalTool.main
|
public static void main(String[] args) throws IOException {
if (!parseInputArgs(args)) {
usage();
System.exit(EXIT_FAILED);
}
if (sHelp) {
usage();
System.exit(EXIT_SUCCEEDED);
}
dumpJournal();
}
|
java
|
public static void main(String[] args) throws IOException {
if (!parseInputArgs(args)) {
usage();
System.exit(EXIT_FAILED);
}
if (sHelp) {
usage();
System.exit(EXIT_SUCCEEDED);
}
dumpJournal();
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"parseInputArgs",
"(",
"args",
")",
")",
"{",
"usage",
"(",
")",
";",
"System",
".",
"exit",
"(",
"EXIT_FAILED",
")",
";",
"}",
"if",
"(",
"sHelp",
")",
"{",
"usage",
"(",
")",
";",
"System",
".",
"exit",
"(",
"EXIT_SUCCEEDED",
")",
";",
"}",
"dumpJournal",
"(",
")",
";",
"}"
] |
Dumps a ufs journal in human-readable format.
@param args arguments passed to the tool
|
[
"Dumps",
"a",
"ufs",
"journal",
"in",
"human",
"-",
"readable",
"format",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/JournalTool.java#L97-L108
|
18,535
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/ValidateConf.java
|
ValidateConf.main
|
public static void main(String[] args) {
LOG.info("Validating configuration.");
try {
new InstancedConfiguration(ConfigurationUtils.defaults()).validate();
LOG.info("Configuration is valid.");
} catch (IllegalStateException e) {
LOG.error("Configuration is invalid: {}", e.getMessage());
System.exit(-1);
}
System.exit(0);
}
|
java
|
public static void main(String[] args) {
LOG.info("Validating configuration.");
try {
new InstancedConfiguration(ConfigurationUtils.defaults()).validate();
LOG.info("Configuration is valid.");
} catch (IllegalStateException e) {
LOG.error("Configuration is invalid: {}", e.getMessage());
System.exit(-1);
}
System.exit(0);
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Validating configuration.\"",
")",
";",
"try",
"{",
"new",
"InstancedConfiguration",
"(",
"ConfigurationUtils",
".",
"defaults",
"(",
")",
")",
".",
"validate",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Configuration is valid.\"",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Configuration is invalid: {}\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"System",
".",
"exit",
"(",
"-",
"1",
")",
";",
"}",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}"
] |
Console program that validates the configuration.
@param args there are no arguments needed
|
[
"Console",
"program",
"that",
"validates",
"the",
"configuration",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/ValidateConf.java#L34-L44
|
18,536
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/cli/extensions/ExtensionsShell.java
|
ExtensionsShell.main
|
public static void main(String[] args) {
ExtensionsShell extensionShell =
new ExtensionsShell(ServerConfiguration.global());
System.exit(extensionShell.run(args));
}
|
java
|
public static void main(String[] args) {
ExtensionsShell extensionShell =
new ExtensionsShell(ServerConfiguration.global());
System.exit(extensionShell.run(args));
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"ExtensionsShell",
"extensionShell",
"=",
"new",
"ExtensionsShell",
"(",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
";",
"System",
".",
"exit",
"(",
"extensionShell",
".",
"run",
"(",
"args",
")",
")",
";",
"}"
] |
Manage Alluxio extensions.
@param args array of arguments given by the user's input from the terminal
|
[
"Manage",
"Alluxio",
"extensions",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/cli/extensions/ExtensionsShell.java#L39-L43
|
18,537
|
Alluxio/alluxio
|
job/client/src/main/java/alluxio/client/job/JobGrpcClientUtils.java
|
JobGrpcClientUtils.run
|
public static void run(JobConfig config, int attempts, AlluxioConfiguration alluxioConf)
throws InterruptedException {
CountingRetry retryPolicy = new CountingRetry(attempts);
while (retryPolicy.attempt()) {
long jobId;
try (JobMasterClient client = JobMasterClient.Factory.create(
JobMasterClientContext.newBuilder(ClientContext.create(alluxioConf)).build())) {
jobId = client.run(config);
} catch (Exception e) {
// job could not be started, retry
LOG.warn("Exception encountered when starting a job.", e);
continue;
}
JobInfo jobInfo = waitFor(jobId, alluxioConf);
if (jobInfo == null) {
// job status could not be fetched, give up
break;
}
if (jobInfo.getStatus() == Status.COMPLETED || jobInfo.getStatus() == Status.CANCELED) {
return;
}
LOG.warn("Job {} failed to complete: {}", jobId, jobInfo.getErrorMessage());
}
throw new RuntimeException("Failed to successfully complete the job.");
}
|
java
|
public static void run(JobConfig config, int attempts, AlluxioConfiguration alluxioConf)
throws InterruptedException {
CountingRetry retryPolicy = new CountingRetry(attempts);
while (retryPolicy.attempt()) {
long jobId;
try (JobMasterClient client = JobMasterClient.Factory.create(
JobMasterClientContext.newBuilder(ClientContext.create(alluxioConf)).build())) {
jobId = client.run(config);
} catch (Exception e) {
// job could not be started, retry
LOG.warn("Exception encountered when starting a job.", e);
continue;
}
JobInfo jobInfo = waitFor(jobId, alluxioConf);
if (jobInfo == null) {
// job status could not be fetched, give up
break;
}
if (jobInfo.getStatus() == Status.COMPLETED || jobInfo.getStatus() == Status.CANCELED) {
return;
}
LOG.warn("Job {} failed to complete: {}", jobId, jobInfo.getErrorMessage());
}
throw new RuntimeException("Failed to successfully complete the job.");
}
|
[
"public",
"static",
"void",
"run",
"(",
"JobConfig",
"config",
",",
"int",
"attempts",
",",
"AlluxioConfiguration",
"alluxioConf",
")",
"throws",
"InterruptedException",
"{",
"CountingRetry",
"retryPolicy",
"=",
"new",
"CountingRetry",
"(",
"attempts",
")",
";",
"while",
"(",
"retryPolicy",
".",
"attempt",
"(",
")",
")",
"{",
"long",
"jobId",
";",
"try",
"(",
"JobMasterClient",
"client",
"=",
"JobMasterClient",
".",
"Factory",
".",
"create",
"(",
"JobMasterClientContext",
".",
"newBuilder",
"(",
"ClientContext",
".",
"create",
"(",
"alluxioConf",
")",
")",
".",
"build",
"(",
")",
")",
")",
"{",
"jobId",
"=",
"client",
".",
"run",
"(",
"config",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// job could not be started, retry",
"LOG",
".",
"warn",
"(",
"\"Exception encountered when starting a job.\"",
",",
"e",
")",
";",
"continue",
";",
"}",
"JobInfo",
"jobInfo",
"=",
"waitFor",
"(",
"jobId",
",",
"alluxioConf",
")",
";",
"if",
"(",
"jobInfo",
"==",
"null",
")",
"{",
"// job status could not be fetched, give up",
"break",
";",
"}",
"if",
"(",
"jobInfo",
".",
"getStatus",
"(",
")",
"==",
"Status",
".",
"COMPLETED",
"||",
"jobInfo",
".",
"getStatus",
"(",
")",
"==",
"Status",
".",
"CANCELED",
")",
"{",
"return",
";",
"}",
"LOG",
".",
"warn",
"(",
"\"Job {} failed to complete: {}\"",
",",
"jobId",
",",
"jobInfo",
".",
"getErrorMessage",
"(",
")",
")",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to successfully complete the job.\"",
")",
";",
"}"
] |
Runs the specified job and waits for it to finish. If the job fails, it is retried the given
number of times. If the job does not complete in the given number of attempts, an exception
is thrown.
@param config configuration for the job to run
@param attempts number of times to try running the job before giving up
@param alluxioConf Alluxio configuration
|
[
"Runs",
"the",
"specified",
"job",
"and",
"waits",
"for",
"it",
"to",
"finish",
".",
"If",
"the",
"job",
"fails",
"it",
"is",
"retried",
"the",
"given",
"number",
"of",
"times",
".",
"If",
"the",
"job",
"does",
"not",
"complete",
"in",
"the",
"given",
"number",
"of",
"attempts",
"an",
"exception",
"is",
"thrown",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/client/src/main/java/alluxio/client/job/JobGrpcClientUtils.java#L51-L75
|
18,538
|
Alluxio/alluxio
|
job/client/src/main/java/alluxio/client/job/JobGrpcClientUtils.java
|
JobGrpcClientUtils.createProgressThread
|
public static Thread createProgressThread(final long intervalMs, final PrintStream stream) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
CommonUtils.sleepMs(intervalMs);
if (Thread.interrupted()) {
return;
}
stream.print(".");
}
}
});
thread.setDaemon(true);
return thread;
}
|
java
|
public static Thread createProgressThread(final long intervalMs, final PrintStream stream) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
CommonUtils.sleepMs(intervalMs);
if (Thread.interrupted()) {
return;
}
stream.print(".");
}
}
});
thread.setDaemon(true);
return thread;
}
|
[
"public",
"static",
"Thread",
"createProgressThread",
"(",
"final",
"long",
"intervalMs",
",",
"final",
"PrintStream",
"stream",
")",
"{",
"Thread",
"thread",
"=",
"new",
"Thread",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"while",
"(",
"true",
")",
"{",
"CommonUtils",
".",
"sleepMs",
"(",
"intervalMs",
")",
";",
"if",
"(",
"Thread",
".",
"interrupted",
"(",
")",
")",
"{",
"return",
";",
"}",
"stream",
".",
"print",
"(",
"\".\"",
")",
";",
"}",
"}",
"}",
")",
";",
"thread",
".",
"setDaemon",
"(",
"true",
")",
";",
"return",
"thread",
";",
"}"
] |
Creates a thread which will write "." to the given print stream at the given interval. The
created thread is not started by this method. The created thread will be daemonic and will
halt when interrupted.
@param intervalMs the time interval in milliseconds between writes
@param stream the print stream to write to
@return the thread
|
[
"Creates",
"a",
"thread",
"which",
"will",
"write",
".",
"to",
"the",
"given",
"print",
"stream",
"at",
"the",
"given",
"interval",
".",
"The",
"created",
"thread",
"is",
"not",
"started",
"by",
"this",
"method",
".",
"The",
"created",
"thread",
"will",
"be",
"daemonic",
"and",
"will",
"halt",
"when",
"interrupted",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/client/src/main/java/alluxio/client/job/JobGrpcClientUtils.java#L97-L112
|
18,539
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/allocator/RoundRobinAllocator.java
|
RoundRobinAllocator.getNextAvailDirInTier
|
private int getNextAvailDirInTier(StorageTierView tierView, long blockSize) {
int dirViewIndex = mTierAliasToLastDirMap.get(tierView.getTierViewAlias());
for (int i = 0; i < tierView.getDirViews().size(); i++) { // try this many times
dirViewIndex = (dirViewIndex + 1) % tierView.getDirViews().size();
if (tierView.getDirView(dirViewIndex).getAvailableBytes() >= blockSize) {
return dirViewIndex;
}
}
return -1;
}
|
java
|
private int getNextAvailDirInTier(StorageTierView tierView, long blockSize) {
int dirViewIndex = mTierAliasToLastDirMap.get(tierView.getTierViewAlias());
for (int i = 0; i < tierView.getDirViews().size(); i++) { // try this many times
dirViewIndex = (dirViewIndex + 1) % tierView.getDirViews().size();
if (tierView.getDirView(dirViewIndex).getAvailableBytes() >= blockSize) {
return dirViewIndex;
}
}
return -1;
}
|
[
"private",
"int",
"getNextAvailDirInTier",
"(",
"StorageTierView",
"tierView",
",",
"long",
"blockSize",
")",
"{",
"int",
"dirViewIndex",
"=",
"mTierAliasToLastDirMap",
".",
"get",
"(",
"tierView",
".",
"getTierViewAlias",
"(",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tierView",
".",
"getDirViews",
"(",
")",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"// try this many times",
"dirViewIndex",
"=",
"(",
"dirViewIndex",
"+",
"1",
")",
"%",
"tierView",
".",
"getDirViews",
"(",
")",
".",
"size",
"(",
")",
";",
"if",
"(",
"tierView",
".",
"getDirView",
"(",
"dirViewIndex",
")",
".",
"getAvailableBytes",
"(",
")",
">=",
"blockSize",
")",
"{",
"return",
"dirViewIndex",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Finds an available dir in a given tier for a block with blockSize.
@param tierView the tier to find a dir
@param blockSize the requested block size
@return the index of the dir if non-negative; -1 if fail to find a dir
|
[
"Finds",
"an",
"available",
"dir",
"in",
"a",
"given",
"tier",
"for",
"a",
"block",
"with",
"blockSize",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/allocator/RoundRobinAllocator.java#L109-L118
|
18,540
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/TieredBlockStore.java
|
TieredBlockStore.createBlockMetaInternal
|
private TempBlockMeta createBlockMetaInternal(long sessionId, long blockId,
BlockStoreLocation location, long initialBlockSize, boolean newBlock)
throws BlockAlreadyExistsException {
// NOTE: a temp block is supposed to be visible for its own writer, unnecessary to acquire
// block lock here since no sharing
try (LockResource r = new LockResource(mMetadataWriteLock)) {
if (newBlock) {
checkTempBlockIdAvailable(blockId);
}
StorageDirView dirView =
mAllocator.allocateBlockWithView(sessionId, initialBlockSize, location, getUpdatedView());
if (dirView == null) {
// Allocator fails to find a proper place for this new block.
return null;
}
// TODO(carson): Add tempBlock to corresponding storageDir and remove the use of
// StorageDirView.createTempBlockMeta.
TempBlockMeta tempBlock = dirView.createTempBlockMeta(sessionId, blockId, initialBlockSize);
try {
// Add allocated temp block to metadata manager. This should never fail if allocator
// correctly assigns a StorageDir.
mMetaManager.addTempBlockMeta(tempBlock);
} catch (WorkerOutOfSpaceException | BlockAlreadyExistsException e) {
// If we reach here, allocator is not working properly
LOG.error("Unexpected failure: {} bytes allocated at {} by allocator, "
+ "but addTempBlockMeta failed", initialBlockSize, location);
throw Throwables.propagate(e);
}
return tempBlock;
}
}
|
java
|
private TempBlockMeta createBlockMetaInternal(long sessionId, long blockId,
BlockStoreLocation location, long initialBlockSize, boolean newBlock)
throws BlockAlreadyExistsException {
// NOTE: a temp block is supposed to be visible for its own writer, unnecessary to acquire
// block lock here since no sharing
try (LockResource r = new LockResource(mMetadataWriteLock)) {
if (newBlock) {
checkTempBlockIdAvailable(blockId);
}
StorageDirView dirView =
mAllocator.allocateBlockWithView(sessionId, initialBlockSize, location, getUpdatedView());
if (dirView == null) {
// Allocator fails to find a proper place for this new block.
return null;
}
// TODO(carson): Add tempBlock to corresponding storageDir and remove the use of
// StorageDirView.createTempBlockMeta.
TempBlockMeta tempBlock = dirView.createTempBlockMeta(sessionId, blockId, initialBlockSize);
try {
// Add allocated temp block to metadata manager. This should never fail if allocator
// correctly assigns a StorageDir.
mMetaManager.addTempBlockMeta(tempBlock);
} catch (WorkerOutOfSpaceException | BlockAlreadyExistsException e) {
// If we reach here, allocator is not working properly
LOG.error("Unexpected failure: {} bytes allocated at {} by allocator, "
+ "but addTempBlockMeta failed", initialBlockSize, location);
throw Throwables.propagate(e);
}
return tempBlock;
}
}
|
[
"private",
"TempBlockMeta",
"createBlockMetaInternal",
"(",
"long",
"sessionId",
",",
"long",
"blockId",
",",
"BlockStoreLocation",
"location",
",",
"long",
"initialBlockSize",
",",
"boolean",
"newBlock",
")",
"throws",
"BlockAlreadyExistsException",
"{",
"// NOTE: a temp block is supposed to be visible for its own writer, unnecessary to acquire",
"// block lock here since no sharing",
"try",
"(",
"LockResource",
"r",
"=",
"new",
"LockResource",
"(",
"mMetadataWriteLock",
")",
")",
"{",
"if",
"(",
"newBlock",
")",
"{",
"checkTempBlockIdAvailable",
"(",
"blockId",
")",
";",
"}",
"StorageDirView",
"dirView",
"=",
"mAllocator",
".",
"allocateBlockWithView",
"(",
"sessionId",
",",
"initialBlockSize",
",",
"location",
",",
"getUpdatedView",
"(",
")",
")",
";",
"if",
"(",
"dirView",
"==",
"null",
")",
"{",
"// Allocator fails to find a proper place for this new block.",
"return",
"null",
";",
"}",
"// TODO(carson): Add tempBlock to corresponding storageDir and remove the use of",
"// StorageDirView.createTempBlockMeta.",
"TempBlockMeta",
"tempBlock",
"=",
"dirView",
".",
"createTempBlockMeta",
"(",
"sessionId",
",",
"blockId",
",",
"initialBlockSize",
")",
";",
"try",
"{",
"// Add allocated temp block to metadata manager. This should never fail if allocator",
"// correctly assigns a StorageDir.",
"mMetaManager",
".",
"addTempBlockMeta",
"(",
"tempBlock",
")",
";",
"}",
"catch",
"(",
"WorkerOutOfSpaceException",
"|",
"BlockAlreadyExistsException",
"e",
")",
"{",
"// If we reach here, allocator is not working properly",
"LOG",
".",
"error",
"(",
"\"Unexpected failure: {} bytes allocated at {} by allocator, \"",
"+",
"\"but addTempBlockMeta failed\"",
",",
"initialBlockSize",
",",
"location",
")",
";",
"throw",
"Throwables",
".",
"propagate",
"(",
"e",
")",
";",
"}",
"return",
"tempBlock",
";",
"}",
"}"
] |
Creates a temp block meta only if allocator finds available space. This method will not trigger
any eviction.
@param sessionId session id
@param blockId block id
@param location location to create the block
@param initialBlockSize initial block size in bytes
@param newBlock true if this temp block is created for a new block
@return a temp block created if successful, or null if allocation failed (instead of throwing
{@link WorkerOutOfSpaceException} because allocation failure could be an expected case)
@throws BlockAlreadyExistsException if there is already a block with the same block id
|
[
"Creates",
"a",
"temp",
"block",
"meta",
"only",
"if",
"allocator",
"finds",
"available",
"space",
".",
"This",
"method",
"will",
"not",
"trigger",
"any",
"eviction",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/TieredBlockStore.java#L635-L665
|
18,541
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/TieredBlockStore.java
|
TieredBlockStore.requestSpaceInternal
|
private Pair<Boolean, BlockStoreLocation> requestSpaceInternal(long blockId, long additionalBytes)
throws BlockDoesNotExistException {
// NOTE: a temp block is supposed to be visible for its own writer, unnecessary to acquire
// block lock here since no sharing
try (LockResource r = new LockResource(mMetadataWriteLock)) {
TempBlockMeta tempBlockMeta = mMetaManager.getTempBlockMeta(blockId);
if (tempBlockMeta.getParentDir().getAvailableBytes() < additionalBytes) {
return new Pair<>(false, tempBlockMeta.getBlockLocation());
}
// Increase the size of this temp block
try {
mMetaManager.resizeTempBlockMeta(tempBlockMeta,
tempBlockMeta.getBlockSize() + additionalBytes);
} catch (InvalidWorkerStateException e) {
throw Throwables.propagate(e); // we shall never reach here
}
return new Pair<>(true, null);
}
}
|
java
|
private Pair<Boolean, BlockStoreLocation> requestSpaceInternal(long blockId, long additionalBytes)
throws BlockDoesNotExistException {
// NOTE: a temp block is supposed to be visible for its own writer, unnecessary to acquire
// block lock here since no sharing
try (LockResource r = new LockResource(mMetadataWriteLock)) {
TempBlockMeta tempBlockMeta = mMetaManager.getTempBlockMeta(blockId);
if (tempBlockMeta.getParentDir().getAvailableBytes() < additionalBytes) {
return new Pair<>(false, tempBlockMeta.getBlockLocation());
}
// Increase the size of this temp block
try {
mMetaManager.resizeTempBlockMeta(tempBlockMeta,
tempBlockMeta.getBlockSize() + additionalBytes);
} catch (InvalidWorkerStateException e) {
throw Throwables.propagate(e); // we shall never reach here
}
return new Pair<>(true, null);
}
}
|
[
"private",
"Pair",
"<",
"Boolean",
",",
"BlockStoreLocation",
">",
"requestSpaceInternal",
"(",
"long",
"blockId",
",",
"long",
"additionalBytes",
")",
"throws",
"BlockDoesNotExistException",
"{",
"// NOTE: a temp block is supposed to be visible for its own writer, unnecessary to acquire",
"// block lock here since no sharing",
"try",
"(",
"LockResource",
"r",
"=",
"new",
"LockResource",
"(",
"mMetadataWriteLock",
")",
")",
"{",
"TempBlockMeta",
"tempBlockMeta",
"=",
"mMetaManager",
".",
"getTempBlockMeta",
"(",
"blockId",
")",
";",
"if",
"(",
"tempBlockMeta",
".",
"getParentDir",
"(",
")",
".",
"getAvailableBytes",
"(",
")",
"<",
"additionalBytes",
")",
"{",
"return",
"new",
"Pair",
"<>",
"(",
"false",
",",
"tempBlockMeta",
".",
"getBlockLocation",
"(",
")",
")",
";",
"}",
"// Increase the size of this temp block",
"try",
"{",
"mMetaManager",
".",
"resizeTempBlockMeta",
"(",
"tempBlockMeta",
",",
"tempBlockMeta",
".",
"getBlockSize",
"(",
")",
"+",
"additionalBytes",
")",
";",
"}",
"catch",
"(",
"InvalidWorkerStateException",
"e",
")",
"{",
"throw",
"Throwables",
".",
"propagate",
"(",
"e",
")",
";",
"// we shall never reach here",
"}",
"return",
"new",
"Pair",
"<>",
"(",
"true",
",",
"null",
")",
";",
"}",
"}"
] |
Increases the temp block size only if this temp block's parent dir has enough available space.
@param blockId block id
@param additionalBytes additional bytes to request for this block
@return a pair of boolean and {@link BlockStoreLocation}. The boolean indicates if the
operation succeeds and the {@link BlockStoreLocation} denotes where to free more space
if it fails.
@throws BlockDoesNotExistException if this block is not found
|
[
"Increases",
"the",
"temp",
"block",
"size",
"only",
"if",
"this",
"temp",
"block",
"s",
"parent",
"dir",
"has",
"enough",
"available",
"space",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/TieredBlockStore.java#L677-L695
|
18,542
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/TieredBlockStore.java
|
TieredBlockStore.removeBlockInternal
|
private void removeBlockInternal(long sessionId, long blockId, BlockStoreLocation location)
throws InvalidWorkerStateException, BlockDoesNotExistException, IOException {
long lockId = mLockManager.lockBlock(sessionId, blockId, BlockLockType.WRITE);
try {
String filePath;
BlockMeta blockMeta;
try (LockResource r = new LockResource(mMetadataReadLock)) {
if (mMetaManager.hasTempBlockMeta(blockId)) {
throw new InvalidWorkerStateException(ExceptionMessage.REMOVE_UNCOMMITTED_BLOCK, blockId);
}
blockMeta = mMetaManager.getBlockMeta(blockId);
filePath = blockMeta.getPath();
}
if (!blockMeta.getBlockLocation().belongsTo(location)) {
throw new BlockDoesNotExistException(ExceptionMessage.BLOCK_NOT_FOUND_AT_LOCATION, blockId,
location);
}
// Heavy IO is guarded by block lock but not metadata lock. This may throw IOException.
Files.delete(Paths.get(filePath));
try (LockResource r = new LockResource(mMetadataWriteLock)) {
mMetaManager.removeBlockMeta(blockMeta);
} catch (BlockDoesNotExistException e) {
throw Throwables.propagate(e); // we shall never reach here
}
} finally {
mLockManager.unlockBlock(lockId);
}
}
|
java
|
private void removeBlockInternal(long sessionId, long blockId, BlockStoreLocation location)
throws InvalidWorkerStateException, BlockDoesNotExistException, IOException {
long lockId = mLockManager.lockBlock(sessionId, blockId, BlockLockType.WRITE);
try {
String filePath;
BlockMeta blockMeta;
try (LockResource r = new LockResource(mMetadataReadLock)) {
if (mMetaManager.hasTempBlockMeta(blockId)) {
throw new InvalidWorkerStateException(ExceptionMessage.REMOVE_UNCOMMITTED_BLOCK, blockId);
}
blockMeta = mMetaManager.getBlockMeta(blockId);
filePath = blockMeta.getPath();
}
if (!blockMeta.getBlockLocation().belongsTo(location)) {
throw new BlockDoesNotExistException(ExceptionMessage.BLOCK_NOT_FOUND_AT_LOCATION, blockId,
location);
}
// Heavy IO is guarded by block lock but not metadata lock. This may throw IOException.
Files.delete(Paths.get(filePath));
try (LockResource r = new LockResource(mMetadataWriteLock)) {
mMetaManager.removeBlockMeta(blockMeta);
} catch (BlockDoesNotExistException e) {
throw Throwables.propagate(e); // we shall never reach here
}
} finally {
mLockManager.unlockBlock(lockId);
}
}
|
[
"private",
"void",
"removeBlockInternal",
"(",
"long",
"sessionId",
",",
"long",
"blockId",
",",
"BlockStoreLocation",
"location",
")",
"throws",
"InvalidWorkerStateException",
",",
"BlockDoesNotExistException",
",",
"IOException",
"{",
"long",
"lockId",
"=",
"mLockManager",
".",
"lockBlock",
"(",
"sessionId",
",",
"blockId",
",",
"BlockLockType",
".",
"WRITE",
")",
";",
"try",
"{",
"String",
"filePath",
";",
"BlockMeta",
"blockMeta",
";",
"try",
"(",
"LockResource",
"r",
"=",
"new",
"LockResource",
"(",
"mMetadataReadLock",
")",
")",
"{",
"if",
"(",
"mMetaManager",
".",
"hasTempBlockMeta",
"(",
"blockId",
")",
")",
"{",
"throw",
"new",
"InvalidWorkerStateException",
"(",
"ExceptionMessage",
".",
"REMOVE_UNCOMMITTED_BLOCK",
",",
"blockId",
")",
";",
"}",
"blockMeta",
"=",
"mMetaManager",
".",
"getBlockMeta",
"(",
"blockId",
")",
";",
"filePath",
"=",
"blockMeta",
".",
"getPath",
"(",
")",
";",
"}",
"if",
"(",
"!",
"blockMeta",
".",
"getBlockLocation",
"(",
")",
".",
"belongsTo",
"(",
"location",
")",
")",
"{",
"throw",
"new",
"BlockDoesNotExistException",
"(",
"ExceptionMessage",
".",
"BLOCK_NOT_FOUND_AT_LOCATION",
",",
"blockId",
",",
"location",
")",
";",
"}",
"// Heavy IO is guarded by block lock but not metadata lock. This may throw IOException.",
"Files",
".",
"delete",
"(",
"Paths",
".",
"get",
"(",
"filePath",
")",
")",
";",
"try",
"(",
"LockResource",
"r",
"=",
"new",
"LockResource",
"(",
"mMetadataWriteLock",
")",
")",
"{",
"mMetaManager",
".",
"removeBlockMeta",
"(",
"blockMeta",
")",
";",
"}",
"catch",
"(",
"BlockDoesNotExistException",
"e",
")",
"{",
"throw",
"Throwables",
".",
"propagate",
"(",
"e",
")",
";",
"// we shall never reach here",
"}",
"}",
"finally",
"{",
"mLockManager",
".",
"unlockBlock",
"(",
"lockId",
")",
";",
"}",
"}"
] |
Removes a block.
@param sessionId session id
@param blockId block id
@param location the source location of the block
@throws InvalidWorkerStateException if the block to remove is a temp block
@throws BlockDoesNotExistException if this block can not be found
|
[
"Removes",
"a",
"block",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/TieredBlockStore.java#L888-L917
|
18,543
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/TieredBlockStore.java
|
TieredBlockStore.updatePinnedInodes
|
@Override
public void updatePinnedInodes(Set<Long> inodes) {
LOG.debug("updatePinnedInodes: inodes={}", inodes);
synchronized (mPinnedInodes) {
mPinnedInodes.clear();
mPinnedInodes.addAll(Preconditions.checkNotNull(inodes));
}
}
|
java
|
@Override
public void updatePinnedInodes(Set<Long> inodes) {
LOG.debug("updatePinnedInodes: inodes={}", inodes);
synchronized (mPinnedInodes) {
mPinnedInodes.clear();
mPinnedInodes.addAll(Preconditions.checkNotNull(inodes));
}
}
|
[
"@",
"Override",
"public",
"void",
"updatePinnedInodes",
"(",
"Set",
"<",
"Long",
">",
"inodes",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"updatePinnedInodes: inodes={}\"",
",",
"inodes",
")",
";",
"synchronized",
"(",
"mPinnedInodes",
")",
"{",
"mPinnedInodes",
".",
"clear",
"(",
")",
";",
"mPinnedInodes",
".",
"addAll",
"(",
"Preconditions",
".",
"checkNotNull",
"(",
"inodes",
")",
")",
";",
"}",
"}"
] |
Updates the pinned blocks.
@param inodes a set of ids inodes that are pinned
|
[
"Updates",
"the",
"pinned",
"blocks",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/TieredBlockStore.java#L941-L948
|
18,544
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/TieredBlockStore.java
|
TieredBlockStore.removeDir
|
public void removeDir(StorageDir dir) {
// TODO(feng): Add a command for manually removing directory
try (LockResource r = new LockResource(mMetadataWriteLock)) {
String tierAlias = dir.getParentTier().getTierAlias();
dir.getParentTier().removeStorageDir(dir);
synchronized (mBlockStoreEventListeners) {
for (BlockStoreEventListener listener : mBlockStoreEventListeners) {
dir.getBlockIds().forEach(listener::onBlockLost);
listener.onStorageLost(tierAlias, dir.getDirPath());
}
}
}
}
|
java
|
public void removeDir(StorageDir dir) {
// TODO(feng): Add a command for manually removing directory
try (LockResource r = new LockResource(mMetadataWriteLock)) {
String tierAlias = dir.getParentTier().getTierAlias();
dir.getParentTier().removeStorageDir(dir);
synchronized (mBlockStoreEventListeners) {
for (BlockStoreEventListener listener : mBlockStoreEventListeners) {
dir.getBlockIds().forEach(listener::onBlockLost);
listener.onStorageLost(tierAlias, dir.getDirPath());
}
}
}
}
|
[
"public",
"void",
"removeDir",
"(",
"StorageDir",
"dir",
")",
"{",
"// TODO(feng): Add a command for manually removing directory",
"try",
"(",
"LockResource",
"r",
"=",
"new",
"LockResource",
"(",
"mMetadataWriteLock",
")",
")",
"{",
"String",
"tierAlias",
"=",
"dir",
".",
"getParentTier",
"(",
")",
".",
"getTierAlias",
"(",
")",
";",
"dir",
".",
"getParentTier",
"(",
")",
".",
"removeStorageDir",
"(",
"dir",
")",
";",
"synchronized",
"(",
"mBlockStoreEventListeners",
")",
"{",
"for",
"(",
"BlockStoreEventListener",
"listener",
":",
"mBlockStoreEventListeners",
")",
"{",
"dir",
".",
"getBlockIds",
"(",
")",
".",
"forEach",
"(",
"listener",
"::",
"onBlockLost",
")",
";",
"listener",
".",
"onStorageLost",
"(",
"tierAlias",
",",
"dir",
".",
"getDirPath",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Removes a storage directory.
@param dir storage directory to be removed
|
[
"Removes",
"a",
"storage",
"directory",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/TieredBlockStore.java#L973-L985
|
18,545
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/conf/AlluxioProperties.java
|
AlluxioProperties.remove
|
public void remove(PropertyKey key) {
// remove is a nop if the key doesn't already exist
if (mUserProps.containsKey(key)) {
mUserProps.remove(key);
mSources.remove(key);
}
}
|
java
|
public void remove(PropertyKey key) {
// remove is a nop if the key doesn't already exist
if (mUserProps.containsKey(key)) {
mUserProps.remove(key);
mSources.remove(key);
}
}
|
[
"public",
"void",
"remove",
"(",
"PropertyKey",
"key",
")",
"{",
"// remove is a nop if the key doesn't already exist",
"if",
"(",
"mUserProps",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"mUserProps",
".",
"remove",
"(",
"key",
")",
";",
"mSources",
".",
"remove",
"(",
"key",
")",
";",
"}",
"}"
] |
Remove the value set for key.
@param key key to remove
|
[
"Remove",
"the",
"value",
"set",
"for",
"key",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/conf/AlluxioProperties.java#L156-L162
|
18,546
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/conf/AlluxioProperties.java
|
AlluxioProperties.isSet
|
public boolean isSet(PropertyKey key) {
if (isSetByUser(key)) {
return true;
}
// In case key is not the reference to the original key
return PropertyKey.fromString(key.toString()).getDefaultValue() != null;
}
|
java
|
public boolean isSet(PropertyKey key) {
if (isSetByUser(key)) {
return true;
}
// In case key is not the reference to the original key
return PropertyKey.fromString(key.toString()).getDefaultValue() != null;
}
|
[
"public",
"boolean",
"isSet",
"(",
"PropertyKey",
"key",
")",
"{",
"if",
"(",
"isSetByUser",
"(",
"key",
")",
")",
"{",
"return",
"true",
";",
"}",
"// In case key is not the reference to the original key",
"return",
"PropertyKey",
".",
"fromString",
"(",
"key",
".",
"toString",
"(",
")",
")",
".",
"getDefaultValue",
"(",
")",
"!=",
"null",
";",
"}"
] |
Checks if there is a value set for the given key.
@param key the key to check
@return true if there is value for the key, false otherwise
|
[
"Checks",
"if",
"there",
"is",
"a",
"value",
"set",
"for",
"the",
"given",
"key",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/conf/AlluxioProperties.java#L170-L176
|
18,547
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/conf/AlluxioProperties.java
|
AlluxioProperties.forEach
|
public void forEach(BiConsumer<? super PropertyKey, ? super String> action) {
for (Map.Entry<PropertyKey, String> entry : entrySet()) {
action.accept(entry.getKey(), entry.getValue());
}
}
|
java
|
public void forEach(BiConsumer<? super PropertyKey, ? super String> action) {
for (Map.Entry<PropertyKey, String> entry : entrySet()) {
action.accept(entry.getKey(), entry.getValue());
}
}
|
[
"public",
"void",
"forEach",
"(",
"BiConsumer",
"<",
"?",
"super",
"PropertyKey",
",",
"?",
"super",
"String",
">",
"action",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"PropertyKey",
",",
"String",
">",
"entry",
":",
"entrySet",
"(",
")",
")",
"{",
"action",
".",
"accept",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] |
Iterates over all the key value pairs and performs the given action.
@param action the operation to perform on each key value pair
|
[
"Iterates",
"over",
"all",
"the",
"key",
"value",
"pairs",
"and",
"performs",
"the",
"given",
"action",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/conf/AlluxioProperties.java#L219-L223
|
18,548
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/conf/AlluxioProperties.java
|
AlluxioProperties.setSource
|
@VisibleForTesting
public void setSource(PropertyKey key, Source source) {
mSources.put(key, source);
}
|
java
|
@VisibleForTesting
public void setSource(PropertyKey key, Source source) {
mSources.put(key, source);
}
|
[
"@",
"VisibleForTesting",
"public",
"void",
"setSource",
"(",
"PropertyKey",
"key",
",",
"Source",
"source",
")",
"{",
"mSources",
".",
"put",
"(",
"key",
",",
"source",
")",
";",
"}"
] |
Sets the source for a given key.
@param key property key
@param source the source
|
[
"Sets",
"the",
"source",
"for",
"a",
"given",
"key",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/conf/AlluxioProperties.java#L240-L243
|
18,549
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/metrics/TimeSeriesStore.java
|
TimeSeriesStore.record
|
public void record(String metric, double value) {
mTimeSeries.compute(metric, (metricName, timeSeries) -> {
if (timeSeries == null) {
timeSeries = new TimeSeries(metricName);
}
timeSeries.record(value);
return timeSeries;
});
}
|
java
|
public void record(String metric, double value) {
mTimeSeries.compute(metric, (metricName, timeSeries) -> {
if (timeSeries == null) {
timeSeries = new TimeSeries(metricName);
}
timeSeries.record(value);
return timeSeries;
});
}
|
[
"public",
"void",
"record",
"(",
"String",
"metric",
",",
"double",
"value",
")",
"{",
"mTimeSeries",
".",
"compute",
"(",
"metric",
",",
"(",
"metricName",
",",
"timeSeries",
")",
"->",
"{",
"if",
"(",
"timeSeries",
"==",
"null",
")",
"{",
"timeSeries",
"=",
"new",
"TimeSeries",
"(",
"metricName",
")",
";",
"}",
"timeSeries",
".",
"record",
"(",
"value",
")",
";",
"return",
"timeSeries",
";",
"}",
")",
";",
"}"
] |
Records a value for the given metric at the current time.
@param metric the name of the metric
@param value the value of the metric
|
[
"Records",
"a",
"value",
"for",
"the",
"given",
"metric",
"at",
"the",
"current",
"time",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/metrics/TimeSeriesStore.java#L44-L52
|
18,550
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/UfsInputStreamManager.java
|
UfsInputStreamManager.release
|
public void release(InputStream inputStream) throws IOException {
// for non-seekable input stream, close and return
if (!(inputStream instanceof CachedSeekableInputStream) || !CACHE_ENABLED) {
inputStream.close();
return;
}
synchronized (mFileIdToInputStreamIds) {
if (!mFileIdToInputStreamIds
.containsKey(((CachedSeekableInputStream) inputStream).getFileId())) {
LOG.debug("The resource {} is already expired",
((CachedSeekableInputStream) inputStream).getResourceId());
// the cache no longer tracks this input stream
inputStream.close();
return;
}
UfsInputStreamIdSet resources =
mFileIdToInputStreamIds.get(((CachedSeekableInputStream) inputStream).getFileId());
if (!resources.release(((CachedSeekableInputStream) inputStream).getResourceId())) {
LOG.debug("Close the expired input stream resource of {}",
((CachedSeekableInputStream) inputStream).getResourceId());
// the input stream expired, close it
inputStream.close();
}
}
}
|
java
|
public void release(InputStream inputStream) throws IOException {
// for non-seekable input stream, close and return
if (!(inputStream instanceof CachedSeekableInputStream) || !CACHE_ENABLED) {
inputStream.close();
return;
}
synchronized (mFileIdToInputStreamIds) {
if (!mFileIdToInputStreamIds
.containsKey(((CachedSeekableInputStream) inputStream).getFileId())) {
LOG.debug("The resource {} is already expired",
((CachedSeekableInputStream) inputStream).getResourceId());
// the cache no longer tracks this input stream
inputStream.close();
return;
}
UfsInputStreamIdSet resources =
mFileIdToInputStreamIds.get(((CachedSeekableInputStream) inputStream).getFileId());
if (!resources.release(((CachedSeekableInputStream) inputStream).getResourceId())) {
LOG.debug("Close the expired input stream resource of {}",
((CachedSeekableInputStream) inputStream).getResourceId());
// the input stream expired, close it
inputStream.close();
}
}
}
|
[
"public",
"void",
"release",
"(",
"InputStream",
"inputStream",
")",
"throws",
"IOException",
"{",
"// for non-seekable input stream, close and return",
"if",
"(",
"!",
"(",
"inputStream",
"instanceof",
"CachedSeekableInputStream",
")",
"||",
"!",
"CACHE_ENABLED",
")",
"{",
"inputStream",
".",
"close",
"(",
")",
";",
"return",
";",
"}",
"synchronized",
"(",
"mFileIdToInputStreamIds",
")",
"{",
"if",
"(",
"!",
"mFileIdToInputStreamIds",
".",
"containsKey",
"(",
"(",
"(",
"CachedSeekableInputStream",
")",
"inputStream",
")",
".",
"getFileId",
"(",
")",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"The resource {} is already expired\"",
",",
"(",
"(",
"CachedSeekableInputStream",
")",
"inputStream",
")",
".",
"getResourceId",
"(",
")",
")",
";",
"// the cache no longer tracks this input stream",
"inputStream",
".",
"close",
"(",
")",
";",
"return",
";",
"}",
"UfsInputStreamIdSet",
"resources",
"=",
"mFileIdToInputStreamIds",
".",
"get",
"(",
"(",
"(",
"CachedSeekableInputStream",
")",
"inputStream",
")",
".",
"getFileId",
"(",
")",
")",
";",
"if",
"(",
"!",
"resources",
".",
"release",
"(",
"(",
"(",
"CachedSeekableInputStream",
")",
"inputStream",
")",
".",
"getResourceId",
"(",
")",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Close the expired input stream resource of {}\"",
",",
"(",
"(",
"CachedSeekableInputStream",
")",
"inputStream",
")",
".",
"getResourceId",
"(",
")",
")",
";",
"// the input stream expired, close it",
"inputStream",
".",
"close",
"(",
")",
";",
"}",
"}",
"}"
] |
Releases an input stream. The input stream is closed if it's already expired.
@param inputStream the input stream to release
@throws IOException when input stream fails to close
|
[
"Releases",
"an",
"input",
"stream",
".",
"The",
"input",
"stream",
"is",
"closed",
"if",
"it",
"s",
"already",
"expired",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/UfsInputStreamManager.java#L134-L159
|
18,551
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/UfsInputStreamManager.java
|
UfsInputStreamManager.invalidate
|
public void invalidate(CachedSeekableInputStream inputStream) throws IOException {
mUnderFileInputStreamCache.invalidate(inputStream.getResourceId());
release(inputStream);
}
|
java
|
public void invalidate(CachedSeekableInputStream inputStream) throws IOException {
mUnderFileInputStreamCache.invalidate(inputStream.getResourceId());
release(inputStream);
}
|
[
"public",
"void",
"invalidate",
"(",
"CachedSeekableInputStream",
"inputStream",
")",
"throws",
"IOException",
"{",
"mUnderFileInputStreamCache",
".",
"invalidate",
"(",
"inputStream",
".",
"getResourceId",
"(",
")",
")",
";",
"release",
"(",
"inputStream",
")",
";",
"}"
] |
Invalidates an input stream from the cache.
@param inputStream the cached input stream
@throws IOException when the invalidated input stream fails to release
|
[
"Invalidates",
"an",
"input",
"stream",
"from",
"the",
"cache",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/UfsInputStreamManager.java#L167-L170
|
18,552
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/UfsInputStreamManager.java
|
UfsInputStreamManager.acquire
|
public InputStream acquire(UnderFileSystem ufs, String path, long fileId, OpenOptions openOptions)
throws IOException {
return acquire(ufs, path, fileId, openOptions, true);
}
|
java
|
public InputStream acquire(UnderFileSystem ufs, String path, long fileId, OpenOptions openOptions)
throws IOException {
return acquire(ufs, path, fileId, openOptions, true);
}
|
[
"public",
"InputStream",
"acquire",
"(",
"UnderFileSystem",
"ufs",
",",
"String",
"path",
",",
"long",
"fileId",
",",
"OpenOptions",
"openOptions",
")",
"throws",
"IOException",
"{",
"return",
"acquire",
"(",
"ufs",
",",
"path",
",",
"fileId",
",",
"openOptions",
",",
"true",
")",
";",
"}"
] |
Acquires an input stream. For seekable input streams, if there is an available input stream in
the cache, reuse it and repositions the offset, otherwise the manager opens a new input stream.
@param ufs the under file system
@param path the path to the under storage file
@param fileId the file id
@param openOptions the open options
@return the acquired input stream
@throws IOException if the input stream fails to open
|
[
"Acquires",
"an",
"input",
"stream",
".",
"For",
"seekable",
"input",
"streams",
"if",
"there",
"is",
"an",
"available",
"input",
"stream",
"in",
"the",
"cache",
"reuse",
"it",
"and",
"repositions",
"the",
"offset",
"otherwise",
"the",
"manager",
"opens",
"a",
"new",
"input",
"stream",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/UfsInputStreamManager.java#L183-L186
|
18,553
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/UfsInputStreamManager.java
|
UfsInputStreamManager.acquire
|
public InputStream acquire(UnderFileSystem ufs, String path, long fileId, OpenOptions openOptions,
boolean reuse) throws IOException {
if (!ufs.isSeekable() || !CACHE_ENABLED) {
// not able to cache, always return a new input stream
return ufs.openExistingFile(path, openOptions);
}
// explicit cache cleanup
mUnderFileInputStreamCache.cleanUp();
UfsInputStreamIdSet resources;
synchronized (mFileIdToInputStreamIds) {
if (mFileIdToInputStreamIds.containsKey(fileId)) {
resources = mFileIdToInputStreamIds.get(fileId);
} else {
resources = new UfsInputStreamIdSet();
mFileIdToInputStreamIds.put(fileId, resources);
}
}
synchronized (resources) {
long nextId = UNAVAILABLE_RESOURCE_ID;
CachedSeekableInputStream inputStream = null;
if (reuse) {
// find the next available input stream from the cache
for (long id : resources.availableIds()) {
inputStream = mUnderFileInputStreamCache.getIfPresent(id);
if (inputStream != null) {
nextId = id;
LOG.debug("Reused the under file input stream resource of {}", nextId);
// for the cached ufs instream, seek to the requested position
inputStream.seek(openOptions.getOffset());
break;
}
}
}
// no cached input stream is available, open a new one
if (nextId == UNAVAILABLE_RESOURCE_ID) {
nextId = IdUtils.getRandomNonNegativeLong();
final long newId = nextId;
try {
inputStream = mUnderFileInputStreamCache.get(nextId, () -> {
SeekableUnderFileInputStream ufsStream
= (SeekableUnderFileInputStream) ufs.openExistingFile(path,
OpenOptions.defaults().setOffset(openOptions.getOffset()));
LOG.debug("Created the under file input stream resource of {}", newId);
return new CachedSeekableInputStream(ufsStream, newId, fileId, path);
});
} catch (ExecutionException e) {
LOG.warn("Failed to create a new cached ufs instream of file id {} and path {}", fileId,
path);
// fall back to a ufs creation.
return ufs.openExistingFile(path,
OpenOptions.defaults().setOffset(openOptions.getOffset()));
}
}
// mark the input stream id as acquired
resources.acquire(nextId);
return inputStream;
}
}
|
java
|
public InputStream acquire(UnderFileSystem ufs, String path, long fileId, OpenOptions openOptions,
boolean reuse) throws IOException {
if (!ufs.isSeekable() || !CACHE_ENABLED) {
// not able to cache, always return a new input stream
return ufs.openExistingFile(path, openOptions);
}
// explicit cache cleanup
mUnderFileInputStreamCache.cleanUp();
UfsInputStreamIdSet resources;
synchronized (mFileIdToInputStreamIds) {
if (mFileIdToInputStreamIds.containsKey(fileId)) {
resources = mFileIdToInputStreamIds.get(fileId);
} else {
resources = new UfsInputStreamIdSet();
mFileIdToInputStreamIds.put(fileId, resources);
}
}
synchronized (resources) {
long nextId = UNAVAILABLE_RESOURCE_ID;
CachedSeekableInputStream inputStream = null;
if (reuse) {
// find the next available input stream from the cache
for (long id : resources.availableIds()) {
inputStream = mUnderFileInputStreamCache.getIfPresent(id);
if (inputStream != null) {
nextId = id;
LOG.debug("Reused the under file input stream resource of {}", nextId);
// for the cached ufs instream, seek to the requested position
inputStream.seek(openOptions.getOffset());
break;
}
}
}
// no cached input stream is available, open a new one
if (nextId == UNAVAILABLE_RESOURCE_ID) {
nextId = IdUtils.getRandomNonNegativeLong();
final long newId = nextId;
try {
inputStream = mUnderFileInputStreamCache.get(nextId, () -> {
SeekableUnderFileInputStream ufsStream
= (SeekableUnderFileInputStream) ufs.openExistingFile(path,
OpenOptions.defaults().setOffset(openOptions.getOffset()));
LOG.debug("Created the under file input stream resource of {}", newId);
return new CachedSeekableInputStream(ufsStream, newId, fileId, path);
});
} catch (ExecutionException e) {
LOG.warn("Failed to create a new cached ufs instream of file id {} and path {}", fileId,
path);
// fall back to a ufs creation.
return ufs.openExistingFile(path,
OpenOptions.defaults().setOffset(openOptions.getOffset()));
}
}
// mark the input stream id as acquired
resources.acquire(nextId);
return inputStream;
}
}
|
[
"public",
"InputStream",
"acquire",
"(",
"UnderFileSystem",
"ufs",
",",
"String",
"path",
",",
"long",
"fileId",
",",
"OpenOptions",
"openOptions",
",",
"boolean",
"reuse",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"ufs",
".",
"isSeekable",
"(",
")",
"||",
"!",
"CACHE_ENABLED",
")",
"{",
"// not able to cache, always return a new input stream",
"return",
"ufs",
".",
"openExistingFile",
"(",
"path",
",",
"openOptions",
")",
";",
"}",
"// explicit cache cleanup",
"mUnderFileInputStreamCache",
".",
"cleanUp",
"(",
")",
";",
"UfsInputStreamIdSet",
"resources",
";",
"synchronized",
"(",
"mFileIdToInputStreamIds",
")",
"{",
"if",
"(",
"mFileIdToInputStreamIds",
".",
"containsKey",
"(",
"fileId",
")",
")",
"{",
"resources",
"=",
"mFileIdToInputStreamIds",
".",
"get",
"(",
"fileId",
")",
";",
"}",
"else",
"{",
"resources",
"=",
"new",
"UfsInputStreamIdSet",
"(",
")",
";",
"mFileIdToInputStreamIds",
".",
"put",
"(",
"fileId",
",",
"resources",
")",
";",
"}",
"}",
"synchronized",
"(",
"resources",
")",
"{",
"long",
"nextId",
"=",
"UNAVAILABLE_RESOURCE_ID",
";",
"CachedSeekableInputStream",
"inputStream",
"=",
"null",
";",
"if",
"(",
"reuse",
")",
"{",
"// find the next available input stream from the cache",
"for",
"(",
"long",
"id",
":",
"resources",
".",
"availableIds",
"(",
")",
")",
"{",
"inputStream",
"=",
"mUnderFileInputStreamCache",
".",
"getIfPresent",
"(",
"id",
")",
";",
"if",
"(",
"inputStream",
"!=",
"null",
")",
"{",
"nextId",
"=",
"id",
";",
"LOG",
".",
"debug",
"(",
"\"Reused the under file input stream resource of {}\"",
",",
"nextId",
")",
";",
"// for the cached ufs instream, seek to the requested position",
"inputStream",
".",
"seek",
"(",
"openOptions",
".",
"getOffset",
"(",
")",
")",
";",
"break",
";",
"}",
"}",
"}",
"// no cached input stream is available, open a new one",
"if",
"(",
"nextId",
"==",
"UNAVAILABLE_RESOURCE_ID",
")",
"{",
"nextId",
"=",
"IdUtils",
".",
"getRandomNonNegativeLong",
"(",
")",
";",
"final",
"long",
"newId",
"=",
"nextId",
";",
"try",
"{",
"inputStream",
"=",
"mUnderFileInputStreamCache",
".",
"get",
"(",
"nextId",
",",
"(",
")",
"->",
"{",
"SeekableUnderFileInputStream",
"ufsStream",
"=",
"(",
"SeekableUnderFileInputStream",
")",
"ufs",
".",
"openExistingFile",
"(",
"path",
",",
"OpenOptions",
".",
"defaults",
"(",
")",
".",
"setOffset",
"(",
"openOptions",
".",
"getOffset",
"(",
")",
")",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Created the under file input stream resource of {}\"",
",",
"newId",
")",
";",
"return",
"new",
"CachedSeekableInputStream",
"(",
"ufsStream",
",",
"newId",
",",
"fileId",
",",
"path",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to create a new cached ufs instream of file id {} and path {}\"",
",",
"fileId",
",",
"path",
")",
";",
"// fall back to a ufs creation.",
"return",
"ufs",
".",
"openExistingFile",
"(",
"path",
",",
"OpenOptions",
".",
"defaults",
"(",
")",
".",
"setOffset",
"(",
"openOptions",
".",
"getOffset",
"(",
")",
")",
")",
";",
"}",
"}",
"// mark the input stream id as acquired",
"resources",
".",
"acquire",
"(",
"nextId",
")",
";",
"return",
"inputStream",
";",
"}",
"}"
] |
Acquires an input stream. For seekable input streams, if there is an available input stream in
the cache and reuse mode is specified, reuse it and repositions the offset, otherwise the
manager opens a new input stream.
@param ufs the under file system
@param path the path to the under storage file
@param fileId the file id
@param openOptions the open options
@param reuse true to reuse existing input stream, otherwise acquire a new stream
@return the acquired input stream
@throws IOException if the input stream fails to open
|
[
"Acquires",
"an",
"input",
"stream",
".",
"For",
"seekable",
"input",
"streams",
"if",
"there",
"is",
"an",
"available",
"input",
"stream",
"in",
"the",
"cache",
"and",
"reuse",
"mode",
"is",
"specified",
"reuse",
"it",
"and",
"repositions",
"the",
"offset",
"otherwise",
"the",
"manager",
"opens",
"a",
"new",
"input",
"stream",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/UfsInputStreamManager.java#L201-L262
|
18,554
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/MetaMasterSync.java
|
MetaMasterSync.heartbeat
|
@Override
public void heartbeat() {
MetaCommand command = null;
try {
if (mMasterId.get() == UNINITIALIZED_MASTER_ID) {
setIdAndRegister();
}
command = mMasterClient.heartbeat(mMasterId.get());
handleCommand(command);
} catch (IOException e) {
// An error occurred, log and ignore it or error if heartbeat timeout is reached
if (command == null) {
LOG.error("Failed to receive leader master heartbeat command.", e);
} else {
LOG.error("Failed to execute leader master heartbeat command: {}", command, e);
}
mMasterClient.disconnect();
}
}
|
java
|
@Override
public void heartbeat() {
MetaCommand command = null;
try {
if (mMasterId.get() == UNINITIALIZED_MASTER_ID) {
setIdAndRegister();
}
command = mMasterClient.heartbeat(mMasterId.get());
handleCommand(command);
} catch (IOException e) {
// An error occurred, log and ignore it or error if heartbeat timeout is reached
if (command == null) {
LOG.error("Failed to receive leader master heartbeat command.", e);
} else {
LOG.error("Failed to execute leader master heartbeat command: {}", command, e);
}
mMasterClient.disconnect();
}
}
|
[
"@",
"Override",
"public",
"void",
"heartbeat",
"(",
")",
"{",
"MetaCommand",
"command",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"mMasterId",
".",
"get",
"(",
")",
"==",
"UNINITIALIZED_MASTER_ID",
")",
"{",
"setIdAndRegister",
"(",
")",
";",
"}",
"command",
"=",
"mMasterClient",
".",
"heartbeat",
"(",
"mMasterId",
".",
"get",
"(",
")",
")",
";",
"handleCommand",
"(",
"command",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// An error occurred, log and ignore it or error if heartbeat timeout is reached",
"if",
"(",
"command",
"==",
"null",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to receive leader master heartbeat command.\"",
",",
"e",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to execute leader master heartbeat command: {}\"",
",",
"command",
",",
"e",
")",
";",
"}",
"mMasterClient",
".",
"disconnect",
"(",
")",
";",
"}",
"}"
] |
Heartbeats to the leader master node.
|
[
"Heartbeats",
"to",
"the",
"leader",
"master",
"node",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/MetaMasterSync.java#L66-L84
|
18,555
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/MetaMasterSync.java
|
MetaMasterSync.handleCommand
|
private void handleCommand(MetaCommand cmd) throws IOException {
if (cmd == null) {
return;
}
switch (cmd) {
case MetaCommand_Nothing:
break;
// Leader master requests re-registration
case MetaCommand_Register:
setIdAndRegister();
break;
// Unknown request
case MetaCommand_Unknown:
LOG.error("Master heartbeat sends unknown command {}", cmd);
break;
default:
throw new RuntimeException("Un-recognized command from leader master " + cmd);
}
}
|
java
|
private void handleCommand(MetaCommand cmd) throws IOException {
if (cmd == null) {
return;
}
switch (cmd) {
case MetaCommand_Nothing:
break;
// Leader master requests re-registration
case MetaCommand_Register:
setIdAndRegister();
break;
// Unknown request
case MetaCommand_Unknown:
LOG.error("Master heartbeat sends unknown command {}", cmd);
break;
default:
throw new RuntimeException("Un-recognized command from leader master " + cmd);
}
}
|
[
"private",
"void",
"handleCommand",
"(",
"MetaCommand",
"cmd",
")",
"throws",
"IOException",
"{",
"if",
"(",
"cmd",
"==",
"null",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"cmd",
")",
"{",
"case",
"MetaCommand_Nothing",
":",
"break",
";",
"// Leader master requests re-registration",
"case",
"MetaCommand_Register",
":",
"setIdAndRegister",
"(",
")",
";",
"break",
";",
"// Unknown request",
"case",
"MetaCommand_Unknown",
":",
"LOG",
".",
"error",
"(",
"\"Master heartbeat sends unknown command {}\"",
",",
"cmd",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"RuntimeException",
"(",
"\"Un-recognized command from leader master \"",
"+",
"cmd",
")",
";",
"}",
"}"
] |
Handles a leader master command.
@param cmd the command to execute
|
[
"Handles",
"a",
"leader",
"master",
"command",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/MetaMasterSync.java#L91-L109
|
18,556
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/MetaMasterSync.java
|
MetaMasterSync.setIdAndRegister
|
private void setIdAndRegister() throws IOException {
mMasterId.set(mMasterClient.getId(mMasterAddress));
mMasterClient.register(mMasterId.get(),
ConfigurationUtils.getConfiguration(ServerConfiguration.global(), Scope.MASTER));
}
|
java
|
private void setIdAndRegister() throws IOException {
mMasterId.set(mMasterClient.getId(mMasterAddress));
mMasterClient.register(mMasterId.get(),
ConfigurationUtils.getConfiguration(ServerConfiguration.global(), Scope.MASTER));
}
|
[
"private",
"void",
"setIdAndRegister",
"(",
")",
"throws",
"IOException",
"{",
"mMasterId",
".",
"set",
"(",
"mMasterClient",
".",
"getId",
"(",
"mMasterAddress",
")",
")",
";",
"mMasterClient",
".",
"register",
"(",
"mMasterId",
".",
"get",
"(",
")",
",",
"ConfigurationUtils",
".",
"getConfiguration",
"(",
"ServerConfiguration",
".",
"global",
"(",
")",
",",
"Scope",
".",
"MASTER",
")",
")",
";",
"}"
] |
Sets the master id and registers with the Alluxio leader master.
|
[
"Sets",
"the",
"master",
"id",
"and",
"registers",
"with",
"the",
"Alluxio",
"leader",
"master",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/MetaMasterSync.java#L114-L118
|
18,557
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/allocator/MaxFreeAllocator.java
|
MaxFreeAllocator.getCandidateDirInTier
|
private StorageDirView getCandidateDirInTier(StorageTierView tierView, long blockSize) {
StorageDirView candidateDirView = null;
long maxFreeBytes = blockSize - 1;
for (StorageDirView dirView : tierView.getDirViews()) {
if (dirView.getAvailableBytes() > maxFreeBytes) {
maxFreeBytes = dirView.getAvailableBytes();
candidateDirView = dirView;
}
}
return candidateDirView;
}
|
java
|
private StorageDirView getCandidateDirInTier(StorageTierView tierView, long blockSize) {
StorageDirView candidateDirView = null;
long maxFreeBytes = blockSize - 1;
for (StorageDirView dirView : tierView.getDirViews()) {
if (dirView.getAvailableBytes() > maxFreeBytes) {
maxFreeBytes = dirView.getAvailableBytes();
candidateDirView = dirView;
}
}
return candidateDirView;
}
|
[
"private",
"StorageDirView",
"getCandidateDirInTier",
"(",
"StorageTierView",
"tierView",
",",
"long",
"blockSize",
")",
"{",
"StorageDirView",
"candidateDirView",
"=",
"null",
";",
"long",
"maxFreeBytes",
"=",
"blockSize",
"-",
"1",
";",
"for",
"(",
"StorageDirView",
"dirView",
":",
"tierView",
".",
"getDirViews",
"(",
")",
")",
"{",
"if",
"(",
"dirView",
".",
"getAvailableBytes",
"(",
")",
">",
"maxFreeBytes",
")",
"{",
"maxFreeBytes",
"=",
"dirView",
".",
"getAvailableBytes",
"(",
")",
";",
"candidateDirView",
"=",
"dirView",
";",
"}",
"}",
"return",
"candidateDirView",
";",
"}"
] |
Finds a directory view in a tier view that has max free space and is able to store the block.
@param tierView the storage tier view
@param blockSize the size of block in bytes
@return the storage directory view if found, null otherwise
|
[
"Finds",
"a",
"directory",
"view",
"in",
"a",
"tier",
"view",
"that",
"has",
"max",
"free",
"space",
"and",
"is",
"able",
"to",
"store",
"the",
"block",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/allocator/MaxFreeAllocator.java#L91-L101
|
18,558
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/meta/StorageTier.java
|
StorageTier.removeStorageDir
|
public void removeStorageDir(StorageDir dir) {
if (mDirs.remove(dir)) {
mCapacityBytes -= dir.getCapacityBytes();
}
mLostStorage.add(dir.getDirPath());
}
|
java
|
public void removeStorageDir(StorageDir dir) {
if (mDirs.remove(dir)) {
mCapacityBytes -= dir.getCapacityBytes();
}
mLostStorage.add(dir.getDirPath());
}
|
[
"public",
"void",
"removeStorageDir",
"(",
"StorageDir",
"dir",
")",
"{",
"if",
"(",
"mDirs",
".",
"remove",
"(",
"dir",
")",
")",
"{",
"mCapacityBytes",
"-=",
"dir",
".",
"getCapacityBytes",
"(",
")",
";",
"}",
"mLostStorage",
".",
"add",
"(",
"dir",
".",
"getDirPath",
"(",
")",
")",
";",
"}"
] |
Removes a directory.
@param dir directory to be removed
|
[
"Removes",
"a",
"directory",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/meta/StorageTier.java#L245-L250
|
18,559
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/RestUtils.java
|
RestUtils.call
|
public static <T> Response call(RestUtils.RestCallable<T> callable,
AlluxioConfiguration alluxioConf) {
return call(callable, alluxioConf, null);
}
|
java
|
public static <T> Response call(RestUtils.RestCallable<T> callable,
AlluxioConfiguration alluxioConf) {
return call(callable, alluxioConf, null);
}
|
[
"public",
"static",
"<",
"T",
">",
"Response",
"call",
"(",
"RestUtils",
".",
"RestCallable",
"<",
"T",
">",
"callable",
",",
"AlluxioConfiguration",
"alluxioConf",
")",
"{",
"return",
"call",
"(",
"callable",
",",
"alluxioConf",
",",
"null",
")",
";",
"}"
] |
Call response.
@param <T> the type parameter
@param callable the callable
@param alluxioConf the alluxio conf
@return the response
|
[
"Call",
"response",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/RestUtils.java#L77-L80
|
18,560
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/RestUtils.java
|
RestUtils.makeCORS
|
public static Response.ResponseBuilder makeCORS(Response.ResponseBuilder responseBuilder,
String returnMethod) {
// TODO(william): Make origin, methods, and headers configurable.
Response.ResponseBuilder rb = responseBuilder.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
if (!"".equals(returnMethod)) {
rb.header("Access-Control-Allow-Headers", returnMethod);
}
return rb;
}
|
java
|
public static Response.ResponseBuilder makeCORS(Response.ResponseBuilder responseBuilder,
String returnMethod) {
// TODO(william): Make origin, methods, and headers configurable.
Response.ResponseBuilder rb = responseBuilder.header("Access-Control-Allow-Origin", "*")
.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
if (!"".equals(returnMethod)) {
rb.header("Access-Control-Allow-Headers", returnMethod);
}
return rb;
}
|
[
"public",
"static",
"Response",
".",
"ResponseBuilder",
"makeCORS",
"(",
"Response",
".",
"ResponseBuilder",
"responseBuilder",
",",
"String",
"returnMethod",
")",
"{",
"// TODO(william): Make origin, methods, and headers configurable.",
"Response",
".",
"ResponseBuilder",
"rb",
"=",
"responseBuilder",
".",
"header",
"(",
"\"Access-Control-Allow-Origin\"",
",",
"\"*\"",
")",
".",
"header",
"(",
"\"Access-Control-Allow-Methods\"",
",",
"\"GET, POST, OPTIONS\"",
")",
";",
"if",
"(",
"!",
"\"\"",
".",
"equals",
"(",
"returnMethod",
")",
")",
"{",
"rb",
".",
"header",
"(",
"\"Access-Control-Allow-Headers\"",
",",
"returnMethod",
")",
";",
"}",
"return",
"rb",
";",
"}"
] |
Makes the responseBuilder CORS compatible.
@param responseBuilder the response builder
@param returnMethod the modified response builder
@return response builder
|
[
"Makes",
"the",
"responseBuilder",
"CORS",
"compatible",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/RestUtils.java#L193-L204
|
18,561
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/LocalAlluxioJobCluster.java
|
LocalAlluxioJobCluster.startMaster
|
private void startMaster() throws IOException, ConnectionFailedException {
mMaster = AlluxioJobMasterProcess.Factory.create();
ServerConfiguration
.set(PropertyKey.JOB_MASTER_RPC_PORT, String.valueOf(mMaster.getRpcAddress().getPort()));
Runnable runMaster = new Runnable() {
@Override
public void run() {
try {
mMaster.start();
} catch (Exception e) {
throw new RuntimeException(e + " \n Start Master Error \n" + e.getMessage(), e);
}
}
};
mMasterThread = new Thread(runMaster);
mMasterThread.start();
}
|
java
|
private void startMaster() throws IOException, ConnectionFailedException {
mMaster = AlluxioJobMasterProcess.Factory.create();
ServerConfiguration
.set(PropertyKey.JOB_MASTER_RPC_PORT, String.valueOf(mMaster.getRpcAddress().getPort()));
Runnable runMaster = new Runnable() {
@Override
public void run() {
try {
mMaster.start();
} catch (Exception e) {
throw new RuntimeException(e + " \n Start Master Error \n" + e.getMessage(), e);
}
}
};
mMasterThread = new Thread(runMaster);
mMasterThread.start();
}
|
[
"private",
"void",
"startMaster",
"(",
")",
"throws",
"IOException",
",",
"ConnectionFailedException",
"{",
"mMaster",
"=",
"AlluxioJobMasterProcess",
".",
"Factory",
".",
"create",
"(",
")",
";",
"ServerConfiguration",
".",
"set",
"(",
"PropertyKey",
".",
"JOB_MASTER_RPC_PORT",
",",
"String",
".",
"valueOf",
"(",
"mMaster",
".",
"getRpcAddress",
"(",
")",
".",
"getPort",
"(",
")",
")",
")",
";",
"Runnable",
"runMaster",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"mMaster",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
"+",
"\" \\n Start Master Error \\n\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
";",
"mMasterThread",
"=",
"new",
"Thread",
"(",
"runMaster",
")",
";",
"mMasterThread",
".",
"start",
"(",
")",
";",
"}"
] |
Runs a master.
@throws IOException if an I/O error occurs
@throws ConnectionFailedException if network connection failed
|
[
"Runs",
"a",
"master",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/LocalAlluxioJobCluster.java#L154-L171
|
18,562
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/LocalAlluxioJobCluster.java
|
LocalAlluxioJobCluster.startWorker
|
private void startWorker() throws IOException, ConnectionFailedException {
mWorker = JobWorkerProcess.Factory.create();
Runnable runWorker = new Runnable() {
@Override
public void run() {
try {
mWorker.start();
} catch (Exception e) {
throw new RuntimeException(e + " \n Start Worker Error \n" + e.getMessage(), e);
}
}
};
mWorkerThread = new Thread(runWorker);
mWorkerThread.start();
}
|
java
|
private void startWorker() throws IOException, ConnectionFailedException {
mWorker = JobWorkerProcess.Factory.create();
Runnable runWorker = new Runnable() {
@Override
public void run() {
try {
mWorker.start();
} catch (Exception e) {
throw new RuntimeException(e + " \n Start Worker Error \n" + e.getMessage(), e);
}
}
};
mWorkerThread = new Thread(runWorker);
mWorkerThread.start();
}
|
[
"private",
"void",
"startWorker",
"(",
")",
"throws",
"IOException",
",",
"ConnectionFailedException",
"{",
"mWorker",
"=",
"JobWorkerProcess",
".",
"Factory",
".",
"create",
"(",
")",
";",
"Runnable",
"runWorker",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"mWorker",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
"+",
"\" \\n Start Worker Error \\n\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
";",
"mWorkerThread",
"=",
"new",
"Thread",
"(",
"runWorker",
")",
";",
"mWorkerThread",
".",
"start",
"(",
")",
";",
"}"
] |
Runs a worker.
@throws IOException if an I/O error occurs
@throws ConnectionFailedException if network connection failed
|
[
"Runs",
"a",
"worker",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/LocalAlluxioJobCluster.java#L179-L193
|
18,563
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/security/authorization/ExtendedACLEntries.java
|
ExtendedACLEntries.setEntry
|
public void setEntry(AclEntry entry) {
// TODO(cc): when setting non-mask entries, the mask should be dynamically updated too.
switch (entry.getType()) {
case NAMED_USER:
mNamedUserActions.put(entry.getSubject(), entry.getActions());
return;
case NAMED_GROUP:
mNamedGroupActions.put(entry.getSubject(), entry.getActions());
return;
case MASK:
mMaskActions = entry.getActions();
return;
case OWNING_USER: // fall through
case OWNING_GROUP: // fall through
case OTHER:
throw new IllegalStateException(
"Deleting base entry is not allowed. entry: " + entry);
default:
throw new IllegalStateException("Unknown ACL entry type: " + entry.getType());
}
}
|
java
|
public void setEntry(AclEntry entry) {
// TODO(cc): when setting non-mask entries, the mask should be dynamically updated too.
switch (entry.getType()) {
case NAMED_USER:
mNamedUserActions.put(entry.getSubject(), entry.getActions());
return;
case NAMED_GROUP:
mNamedGroupActions.put(entry.getSubject(), entry.getActions());
return;
case MASK:
mMaskActions = entry.getActions();
return;
case OWNING_USER: // fall through
case OWNING_GROUP: // fall through
case OTHER:
throw new IllegalStateException(
"Deleting base entry is not allowed. entry: " + entry);
default:
throw new IllegalStateException("Unknown ACL entry type: " + entry.getType());
}
}
|
[
"public",
"void",
"setEntry",
"(",
"AclEntry",
"entry",
")",
"{",
"// TODO(cc): when setting non-mask entries, the mask should be dynamically updated too.",
"switch",
"(",
"entry",
".",
"getType",
"(",
")",
")",
"{",
"case",
"NAMED_USER",
":",
"mNamedUserActions",
".",
"put",
"(",
"entry",
".",
"getSubject",
"(",
")",
",",
"entry",
".",
"getActions",
"(",
")",
")",
";",
"return",
";",
"case",
"NAMED_GROUP",
":",
"mNamedGroupActions",
".",
"put",
"(",
"entry",
".",
"getSubject",
"(",
")",
",",
"entry",
".",
"getActions",
"(",
")",
")",
";",
"return",
";",
"case",
"MASK",
":",
"mMaskActions",
"=",
"entry",
".",
"getActions",
"(",
")",
";",
"return",
";",
"case",
"OWNING_USER",
":",
"// fall through",
"case",
"OWNING_GROUP",
":",
"// fall through",
"case",
"OTHER",
":",
"throw",
"new",
"IllegalStateException",
"(",
"\"Deleting base entry is not allowed. entry: \"",
"+",
"entry",
")",
";",
"default",
":",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unknown ACL entry type: \"",
"+",
"entry",
".",
"getType",
"(",
")",
")",
";",
"}",
"}"
] |
Sets an entry into the access control list.
If an entry with the same type and subject already exists, overwrites the existing entry;
Otherwise, adds this new entry.
@param entry the entry to be added or updated
|
[
"Sets",
"an",
"entry",
"into",
"the",
"access",
"control",
"list",
".",
"If",
"an",
"entry",
"with",
"the",
"same",
"type",
"and",
"subject",
"already",
"exists",
"overwrites",
"the",
"existing",
"entry",
";",
"Otherwise",
"adds",
"this",
"new",
"entry",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/security/authorization/ExtendedACLEntries.java#L143-L163
|
18,564
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/security/authorization/ExtendedACLEntries.java
|
ExtendedACLEntries.updateMask
|
public void updateMask(AclActions groupActions) {
AclActions result = new AclActions(groupActions);
for (Map.Entry<String, AclActions> kv : mNamedUserActions.entrySet()) {
AclActions userAction = kv.getValue();
result.merge(userAction);
for (AclAction action : AclAction.values()) {
if (result.contains(action) || userAction.contains(action)) {
result.add(action);
}
}
}
for (Map.Entry<String, AclActions> kv : mNamedGroupActions.entrySet()) {
AclActions userAction = kv.getValue();
result.merge(userAction);
for (AclAction action : AclAction.values()) {
if (result.contains(action) || userAction.contains(action)) {
result.add(action);
}
}
}
mMaskActions = result;
}
|
java
|
public void updateMask(AclActions groupActions) {
AclActions result = new AclActions(groupActions);
for (Map.Entry<String, AclActions> kv : mNamedUserActions.entrySet()) {
AclActions userAction = kv.getValue();
result.merge(userAction);
for (AclAction action : AclAction.values()) {
if (result.contains(action) || userAction.contains(action)) {
result.add(action);
}
}
}
for (Map.Entry<String, AclActions> kv : mNamedGroupActions.entrySet()) {
AclActions userAction = kv.getValue();
result.merge(userAction);
for (AclAction action : AclAction.values()) {
if (result.contains(action) || userAction.contains(action)) {
result.add(action);
}
}
}
mMaskActions = result;
}
|
[
"public",
"void",
"updateMask",
"(",
"AclActions",
"groupActions",
")",
"{",
"AclActions",
"result",
"=",
"new",
"AclActions",
"(",
"groupActions",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"AclActions",
">",
"kv",
":",
"mNamedUserActions",
".",
"entrySet",
"(",
")",
")",
"{",
"AclActions",
"userAction",
"=",
"kv",
".",
"getValue",
"(",
")",
";",
"result",
".",
"merge",
"(",
"userAction",
")",
";",
"for",
"(",
"AclAction",
"action",
":",
"AclAction",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"result",
".",
"contains",
"(",
"action",
")",
"||",
"userAction",
".",
"contains",
"(",
"action",
")",
")",
"{",
"result",
".",
"add",
"(",
"action",
")",
";",
"}",
"}",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"AclActions",
">",
"kv",
":",
"mNamedGroupActions",
".",
"entrySet",
"(",
")",
")",
"{",
"AclActions",
"userAction",
"=",
"kv",
".",
"getValue",
"(",
")",
";",
"result",
".",
"merge",
"(",
"userAction",
")",
";",
"for",
"(",
"AclAction",
"action",
":",
"AclAction",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"result",
".",
"contains",
"(",
"action",
")",
"||",
"userAction",
".",
"contains",
"(",
"action",
")",
")",
"{",
"result",
".",
"add",
"(",
"action",
")",
";",
"}",
"}",
"}",
"mMaskActions",
"=",
"result",
";",
"}"
] |
Update the mask to be the union of owning group entry, named user entry and named group entry.
@param groupActions the group entry to be integrated into the mask
|
[
"Update",
"the",
"mask",
"to",
"be",
"the",
"union",
"of",
"owning",
"group",
"entry",
"named",
"user",
"entry",
"and",
"named",
"group",
"entry",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/security/authorization/ExtendedACLEntries.java#L192-L218
|
18,565
|
Alluxio/alluxio
|
integration/checker/src/main/java/alluxio/checker/SparkIntegrationChecker.java
|
SparkIntegrationChecker.run
|
private Status run(JavaSparkContext sc, PrintWriter reportWriter, AlluxioConfiguration conf) {
// Check whether Spark driver can recognize Alluxio classes and filesystem
Status driverStatus = CheckerUtils.performIntegrationChecks();
String driverAddress = sc.getConf().get("spark.driver.host");
switch (driverStatus) {
case FAIL_TO_FIND_CLASS:
reportWriter.printf("Spark driver: %s failed to recognize Alluxio classes.%n%n",
driverAddress);
return driverStatus;
case FAIL_TO_FIND_FS:
reportWriter.printf("Spark driver: %s failed to recognize Alluxio filesystem.%n%n",
driverAddress);
return driverStatus;
default:
reportWriter.printf("Spark driver: %s can recognize Alluxio filesystem.%n%n",
driverAddress);
break;
}
if (!CheckerUtils.supportAlluxioHA(reportWriter, conf)) {
return Status.FAIL_TO_SUPPORT_HA;
}
return runSparkJob(sc, reportWriter);
}
|
java
|
private Status run(JavaSparkContext sc, PrintWriter reportWriter, AlluxioConfiguration conf) {
// Check whether Spark driver can recognize Alluxio classes and filesystem
Status driverStatus = CheckerUtils.performIntegrationChecks();
String driverAddress = sc.getConf().get("spark.driver.host");
switch (driverStatus) {
case FAIL_TO_FIND_CLASS:
reportWriter.printf("Spark driver: %s failed to recognize Alluxio classes.%n%n",
driverAddress);
return driverStatus;
case FAIL_TO_FIND_FS:
reportWriter.printf("Spark driver: %s failed to recognize Alluxio filesystem.%n%n",
driverAddress);
return driverStatus;
default:
reportWriter.printf("Spark driver: %s can recognize Alluxio filesystem.%n%n",
driverAddress);
break;
}
if (!CheckerUtils.supportAlluxioHA(reportWriter, conf)) {
return Status.FAIL_TO_SUPPORT_HA;
}
return runSparkJob(sc, reportWriter);
}
|
[
"private",
"Status",
"run",
"(",
"JavaSparkContext",
"sc",
",",
"PrintWriter",
"reportWriter",
",",
"AlluxioConfiguration",
"conf",
")",
"{",
"// Check whether Spark driver can recognize Alluxio classes and filesystem",
"Status",
"driverStatus",
"=",
"CheckerUtils",
".",
"performIntegrationChecks",
"(",
")",
";",
"String",
"driverAddress",
"=",
"sc",
".",
"getConf",
"(",
")",
".",
"get",
"(",
"\"spark.driver.host\"",
")",
";",
"switch",
"(",
"driverStatus",
")",
"{",
"case",
"FAIL_TO_FIND_CLASS",
":",
"reportWriter",
".",
"printf",
"(",
"\"Spark driver: %s failed to recognize Alluxio classes.%n%n\"",
",",
"driverAddress",
")",
";",
"return",
"driverStatus",
";",
"case",
"FAIL_TO_FIND_FS",
":",
"reportWriter",
".",
"printf",
"(",
"\"Spark driver: %s failed to recognize Alluxio filesystem.%n%n\"",
",",
"driverAddress",
")",
";",
"return",
"driverStatus",
";",
"default",
":",
"reportWriter",
".",
"printf",
"(",
"\"Spark driver: %s can recognize Alluxio filesystem.%n%n\"",
",",
"driverAddress",
")",
";",
"break",
";",
"}",
"if",
"(",
"!",
"CheckerUtils",
".",
"supportAlluxioHA",
"(",
"reportWriter",
",",
"conf",
")",
")",
"{",
"return",
"Status",
".",
"FAIL_TO_SUPPORT_HA",
";",
"}",
"return",
"runSparkJob",
"(",
"sc",
",",
"reportWriter",
")",
";",
"}"
] |
Implements Spark with Alluxio integration checker.
@param sc current JavaSparkContext
@param reportWriter save user-facing messages to a generated file
@return performIntegrationChecks results
|
[
"Implements",
"Spark",
"with",
"Alluxio",
"integration",
"checker",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/checker/src/main/java/alluxio/checker/SparkIntegrationChecker.java#L77-L101
|
18,566
|
Alluxio/alluxio
|
integration/checker/src/main/java/alluxio/checker/SparkIntegrationChecker.java
|
SparkIntegrationChecker.runSparkJob
|
private Status runSparkJob(JavaSparkContext sc, PrintWriter reportWriter) {
// Generate a list of integer for testing
List<Integer> nums = IntStream.rangeClosed(1, mPartitions).boxed().collect(Collectors.toList());
JavaRDD<Integer> dataSet = sc.parallelize(nums, mPartitions);
// Run a Spark job to check whether Spark executors can recognize Alluxio
JavaPairRDD<Status, String> extractedStatus = dataSet
.mapToPair(s -> new Tuple2<>(CheckerUtils.performIntegrationChecks(),
CheckerUtils.getLocalAddress()));
// Merge the IP addresses that can/cannot recognize Alluxio
JavaPairRDD<Status, String> mergeStatus = extractedStatus.reduceByKey((a, b)
-> a.contains(b) ? a : (b.contains(a) ? b : a + " " + b),
(mPartitions < 10 ? 1 : mPartitions / 10));
mSparkJobResult = mergeStatus.collect();
Map<Status, List<String>> resultMap = new HashMap<>();
for (Tuple2<Status, String> op : mSparkJobResult) {
List<String> addresses = resultMap.getOrDefault(op._1, new ArrayList<>());
addresses.add(op._2);
resultMap.put(op._1, addresses);
}
return CheckerUtils.printNodesResults(resultMap, reportWriter);
}
|
java
|
private Status runSparkJob(JavaSparkContext sc, PrintWriter reportWriter) {
// Generate a list of integer for testing
List<Integer> nums = IntStream.rangeClosed(1, mPartitions).boxed().collect(Collectors.toList());
JavaRDD<Integer> dataSet = sc.parallelize(nums, mPartitions);
// Run a Spark job to check whether Spark executors can recognize Alluxio
JavaPairRDD<Status, String> extractedStatus = dataSet
.mapToPair(s -> new Tuple2<>(CheckerUtils.performIntegrationChecks(),
CheckerUtils.getLocalAddress()));
// Merge the IP addresses that can/cannot recognize Alluxio
JavaPairRDD<Status, String> mergeStatus = extractedStatus.reduceByKey((a, b)
-> a.contains(b) ? a : (b.contains(a) ? b : a + " " + b),
(mPartitions < 10 ? 1 : mPartitions / 10));
mSparkJobResult = mergeStatus.collect();
Map<Status, List<String>> resultMap = new HashMap<>();
for (Tuple2<Status, String> op : mSparkJobResult) {
List<String> addresses = resultMap.getOrDefault(op._1, new ArrayList<>());
addresses.add(op._2);
resultMap.put(op._1, addresses);
}
return CheckerUtils.printNodesResults(resultMap, reportWriter);
}
|
[
"private",
"Status",
"runSparkJob",
"(",
"JavaSparkContext",
"sc",
",",
"PrintWriter",
"reportWriter",
")",
"{",
"// Generate a list of integer for testing",
"List",
"<",
"Integer",
">",
"nums",
"=",
"IntStream",
".",
"rangeClosed",
"(",
"1",
",",
"mPartitions",
")",
".",
"boxed",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"JavaRDD",
"<",
"Integer",
">",
"dataSet",
"=",
"sc",
".",
"parallelize",
"(",
"nums",
",",
"mPartitions",
")",
";",
"// Run a Spark job to check whether Spark executors can recognize Alluxio",
"JavaPairRDD",
"<",
"Status",
",",
"String",
">",
"extractedStatus",
"=",
"dataSet",
".",
"mapToPair",
"(",
"s",
"->",
"new",
"Tuple2",
"<>",
"(",
"CheckerUtils",
".",
"performIntegrationChecks",
"(",
")",
",",
"CheckerUtils",
".",
"getLocalAddress",
"(",
")",
")",
")",
";",
"// Merge the IP addresses that can/cannot recognize Alluxio",
"JavaPairRDD",
"<",
"Status",
",",
"String",
">",
"mergeStatus",
"=",
"extractedStatus",
".",
"reduceByKey",
"(",
"(",
"a",
",",
"b",
")",
"->",
"a",
".",
"contains",
"(",
"b",
")",
"?",
"a",
":",
"(",
"b",
".",
"contains",
"(",
"a",
")",
"?",
"b",
":",
"a",
"+",
"\" \"",
"+",
"b",
")",
",",
"(",
"mPartitions",
"<",
"10",
"?",
"1",
":",
"mPartitions",
"/",
"10",
")",
")",
";",
"mSparkJobResult",
"=",
"mergeStatus",
".",
"collect",
"(",
")",
";",
"Map",
"<",
"Status",
",",
"List",
"<",
"String",
">",
">",
"resultMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Tuple2",
"<",
"Status",
",",
"String",
">",
"op",
":",
"mSparkJobResult",
")",
"{",
"List",
"<",
"String",
">",
"addresses",
"=",
"resultMap",
".",
"getOrDefault",
"(",
"op",
".",
"_1",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"addresses",
".",
"add",
"(",
"op",
".",
"_2",
")",
";",
"resultMap",
".",
"put",
"(",
"op",
".",
"_1",
",",
"addresses",
")",
";",
"}",
"return",
"CheckerUtils",
".",
"printNodesResults",
"(",
"resultMap",
",",
"reportWriter",
")",
";",
"}"
] |
Spark job to check whether Spark executors can recognize Alluxio filesystem.
@param sc current JavaSparkContext
@param reportWriter save user-facing messages to a generated file
@return Spark job result
|
[
"Spark",
"job",
"to",
"check",
"whether",
"Spark",
"executors",
"can",
"recognize",
"Alluxio",
"filesystem",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/checker/src/main/java/alluxio/checker/SparkIntegrationChecker.java#L110-L136
|
18,567
|
Alluxio/alluxio
|
integration/checker/src/main/java/alluxio/checker/SparkIntegrationChecker.java
|
SparkIntegrationChecker.printConfigInfo
|
private void printConfigInfo(SparkConf conf, PrintWriter reportWriter) {
// Get Spark configurations
if (conf.contains("spark.master")) {
reportWriter.printf("Spark master is: %s.%n%n", conf.get("spark.master"));
}
if (conf.contains("spark.submit.deployMode")) {
reportWriter.printf("spark-submit deploy mode is: %s.%n%n",
conf.get("spark.submit.deployMode"));
}
if (conf.contains("spark.driver.extraClassPath")) {
reportWriter.printf("spark.driver.extraClassPath includes jar paths: %s.%n%n",
conf.get("spark.driver.extraClassPath"));
}
if (conf.contains("spark.executor.extraClassPath")) {
reportWriter.printf("spark.executor.extraClassPath includes jar paths: %s.%n%n",
conf.get("spark.executor.extraClassPath"));
}
}
|
java
|
private void printConfigInfo(SparkConf conf, PrintWriter reportWriter) {
// Get Spark configurations
if (conf.contains("spark.master")) {
reportWriter.printf("Spark master is: %s.%n%n", conf.get("spark.master"));
}
if (conf.contains("spark.submit.deployMode")) {
reportWriter.printf("spark-submit deploy mode is: %s.%n%n",
conf.get("spark.submit.deployMode"));
}
if (conf.contains("spark.driver.extraClassPath")) {
reportWriter.printf("spark.driver.extraClassPath includes jar paths: %s.%n%n",
conf.get("spark.driver.extraClassPath"));
}
if (conf.contains("spark.executor.extraClassPath")) {
reportWriter.printf("spark.executor.extraClassPath includes jar paths: %s.%n%n",
conf.get("spark.executor.extraClassPath"));
}
}
|
[
"private",
"void",
"printConfigInfo",
"(",
"SparkConf",
"conf",
",",
"PrintWriter",
"reportWriter",
")",
"{",
"// Get Spark configurations",
"if",
"(",
"conf",
".",
"contains",
"(",
"\"spark.master\"",
")",
")",
"{",
"reportWriter",
".",
"printf",
"(",
"\"Spark master is: %s.%n%n\"",
",",
"conf",
".",
"get",
"(",
"\"spark.master\"",
")",
")",
";",
"}",
"if",
"(",
"conf",
".",
"contains",
"(",
"\"spark.submit.deployMode\"",
")",
")",
"{",
"reportWriter",
".",
"printf",
"(",
"\"spark-submit deploy mode is: %s.%n%n\"",
",",
"conf",
".",
"get",
"(",
"\"spark.submit.deployMode\"",
")",
")",
";",
"}",
"if",
"(",
"conf",
".",
"contains",
"(",
"\"spark.driver.extraClassPath\"",
")",
")",
"{",
"reportWriter",
".",
"printf",
"(",
"\"spark.driver.extraClassPath includes jar paths: %s.%n%n\"",
",",
"conf",
".",
"get",
"(",
"\"spark.driver.extraClassPath\"",
")",
")",
";",
"}",
"if",
"(",
"conf",
".",
"contains",
"(",
"\"spark.executor.extraClassPath\"",
")",
")",
"{",
"reportWriter",
".",
"printf",
"(",
"\"spark.executor.extraClassPath includes jar paths: %s.%n%n\"",
",",
"conf",
".",
"get",
"(",
"\"spark.executor.extraClassPath\"",
")",
")",
";",
"}",
"}"
] |
Saves related Spark and Alluxio configuration information.
@param conf the current SparkConf
@param reportWriter save user-facing messages to a generated file
|
[
"Saves",
"related",
"Spark",
"and",
"Alluxio",
"configuration",
"information",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/checker/src/main/java/alluxio/checker/SparkIntegrationChecker.java#L144-L161
|
18,568
|
Alluxio/alluxio
|
integration/checker/src/main/java/alluxio/checker/SparkIntegrationChecker.java
|
SparkIntegrationChecker.printResultInfo
|
private void printResultInfo(Status resultStatus, PrintWriter reportWriter) {
switch (resultStatus) {
case FAIL_TO_FIND_CLASS:
reportWriter.println(FAIL_TO_FIND_CLASS_MESSAGE);
reportWriter.println(TEST_FAILED_MESSAGE);
break;
case FAIL_TO_FIND_FS:
reportWriter.println(FAIL_TO_FIND_FS_MESSAGE);
reportWriter.println(TEST_FAILED_MESSAGE);
break;
case FAIL_TO_SUPPORT_HA:
reportWriter.println(FAIL_TO_SUPPORT_HA_MESSAGE);
reportWriter.println(TEST_FAILED_MESSAGE);
break;
default:
reportWriter.println(TEST_PASSED_MESSAGE);
break;
}
}
|
java
|
private void printResultInfo(Status resultStatus, PrintWriter reportWriter) {
switch (resultStatus) {
case FAIL_TO_FIND_CLASS:
reportWriter.println(FAIL_TO_FIND_CLASS_MESSAGE);
reportWriter.println(TEST_FAILED_MESSAGE);
break;
case FAIL_TO_FIND_FS:
reportWriter.println(FAIL_TO_FIND_FS_MESSAGE);
reportWriter.println(TEST_FAILED_MESSAGE);
break;
case FAIL_TO_SUPPORT_HA:
reportWriter.println(FAIL_TO_SUPPORT_HA_MESSAGE);
reportWriter.println(TEST_FAILED_MESSAGE);
break;
default:
reportWriter.println(TEST_PASSED_MESSAGE);
break;
}
}
|
[
"private",
"void",
"printResultInfo",
"(",
"Status",
"resultStatus",
",",
"PrintWriter",
"reportWriter",
")",
"{",
"switch",
"(",
"resultStatus",
")",
"{",
"case",
"FAIL_TO_FIND_CLASS",
":",
"reportWriter",
".",
"println",
"(",
"FAIL_TO_FIND_CLASS_MESSAGE",
")",
";",
"reportWriter",
".",
"println",
"(",
"TEST_FAILED_MESSAGE",
")",
";",
"break",
";",
"case",
"FAIL_TO_FIND_FS",
":",
"reportWriter",
".",
"println",
"(",
"FAIL_TO_FIND_FS_MESSAGE",
")",
";",
"reportWriter",
".",
"println",
"(",
"TEST_FAILED_MESSAGE",
")",
";",
"break",
";",
"case",
"FAIL_TO_SUPPORT_HA",
":",
"reportWriter",
".",
"println",
"(",
"FAIL_TO_SUPPORT_HA_MESSAGE",
")",
";",
"reportWriter",
".",
"println",
"(",
"TEST_FAILED_MESSAGE",
")",
";",
"break",
";",
"default",
":",
"reportWriter",
".",
"println",
"(",
"TEST_PASSED_MESSAGE",
")",
";",
"break",
";",
"}",
"}"
] |
Saves Spark with Alluixo integration checker results.
@param resultStatus Spark job result status
@param reportWriter save user-facing messages to a generated file
|
[
"Saves",
"Spark",
"with",
"Alluixo",
"integration",
"checker",
"results",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/checker/src/main/java/alluxio/checker/SparkIntegrationChecker.java#L169-L187
|
18,569
|
Alluxio/alluxio
|
integration/checker/src/main/java/alluxio/checker/SparkIntegrationChecker.java
|
SparkIntegrationChecker.main
|
public static void main(String[] args) throws Exception {
AlluxioConfiguration alluxioConf = new InstancedConfiguration(ConfigurationUtils.defaults());
SparkIntegrationChecker checker = new SparkIntegrationChecker();
JCommander jCommander = new JCommander(checker, args);
jCommander.setProgramName("SparkIntegrationChecker");
// Create a file to save user-facing messages
try (PrintWriter reportWriter = CheckerUtils.initReportFile()) {
// Start the Java Spark Context
SparkConf conf = new SparkConf().setAppName(SparkIntegrationChecker.class.getName());
JavaSparkContext sc = new JavaSparkContext(conf);
checker.printConfigInfo(conf, reportWriter);
Status resultStatus = checker.run(sc, reportWriter, alluxioConf);
checker.printResultInfo(resultStatus, reportWriter);
reportWriter.flush();
System.exit(resultStatus.equals(Status.SUCCESS) ? 0 : 1);
}
}
|
java
|
public static void main(String[] args) throws Exception {
AlluxioConfiguration alluxioConf = new InstancedConfiguration(ConfigurationUtils.defaults());
SparkIntegrationChecker checker = new SparkIntegrationChecker();
JCommander jCommander = new JCommander(checker, args);
jCommander.setProgramName("SparkIntegrationChecker");
// Create a file to save user-facing messages
try (PrintWriter reportWriter = CheckerUtils.initReportFile()) {
// Start the Java Spark Context
SparkConf conf = new SparkConf().setAppName(SparkIntegrationChecker.class.getName());
JavaSparkContext sc = new JavaSparkContext(conf);
checker.printConfigInfo(conf, reportWriter);
Status resultStatus = checker.run(sc, reportWriter, alluxioConf);
checker.printResultInfo(resultStatus, reportWriter);
reportWriter.flush();
System.exit(resultStatus.equals(Status.SUCCESS) ? 0 : 1);
}
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"AlluxioConfiguration",
"alluxioConf",
"=",
"new",
"InstancedConfiguration",
"(",
"ConfigurationUtils",
".",
"defaults",
"(",
")",
")",
";",
"SparkIntegrationChecker",
"checker",
"=",
"new",
"SparkIntegrationChecker",
"(",
")",
";",
"JCommander",
"jCommander",
"=",
"new",
"JCommander",
"(",
"checker",
",",
"args",
")",
";",
"jCommander",
".",
"setProgramName",
"(",
"\"SparkIntegrationChecker\"",
")",
";",
"// Create a file to save user-facing messages",
"try",
"(",
"PrintWriter",
"reportWriter",
"=",
"CheckerUtils",
".",
"initReportFile",
"(",
")",
")",
"{",
"// Start the Java Spark Context",
"SparkConf",
"conf",
"=",
"new",
"SparkConf",
"(",
")",
".",
"setAppName",
"(",
"SparkIntegrationChecker",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"JavaSparkContext",
"sc",
"=",
"new",
"JavaSparkContext",
"(",
"conf",
")",
";",
"checker",
".",
"printConfigInfo",
"(",
"conf",
",",
"reportWriter",
")",
";",
"Status",
"resultStatus",
"=",
"checker",
".",
"run",
"(",
"sc",
",",
"reportWriter",
",",
"alluxioConf",
")",
";",
"checker",
".",
"printResultInfo",
"(",
"resultStatus",
",",
"reportWriter",
")",
";",
"reportWriter",
".",
"flush",
"(",
")",
";",
"System",
".",
"exit",
"(",
"resultStatus",
".",
"equals",
"(",
"Status",
".",
"SUCCESS",
")",
"?",
"0",
":",
"1",
")",
";",
"}",
"}"
] |
Main function will be triggered via spark-submit.
@param args optional argument mPartitions may be passed in
|
[
"Main",
"function",
"will",
"be",
"triggered",
"via",
"spark",
"-",
"submit",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/checker/src/main/java/alluxio/checker/SparkIntegrationChecker.java#L194-L212
|
18,570
|
Alluxio/alluxio
|
integration/fuse/src/main/java/alluxio/fuse/AlluxioFuse.java
|
AlluxioFuse.parseOptions
|
private static AlluxioFuseOptions parseOptions(String[] args, AlluxioConfiguration alluxioConf) {
final Options opts = new Options();
final Option mntPoint = Option.builder("m")
.hasArg()
.required(true)
.longOpt("mount-point")
.desc("Desired local mount point for alluxio-fuse.")
.build();
final Option alluxioRoot = Option.builder("r")
.hasArg()
.required(true)
.longOpt("alluxio-root")
.desc("Path within alluxio that will be used as the root of the FUSE mount "
+ "(e.g., /users/foo; defaults to /)")
.build();
final Option help = Option.builder("h")
.required(false)
.desc("Print this help")
.build();
final Option fuseOption = Option.builder("o")
.valueSeparator(',')
.required(false)
.hasArgs()
.desc("FUSE mount options")
.build();
opts.addOption(mntPoint);
opts.addOption(alluxioRoot);
opts.addOption(help);
opts.addOption(fuseOption);
final CommandLineParser parser = new DefaultParser();
try {
CommandLine cli = parser.parse(opts, args);
if (cli.hasOption("h")) {
final HelpFormatter fmt = new HelpFormatter();
fmt.printHelp(AlluxioFuse.class.getName(), opts);
return null;
}
String mntPointValue = cli.getOptionValue("m");
String alluxioRootValue = cli.getOptionValue("r");
List<String> fuseOpts = new ArrayList<>();
boolean noUserMaxWrite = true;
if (cli.hasOption("o")) {
String[] fopts = cli.getOptionValues("o");
// keep the -o
for (final String fopt: fopts) {
fuseOpts.add("-o" + fopt);
if (noUserMaxWrite && fopt.startsWith("max_write")) {
noUserMaxWrite = false;
}
}
}
// check if the user has specified his own max_write, otherwise get it
// from conf
if (noUserMaxWrite) {
final long maxWrite = alluxioConf.getBytes(PropertyKey.FUSE_MAXWRITE_BYTES);
fuseOpts.add(String.format("-omax_write=%d", maxWrite));
}
final boolean fuseDebug = alluxioConf.getBoolean(PropertyKey.FUSE_DEBUG_ENABLED);
return new AlluxioFuseOptions(mntPointValue, alluxioRootValue, fuseDebug, fuseOpts);
} catch (ParseException e) {
System.err.println("Error while parsing CLI: " + e.getMessage());
final HelpFormatter fmt = new HelpFormatter();
fmt.printHelp(AlluxioFuse.class.getName(), opts);
return null;
}
}
|
java
|
private static AlluxioFuseOptions parseOptions(String[] args, AlluxioConfiguration alluxioConf) {
final Options opts = new Options();
final Option mntPoint = Option.builder("m")
.hasArg()
.required(true)
.longOpt("mount-point")
.desc("Desired local mount point for alluxio-fuse.")
.build();
final Option alluxioRoot = Option.builder("r")
.hasArg()
.required(true)
.longOpt("alluxio-root")
.desc("Path within alluxio that will be used as the root of the FUSE mount "
+ "(e.g., /users/foo; defaults to /)")
.build();
final Option help = Option.builder("h")
.required(false)
.desc("Print this help")
.build();
final Option fuseOption = Option.builder("o")
.valueSeparator(',')
.required(false)
.hasArgs()
.desc("FUSE mount options")
.build();
opts.addOption(mntPoint);
opts.addOption(alluxioRoot);
opts.addOption(help);
opts.addOption(fuseOption);
final CommandLineParser parser = new DefaultParser();
try {
CommandLine cli = parser.parse(opts, args);
if (cli.hasOption("h")) {
final HelpFormatter fmt = new HelpFormatter();
fmt.printHelp(AlluxioFuse.class.getName(), opts);
return null;
}
String mntPointValue = cli.getOptionValue("m");
String alluxioRootValue = cli.getOptionValue("r");
List<String> fuseOpts = new ArrayList<>();
boolean noUserMaxWrite = true;
if (cli.hasOption("o")) {
String[] fopts = cli.getOptionValues("o");
// keep the -o
for (final String fopt: fopts) {
fuseOpts.add("-o" + fopt);
if (noUserMaxWrite && fopt.startsWith("max_write")) {
noUserMaxWrite = false;
}
}
}
// check if the user has specified his own max_write, otherwise get it
// from conf
if (noUserMaxWrite) {
final long maxWrite = alluxioConf.getBytes(PropertyKey.FUSE_MAXWRITE_BYTES);
fuseOpts.add(String.format("-omax_write=%d", maxWrite));
}
final boolean fuseDebug = alluxioConf.getBoolean(PropertyKey.FUSE_DEBUG_ENABLED);
return new AlluxioFuseOptions(mntPointValue, alluxioRootValue, fuseDebug, fuseOpts);
} catch (ParseException e) {
System.err.println("Error while parsing CLI: " + e.getMessage());
final HelpFormatter fmt = new HelpFormatter();
fmt.printHelp(AlluxioFuse.class.getName(), opts);
return null;
}
}
|
[
"private",
"static",
"AlluxioFuseOptions",
"parseOptions",
"(",
"String",
"[",
"]",
"args",
",",
"AlluxioConfiguration",
"alluxioConf",
")",
"{",
"final",
"Options",
"opts",
"=",
"new",
"Options",
"(",
")",
";",
"final",
"Option",
"mntPoint",
"=",
"Option",
".",
"builder",
"(",
"\"m\"",
")",
".",
"hasArg",
"(",
")",
".",
"required",
"(",
"true",
")",
".",
"longOpt",
"(",
"\"mount-point\"",
")",
".",
"desc",
"(",
"\"Desired local mount point for alluxio-fuse.\"",
")",
".",
"build",
"(",
")",
";",
"final",
"Option",
"alluxioRoot",
"=",
"Option",
".",
"builder",
"(",
"\"r\"",
")",
".",
"hasArg",
"(",
")",
".",
"required",
"(",
"true",
")",
".",
"longOpt",
"(",
"\"alluxio-root\"",
")",
".",
"desc",
"(",
"\"Path within alluxio that will be used as the root of the FUSE mount \"",
"+",
"\"(e.g., /users/foo; defaults to /)\"",
")",
".",
"build",
"(",
")",
";",
"final",
"Option",
"help",
"=",
"Option",
".",
"builder",
"(",
"\"h\"",
")",
".",
"required",
"(",
"false",
")",
".",
"desc",
"(",
"\"Print this help\"",
")",
".",
"build",
"(",
")",
";",
"final",
"Option",
"fuseOption",
"=",
"Option",
".",
"builder",
"(",
"\"o\"",
")",
".",
"valueSeparator",
"(",
"'",
"'",
")",
".",
"required",
"(",
"false",
")",
".",
"hasArgs",
"(",
")",
".",
"desc",
"(",
"\"FUSE mount options\"",
")",
".",
"build",
"(",
")",
";",
"opts",
".",
"addOption",
"(",
"mntPoint",
")",
";",
"opts",
".",
"addOption",
"(",
"alluxioRoot",
")",
";",
"opts",
".",
"addOption",
"(",
"help",
")",
";",
"opts",
".",
"addOption",
"(",
"fuseOption",
")",
";",
"final",
"CommandLineParser",
"parser",
"=",
"new",
"DefaultParser",
"(",
")",
";",
"try",
"{",
"CommandLine",
"cli",
"=",
"parser",
".",
"parse",
"(",
"opts",
",",
"args",
")",
";",
"if",
"(",
"cli",
".",
"hasOption",
"(",
"\"h\"",
")",
")",
"{",
"final",
"HelpFormatter",
"fmt",
"=",
"new",
"HelpFormatter",
"(",
")",
";",
"fmt",
".",
"printHelp",
"(",
"AlluxioFuse",
".",
"class",
".",
"getName",
"(",
")",
",",
"opts",
")",
";",
"return",
"null",
";",
"}",
"String",
"mntPointValue",
"=",
"cli",
".",
"getOptionValue",
"(",
"\"m\"",
")",
";",
"String",
"alluxioRootValue",
"=",
"cli",
".",
"getOptionValue",
"(",
"\"r\"",
")",
";",
"List",
"<",
"String",
">",
"fuseOpts",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"boolean",
"noUserMaxWrite",
"=",
"true",
";",
"if",
"(",
"cli",
".",
"hasOption",
"(",
"\"o\"",
")",
")",
"{",
"String",
"[",
"]",
"fopts",
"=",
"cli",
".",
"getOptionValues",
"(",
"\"o\"",
")",
";",
"// keep the -o",
"for",
"(",
"final",
"String",
"fopt",
":",
"fopts",
")",
"{",
"fuseOpts",
".",
"add",
"(",
"\"-o\"",
"+",
"fopt",
")",
";",
"if",
"(",
"noUserMaxWrite",
"&&",
"fopt",
".",
"startsWith",
"(",
"\"max_write\"",
")",
")",
"{",
"noUserMaxWrite",
"=",
"false",
";",
"}",
"}",
"}",
"// check if the user has specified his own max_write, otherwise get it",
"// from conf",
"if",
"(",
"noUserMaxWrite",
")",
"{",
"final",
"long",
"maxWrite",
"=",
"alluxioConf",
".",
"getBytes",
"(",
"PropertyKey",
".",
"FUSE_MAXWRITE_BYTES",
")",
";",
"fuseOpts",
".",
"add",
"(",
"String",
".",
"format",
"(",
"\"-omax_write=%d\"",
",",
"maxWrite",
")",
")",
";",
"}",
"final",
"boolean",
"fuseDebug",
"=",
"alluxioConf",
".",
"getBoolean",
"(",
"PropertyKey",
".",
"FUSE_DEBUG_ENABLED",
")",
";",
"return",
"new",
"AlluxioFuseOptions",
"(",
"mntPointValue",
",",
"alluxioRootValue",
",",
"fuseDebug",
",",
"fuseOpts",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Error while parsing CLI: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"final",
"HelpFormatter",
"fmt",
"=",
"new",
"HelpFormatter",
"(",
")",
";",
"fmt",
".",
"printHelp",
"(",
"AlluxioFuse",
".",
"class",
".",
"getName",
"(",
")",
",",
"opts",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Parses CLI options.
@param args CLI args
@return Alluxio-FUSE configuration options
|
[
"Parses",
"CLI",
"options",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuse.java#L84-L159
|
18,571
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java
|
DirectedAcyclicGraph.add
|
public void add(T payload, List<T> parents) {
// This checks the payload doesn't exist in the graph, and therefore prevents cycles.
Preconditions.checkState(!contains(payload), "the payload already exists in the DAG");
// construct the new node
DirectedAcyclicGraphNode<T> newNode = new DirectedAcyclicGraphNode<>(payload);
mIndex.put(payload, newNode);
if (parents.isEmpty()) {
// add to root
mRoots.add(newNode);
} else {
// find parent nodes
for (T parent : parents) {
Preconditions.checkState(contains(parent),
"the parent payload " + parent + " does not exist in the DAG");
DirectedAcyclicGraphNode<T> parentNode = mIndex.get(parent);
parentNode.addChild(newNode);
newNode.addParent(parentNode);
}
}
}
|
java
|
public void add(T payload, List<T> parents) {
// This checks the payload doesn't exist in the graph, and therefore prevents cycles.
Preconditions.checkState(!contains(payload), "the payload already exists in the DAG");
// construct the new node
DirectedAcyclicGraphNode<T> newNode = new DirectedAcyclicGraphNode<>(payload);
mIndex.put(payload, newNode);
if (parents.isEmpty()) {
// add to root
mRoots.add(newNode);
} else {
// find parent nodes
for (T parent : parents) {
Preconditions.checkState(contains(parent),
"the parent payload " + parent + " does not exist in the DAG");
DirectedAcyclicGraphNode<T> parentNode = mIndex.get(parent);
parentNode.addChild(newNode);
newNode.addParent(parentNode);
}
}
}
|
[
"public",
"void",
"add",
"(",
"T",
"payload",
",",
"List",
"<",
"T",
">",
"parents",
")",
"{",
"// This checks the payload doesn't exist in the graph, and therefore prevents cycles.",
"Preconditions",
".",
"checkState",
"(",
"!",
"contains",
"(",
"payload",
")",
",",
"\"the payload already exists in the DAG\"",
")",
";",
"// construct the new node",
"DirectedAcyclicGraphNode",
"<",
"T",
">",
"newNode",
"=",
"new",
"DirectedAcyclicGraphNode",
"<>",
"(",
"payload",
")",
";",
"mIndex",
".",
"put",
"(",
"payload",
",",
"newNode",
")",
";",
"if",
"(",
"parents",
".",
"isEmpty",
"(",
")",
")",
"{",
"// add to root",
"mRoots",
".",
"add",
"(",
"newNode",
")",
";",
"}",
"else",
"{",
"// find parent nodes",
"for",
"(",
"T",
"parent",
":",
"parents",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"contains",
"(",
"parent",
")",
",",
"\"the parent payload \"",
"+",
"parent",
"+",
"\" does not exist in the DAG\"",
")",
";",
"DirectedAcyclicGraphNode",
"<",
"T",
">",
"parentNode",
"=",
"mIndex",
".",
"get",
"(",
"parent",
")",
";",
"parentNode",
".",
"addChild",
"(",
"newNode",
")",
";",
"newNode",
".",
"addParent",
"(",
"parentNode",
")",
";",
"}",
"}",
"}"
] |
Adds a node to the DAG, that takes the given payload and depends on the specified parents.
@param payload the payload
@param parents the parents of the created node
|
[
"Adds",
"a",
"node",
"to",
"the",
"DAG",
"that",
"takes",
"the",
"given",
"payload",
"and",
"depends",
"on",
"the",
"specified",
"parents",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java#L51-L72
|
18,572
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java
|
DirectedAcyclicGraph.deleteLeaf
|
public void deleteLeaf(T payload) {
Preconditions.checkState(contains(payload), "the node does not exist");
DirectedAcyclicGraphNode<T> node = mIndex.get(payload);
Preconditions.checkState(node.getChildren().isEmpty(), "the node is not a leaf");
// delete from parent
for (DirectedAcyclicGraphNode<T> parent : node.getParents()) {
parent.removeChild(node);
}
// remove from index
mIndex.remove(payload);
if (node.getParents().isEmpty()) {
mRoots.remove(node);
}
}
|
java
|
public void deleteLeaf(T payload) {
Preconditions.checkState(contains(payload), "the node does not exist");
DirectedAcyclicGraphNode<T> node = mIndex.get(payload);
Preconditions.checkState(node.getChildren().isEmpty(), "the node is not a leaf");
// delete from parent
for (DirectedAcyclicGraphNode<T> parent : node.getParents()) {
parent.removeChild(node);
}
// remove from index
mIndex.remove(payload);
if (node.getParents().isEmpty()) {
mRoots.remove(node);
}
}
|
[
"public",
"void",
"deleteLeaf",
"(",
"T",
"payload",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"contains",
"(",
"payload",
")",
",",
"\"the node does not exist\"",
")",
";",
"DirectedAcyclicGraphNode",
"<",
"T",
">",
"node",
"=",
"mIndex",
".",
"get",
"(",
"payload",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"node",
".",
"getChildren",
"(",
")",
".",
"isEmpty",
"(",
")",
",",
"\"the node is not a leaf\"",
")",
";",
"// delete from parent",
"for",
"(",
"DirectedAcyclicGraphNode",
"<",
"T",
">",
"parent",
":",
"node",
".",
"getParents",
"(",
")",
")",
"{",
"parent",
".",
"removeChild",
"(",
"node",
")",
";",
"}",
"// remove from index",
"mIndex",
".",
"remove",
"(",
"payload",
")",
";",
"if",
"(",
"node",
".",
"getParents",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"mRoots",
".",
"remove",
"(",
"node",
")",
";",
"}",
"}"
] |
Deletes a leaf DAG node that carries the given payload.
@param payload the payload of the node to delete
|
[
"Deletes",
"a",
"leaf",
"DAG",
"node",
"that",
"carries",
"the",
"given",
"payload",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java#L79-L95
|
18,573
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java
|
DirectedAcyclicGraph.getChildren
|
public List<T> getChildren(T payload) {
List<T> children = new ArrayList<>();
if (!mIndex.containsKey(payload)) {
return children;
}
DirectedAcyclicGraphNode<T> node = mIndex.get(payload);
for (DirectedAcyclicGraphNode<T> child : node.getChildren()) {
children.add(child.getPayload());
}
return children;
}
|
java
|
public List<T> getChildren(T payload) {
List<T> children = new ArrayList<>();
if (!mIndex.containsKey(payload)) {
return children;
}
DirectedAcyclicGraphNode<T> node = mIndex.get(payload);
for (DirectedAcyclicGraphNode<T> child : node.getChildren()) {
children.add(child.getPayload());
}
return children;
}
|
[
"public",
"List",
"<",
"T",
">",
"getChildren",
"(",
"T",
"payload",
")",
"{",
"List",
"<",
"T",
">",
"children",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"!",
"mIndex",
".",
"containsKey",
"(",
"payload",
")",
")",
"{",
"return",
"children",
";",
"}",
"DirectedAcyclicGraphNode",
"<",
"T",
">",
"node",
"=",
"mIndex",
".",
"get",
"(",
"payload",
")",
";",
"for",
"(",
"DirectedAcyclicGraphNode",
"<",
"T",
">",
"child",
":",
"node",
".",
"getChildren",
"(",
")",
")",
"{",
"children",
".",
"add",
"(",
"child",
".",
"getPayload",
"(",
")",
")",
";",
"}",
"return",
"children",
";",
"}"
] |
Gets the payloads for the children of the given node.
@param payload the payload of the parent node
@return the children's payloads, an empty list if the given payload doesn't exist in the DAG
|
[
"Gets",
"the",
"payloads",
"for",
"the",
"children",
"of",
"the",
"given",
"node",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java#L113-L123
|
18,574
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java
|
DirectedAcyclicGraph.getParents
|
public List<T> getParents(T payload) {
List<T> parents = new ArrayList<>();
if (!mIndex.containsKey(payload)) {
return parents;
}
DirectedAcyclicGraphNode<T> node = mIndex.get(payload);
for (DirectedAcyclicGraphNode<T> parent : node.getParents()) {
parents.add(parent.getPayload());
}
return parents;
}
|
java
|
public List<T> getParents(T payload) {
List<T> parents = new ArrayList<>();
if (!mIndex.containsKey(payload)) {
return parents;
}
DirectedAcyclicGraphNode<T> node = mIndex.get(payload);
for (DirectedAcyclicGraphNode<T> parent : node.getParents()) {
parents.add(parent.getPayload());
}
return parents;
}
|
[
"public",
"List",
"<",
"T",
">",
"getParents",
"(",
"T",
"payload",
")",
"{",
"List",
"<",
"T",
">",
"parents",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"!",
"mIndex",
".",
"containsKey",
"(",
"payload",
")",
")",
"{",
"return",
"parents",
";",
"}",
"DirectedAcyclicGraphNode",
"<",
"T",
">",
"node",
"=",
"mIndex",
".",
"get",
"(",
"payload",
")",
";",
"for",
"(",
"DirectedAcyclicGraphNode",
"<",
"T",
">",
"parent",
":",
"node",
".",
"getParents",
"(",
")",
")",
"{",
"parents",
".",
"add",
"(",
"parent",
".",
"getPayload",
"(",
")",
")",
";",
"}",
"return",
"parents",
";",
"}"
] |
Gets the payloads for the given nodes parents.
@param payload the payload of the children node
@return the parents' payloads, an empty list if the given payload doesn't exist in the DAG
|
[
"Gets",
"the",
"payloads",
"for",
"the",
"given",
"nodes",
"parents",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java#L131-L141
|
18,575
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java
|
DirectedAcyclicGraph.isRoot
|
public boolean isRoot(T payload) {
if (!contains(payload)) {
return false;
}
return mRoots.contains(mIndex.get(payload));
}
|
java
|
public boolean isRoot(T payload) {
if (!contains(payload)) {
return false;
}
return mRoots.contains(mIndex.get(payload));
}
|
[
"public",
"boolean",
"isRoot",
"(",
"T",
"payload",
")",
"{",
"if",
"(",
"!",
"contains",
"(",
"payload",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"mRoots",
".",
"contains",
"(",
"mIndex",
".",
"get",
"(",
"payload",
")",
")",
";",
"}"
] |
Checks if a given payload is in a root of the DAG.
@param payload the payload to check for root
@return true if the payload is in the root of the DAG, false otherwise
|
[
"Checks",
"if",
"a",
"given",
"payload",
"is",
"in",
"a",
"root",
"of",
"the",
"DAG",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java#L149-L154
|
18,576
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java
|
DirectedAcyclicGraph.getRoots
|
public List<T> getRoots() {
List<T> roots = new ArrayList<>();
for (DirectedAcyclicGraphNode<T> root : mRoots) {
roots.add(root.getPayload());
}
return roots;
}
|
java
|
public List<T> getRoots() {
List<T> roots = new ArrayList<>();
for (DirectedAcyclicGraphNode<T> root : mRoots) {
roots.add(root.getPayload());
}
return roots;
}
|
[
"public",
"List",
"<",
"T",
">",
"getRoots",
"(",
")",
"{",
"List",
"<",
"T",
">",
"roots",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"DirectedAcyclicGraphNode",
"<",
"T",
">",
"root",
":",
"mRoots",
")",
"{",
"roots",
".",
"add",
"(",
"root",
".",
"getPayload",
"(",
")",
")",
";",
"}",
"return",
"roots",
";",
"}"
] |
Gets the payloads of all the root nodes of the DAG.
@return all the root payloads
|
[
"Gets",
"the",
"payloads",
"of",
"all",
"the",
"root",
"nodes",
"of",
"the",
"DAG",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java#L161-L167
|
18,577
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java
|
DirectedAcyclicGraph.sortTopologically
|
public List<T> sortTopologically(Set<T> payloads) {
List<T> result = new ArrayList<>();
Set<T> input = new HashSet<>(payloads);
Deque<DirectedAcyclicGraphNode<T>> toVisit = new ArrayDeque<>(mRoots);
while (!toVisit.isEmpty()) {
DirectedAcyclicGraphNode<T> visit = toVisit.removeFirst();
T payload = visit.getPayload();
if (input.remove(payload)) {
result.add(visit.getPayload());
}
toVisit.addAll(visit.getChildren());
}
Preconditions.checkState(input.isEmpty(), "Not all the given payloads are in the DAG: ",
input);
return result;
}
|
java
|
public List<T> sortTopologically(Set<T> payloads) {
List<T> result = new ArrayList<>();
Set<T> input = new HashSet<>(payloads);
Deque<DirectedAcyclicGraphNode<T>> toVisit = new ArrayDeque<>(mRoots);
while (!toVisit.isEmpty()) {
DirectedAcyclicGraphNode<T> visit = toVisit.removeFirst();
T payload = visit.getPayload();
if (input.remove(payload)) {
result.add(visit.getPayload());
}
toVisit.addAll(visit.getChildren());
}
Preconditions.checkState(input.isEmpty(), "Not all the given payloads are in the DAG: ",
input);
return result;
}
|
[
"public",
"List",
"<",
"T",
">",
"sortTopologically",
"(",
"Set",
"<",
"T",
">",
"payloads",
")",
"{",
"List",
"<",
"T",
">",
"result",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Set",
"<",
"T",
">",
"input",
"=",
"new",
"HashSet",
"<>",
"(",
"payloads",
")",
";",
"Deque",
"<",
"DirectedAcyclicGraphNode",
"<",
"T",
">",
">",
"toVisit",
"=",
"new",
"ArrayDeque",
"<>",
"(",
"mRoots",
")",
";",
"while",
"(",
"!",
"toVisit",
".",
"isEmpty",
"(",
")",
")",
"{",
"DirectedAcyclicGraphNode",
"<",
"T",
">",
"visit",
"=",
"toVisit",
".",
"removeFirst",
"(",
")",
";",
"T",
"payload",
"=",
"visit",
".",
"getPayload",
"(",
")",
";",
"if",
"(",
"input",
".",
"remove",
"(",
"payload",
")",
")",
"{",
"result",
".",
"add",
"(",
"visit",
".",
"getPayload",
"(",
")",
")",
";",
"}",
"toVisit",
".",
"addAll",
"(",
"visit",
".",
"getChildren",
"(",
")",
")",
";",
"}",
"Preconditions",
".",
"checkState",
"(",
"input",
".",
"isEmpty",
"(",
")",
",",
"\"Not all the given payloads are in the DAG: \"",
",",
"input",
")",
";",
"return",
"result",
";",
"}"
] |
Sorts a given set of payloads topologically based on the DAG. This method requires all the
payloads to be in the DAG.
@param payloads the set of input payloads
@return the payloads after topological sort
|
[
"Sorts",
"a",
"given",
"set",
"of",
"payloads",
"topologically",
"based",
"on",
"the",
"DAG",
".",
"This",
"method",
"requires",
"all",
"the",
"payloads",
"to",
"be",
"in",
"the",
"DAG",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/DirectedAcyclicGraph.java#L176-L193
|
18,578
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/security/authentication/AuthenticatedUserInjector.java
|
AuthenticatedUserInjector.authenticateCall
|
private <ReqT, RespT> boolean authenticateCall(ServerCall<ReqT, RespT> call, Metadata headers) {
// Fail validation for cancelled server calls.
if (call.isCancelled()) {
LOG.debug("Server call has been cancelled: %s",
call.getMethodDescriptor().getFullMethodName());
return false;
}
// Try to fetch channel Id from the metadata.
UUID channelId = headers.get(ChannelIdInjector.S_CLIENT_ID_KEY);
boolean callAuthenticated = false;
if (channelId != null) {
try {
// Fetch authenticated username for this channel and set it.
AuthenticatedUserInfo userInfo = mAuthenticationServer.getUserInfoForChannel(channelId);
if (userInfo != null) {
AuthenticatedClientUser.set(userInfo.getAuthorizedUserName());
AuthenticatedClientUser.setConnectionUser(userInfo.getConnectionUserName());
AuthenticatedClientUser.setAuthMethod(userInfo.getAuthMethod());
} else {
AuthenticatedClientUser.remove();
}
callAuthenticated = true;
} catch (UnauthenticatedException e) {
String message = String.format("Channel: %s is not authenticated for call: %s",
channelId.toString(), call.getMethodDescriptor().getFullMethodName());
call.close(Status.UNAUTHENTICATED.withDescription(message), headers);
}
} else {
String message = String.format("Channel Id is missing for call: %s.",
call.getMethodDescriptor().getFullMethodName());
call.close(Status.UNAUTHENTICATED.withDescription(message), headers);
}
return callAuthenticated;
}
|
java
|
private <ReqT, RespT> boolean authenticateCall(ServerCall<ReqT, RespT> call, Metadata headers) {
// Fail validation for cancelled server calls.
if (call.isCancelled()) {
LOG.debug("Server call has been cancelled: %s",
call.getMethodDescriptor().getFullMethodName());
return false;
}
// Try to fetch channel Id from the metadata.
UUID channelId = headers.get(ChannelIdInjector.S_CLIENT_ID_KEY);
boolean callAuthenticated = false;
if (channelId != null) {
try {
// Fetch authenticated username for this channel and set it.
AuthenticatedUserInfo userInfo = mAuthenticationServer.getUserInfoForChannel(channelId);
if (userInfo != null) {
AuthenticatedClientUser.set(userInfo.getAuthorizedUserName());
AuthenticatedClientUser.setConnectionUser(userInfo.getConnectionUserName());
AuthenticatedClientUser.setAuthMethod(userInfo.getAuthMethod());
} else {
AuthenticatedClientUser.remove();
}
callAuthenticated = true;
} catch (UnauthenticatedException e) {
String message = String.format("Channel: %s is not authenticated for call: %s",
channelId.toString(), call.getMethodDescriptor().getFullMethodName());
call.close(Status.UNAUTHENTICATED.withDescription(message), headers);
}
} else {
String message = String.format("Channel Id is missing for call: %s.",
call.getMethodDescriptor().getFullMethodName());
call.close(Status.UNAUTHENTICATED.withDescription(message), headers);
}
return callAuthenticated;
}
|
[
"private",
"<",
"ReqT",
",",
"RespT",
">",
"boolean",
"authenticateCall",
"(",
"ServerCall",
"<",
"ReqT",
",",
"RespT",
">",
"call",
",",
"Metadata",
"headers",
")",
"{",
"// Fail validation for cancelled server calls.",
"if",
"(",
"call",
".",
"isCancelled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Server call has been cancelled: %s\"",
",",
"call",
".",
"getMethodDescriptor",
"(",
")",
".",
"getFullMethodName",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"// Try to fetch channel Id from the metadata.",
"UUID",
"channelId",
"=",
"headers",
".",
"get",
"(",
"ChannelIdInjector",
".",
"S_CLIENT_ID_KEY",
")",
";",
"boolean",
"callAuthenticated",
"=",
"false",
";",
"if",
"(",
"channelId",
"!=",
"null",
")",
"{",
"try",
"{",
"// Fetch authenticated username for this channel and set it.",
"AuthenticatedUserInfo",
"userInfo",
"=",
"mAuthenticationServer",
".",
"getUserInfoForChannel",
"(",
"channelId",
")",
";",
"if",
"(",
"userInfo",
"!=",
"null",
")",
"{",
"AuthenticatedClientUser",
".",
"set",
"(",
"userInfo",
".",
"getAuthorizedUserName",
"(",
")",
")",
";",
"AuthenticatedClientUser",
".",
"setConnectionUser",
"(",
"userInfo",
".",
"getConnectionUserName",
"(",
")",
")",
";",
"AuthenticatedClientUser",
".",
"setAuthMethod",
"(",
"userInfo",
".",
"getAuthMethod",
"(",
")",
")",
";",
"}",
"else",
"{",
"AuthenticatedClientUser",
".",
"remove",
"(",
")",
";",
"}",
"callAuthenticated",
"=",
"true",
";",
"}",
"catch",
"(",
"UnauthenticatedException",
"e",
")",
"{",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Channel: %s is not authenticated for call: %s\"",
",",
"channelId",
".",
"toString",
"(",
")",
",",
"call",
".",
"getMethodDescriptor",
"(",
")",
".",
"getFullMethodName",
"(",
")",
")",
";",
"call",
".",
"close",
"(",
"Status",
".",
"UNAUTHENTICATED",
".",
"withDescription",
"(",
"message",
")",
",",
"headers",
")",
";",
"}",
"}",
"else",
"{",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Channel Id is missing for call: %s.\"",
",",
"call",
".",
"getMethodDescriptor",
"(",
")",
".",
"getFullMethodName",
"(",
")",
")",
";",
"call",
".",
"close",
"(",
"Status",
".",
"UNAUTHENTICATED",
".",
"withDescription",
"(",
"message",
")",
",",
"headers",
")",
";",
"}",
"return",
"callAuthenticated",
";",
"}"
] |
Authenticates given call against auth-server state.
Fails the call if it's not originating from an authenticated client channel.
It sets thread-local authentication information for the call with the user information
that is kept on auth-server.
|
[
"Authenticates",
"given",
"call",
"against",
"auth",
"-",
"server",
"state",
".",
"Fails",
"the",
"call",
"if",
"it",
"s",
"not",
"originating",
"from",
"an",
"authenticated",
"client",
"channel",
".",
"It",
"sets",
"thread",
"-",
"local",
"authentication",
"information",
"for",
"the",
"call",
"with",
"the",
"user",
"information",
"that",
"is",
"kept",
"on",
"auth",
"-",
"server",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/security/authentication/AuthenticatedUserInjector.java#L79-L113
|
18,579
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/doctor/StorageCommand.java
|
StorageCommand.run
|
public int run() throws IOException {
List<WorkerLostStorageInfo> workerLostStorageList = mBlockMasterClient.getWorkerLostStorage();
if (workerLostStorageList.size() == 0) {
mPrintStream.println("All worker storage paths are in working state.");
return 0;
}
for (WorkerLostStorageInfo info : workerLostStorageList) {
Map<String, StorageList> lostStorageMap = info.getLostStorageMap();
if (lostStorageMap.size() != 0) {
mPrintStream.printf("The following storage paths are lost in worker %s: %n",
info.getAddress().getHost());
for (Map.Entry<String, StorageList> tierStorage : lostStorageMap.entrySet()) {
for (String storage : tierStorage.getValue().getStorageList()) {
mPrintStream.printf("%s (%s)%n", storage, tierStorage.getKey());
}
}
}
}
return 0;
}
|
java
|
public int run() throws IOException {
List<WorkerLostStorageInfo> workerLostStorageList = mBlockMasterClient.getWorkerLostStorage();
if (workerLostStorageList.size() == 0) {
mPrintStream.println("All worker storage paths are in working state.");
return 0;
}
for (WorkerLostStorageInfo info : workerLostStorageList) {
Map<String, StorageList> lostStorageMap = info.getLostStorageMap();
if (lostStorageMap.size() != 0) {
mPrintStream.printf("The following storage paths are lost in worker %s: %n",
info.getAddress().getHost());
for (Map.Entry<String, StorageList> tierStorage : lostStorageMap.entrySet()) {
for (String storage : tierStorage.getValue().getStorageList()) {
mPrintStream.printf("%s (%s)%n", storage, tierStorage.getKey());
}
}
}
}
return 0;
}
|
[
"public",
"int",
"run",
"(",
")",
"throws",
"IOException",
"{",
"List",
"<",
"WorkerLostStorageInfo",
">",
"workerLostStorageList",
"=",
"mBlockMasterClient",
".",
"getWorkerLostStorage",
"(",
")",
";",
"if",
"(",
"workerLostStorageList",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"mPrintStream",
".",
"println",
"(",
"\"All worker storage paths are in working state.\"",
")",
";",
"return",
"0",
";",
"}",
"for",
"(",
"WorkerLostStorageInfo",
"info",
":",
"workerLostStorageList",
")",
"{",
"Map",
"<",
"String",
",",
"StorageList",
">",
"lostStorageMap",
"=",
"info",
".",
"getLostStorageMap",
"(",
")",
";",
"if",
"(",
"lostStorageMap",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"mPrintStream",
".",
"printf",
"(",
"\"The following storage paths are lost in worker %s: %n\"",
",",
"info",
".",
"getAddress",
"(",
")",
".",
"getHost",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"StorageList",
">",
"tierStorage",
":",
"lostStorageMap",
".",
"entrySet",
"(",
")",
")",
"{",
"for",
"(",
"String",
"storage",
":",
"tierStorage",
".",
"getValue",
"(",
")",
".",
"getStorageList",
"(",
")",
")",
"{",
"mPrintStream",
".",
"printf",
"(",
"\"%s (%s)%n\"",
",",
"storage",
",",
"tierStorage",
".",
"getKey",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"return",
"0",
";",
"}"
] |
Runs doctor storage command.
@return 0 on success, 1 otherwise
|
[
"Runs",
"doctor",
"storage",
"command",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/doctor/StorageCommand.java#L46-L65
|
18,580
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/command/SetReplicationCommand.java
|
SetReplicationCommand.setReplication
|
private void setReplication(AlluxioURI path, Integer replicationMax, Integer replicationMin,
boolean recursive) throws AlluxioException, IOException {
SetAttributePOptions.Builder optionsBuilder =
SetAttributePOptions.newBuilder().setRecursive(recursive);
String message = "Changed the replication level of " + path + "\n";
if (replicationMax != null) {
optionsBuilder.setReplicationMax(replicationMax);
message += "replicationMax was set to " + replicationMax + "\n";
}
if (replicationMin != null) {
optionsBuilder.setReplicationMin(replicationMin);
message += "replicationMin was set to " + replicationMin + "\n";
}
mFileSystem.setAttribute(path, optionsBuilder.build());
System.out.println(message);
}
|
java
|
private void setReplication(AlluxioURI path, Integer replicationMax, Integer replicationMin,
boolean recursive) throws AlluxioException, IOException {
SetAttributePOptions.Builder optionsBuilder =
SetAttributePOptions.newBuilder().setRecursive(recursive);
String message = "Changed the replication level of " + path + "\n";
if (replicationMax != null) {
optionsBuilder.setReplicationMax(replicationMax);
message += "replicationMax was set to " + replicationMax + "\n";
}
if (replicationMin != null) {
optionsBuilder.setReplicationMin(replicationMin);
message += "replicationMin was set to " + replicationMin + "\n";
}
mFileSystem.setAttribute(path, optionsBuilder.build());
System.out.println(message);
}
|
[
"private",
"void",
"setReplication",
"(",
"AlluxioURI",
"path",
",",
"Integer",
"replicationMax",
",",
"Integer",
"replicationMin",
",",
"boolean",
"recursive",
")",
"throws",
"AlluxioException",
",",
"IOException",
"{",
"SetAttributePOptions",
".",
"Builder",
"optionsBuilder",
"=",
"SetAttributePOptions",
".",
"newBuilder",
"(",
")",
".",
"setRecursive",
"(",
"recursive",
")",
";",
"String",
"message",
"=",
"\"Changed the replication level of \"",
"+",
"path",
"+",
"\"\\n\"",
";",
"if",
"(",
"replicationMax",
"!=",
"null",
")",
"{",
"optionsBuilder",
".",
"setReplicationMax",
"(",
"replicationMax",
")",
";",
"message",
"+=",
"\"replicationMax was set to \"",
"+",
"replicationMax",
"+",
"\"\\n\"",
";",
"}",
"if",
"(",
"replicationMin",
"!=",
"null",
")",
"{",
"optionsBuilder",
".",
"setReplicationMin",
"(",
"replicationMin",
")",
";",
"message",
"+=",
"\"replicationMin was set to \"",
"+",
"replicationMin",
"+",
"\"\\n\"",
";",
"}",
"mFileSystem",
".",
"setAttribute",
"(",
"path",
",",
"optionsBuilder",
".",
"build",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"message",
")",
";",
"}"
] |
Changes the replication level of directory or file with the path specified in args.
@param path The {@link AlluxioURI} path as the input of the command
@param replicationMax the max replicas, null if not to set
@param replicationMin the min replicas, null if not to set
@param recursive Whether change the permission recursively
@throws AlluxioException when Alluxio exception occurs
@throws IOException when non-Alluxio exception occurs
|
[
"Changes",
"the",
"replication",
"level",
"of",
"directory",
"or",
"file",
"with",
"the",
"path",
"specified",
"in",
"args",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/command/SetReplicationCommand.java#L80-L95
|
18,581
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/Utils.java
|
Utils.limitLife
|
public static void limitLife(final long lifetimeMs) {
new Thread(() -> {
CommonUtils.sleepMs(lifetimeMs);
LOG.info("Process has timed out after {}ms, exiting now", lifetimeMs);
System.exit(-1);
}, "life-limiter").start();
}
|
java
|
public static void limitLife(final long lifetimeMs) {
new Thread(() -> {
CommonUtils.sleepMs(lifetimeMs);
LOG.info("Process has timed out after {}ms, exiting now", lifetimeMs);
System.exit(-1);
}, "life-limiter").start();
}
|
[
"public",
"static",
"void",
"limitLife",
"(",
"final",
"long",
"lifetimeMs",
")",
"{",
"new",
"Thread",
"(",
"(",
")",
"->",
"{",
"CommonUtils",
".",
"sleepMs",
"(",
"lifetimeMs",
")",
";",
"LOG",
".",
"info",
"(",
"\"Process has timed out after {}ms, exiting now\"",
",",
"lifetimeMs",
")",
";",
"System",
".",
"exit",
"(",
"-",
"1",
")",
";",
"}",
",",
"\"life-limiter\"",
")",
".",
"start",
"(",
")",
";",
"}"
] |
Launches a thread to terminate the current process after the specified period has elapsed.
@param lifetimeMs the time to wait before terminating the current process
|
[
"Launches",
"a",
"thread",
"to",
"terminate",
"the",
"current",
"process",
"after",
"the",
"specified",
"period",
"has",
"elapsed",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/Utils.java#L33-L39
|
18,582
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/wire/MasterWebUIMetrics.java
|
MasterWebUIMetrics.setUfsOps
|
public MasterWebUIMetrics setUfsOps(Map<String, Map<String, Long>> UfsOps) {
mUfsOps = UfsOps;
return this;
}
|
java
|
public MasterWebUIMetrics setUfsOps(Map<String, Map<String, Long>> UfsOps) {
mUfsOps = UfsOps;
return this;
}
|
[
"public",
"MasterWebUIMetrics",
"setUfsOps",
"(",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"Long",
">",
">",
"UfsOps",
")",
"{",
"mUfsOps",
"=",
"UfsOps",
";",
"return",
"this",
";",
"}"
] |
Sets ufs ops.
@param UfsOps the ufs ops
@return the ufs ops
|
[
"Sets",
"ufs",
"ops",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/wire/MasterWebUIMetrics.java#L466-L469
|
18,583
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/raft/RaftJournalSystem.java
|
RaftJournalSystem.catchUp
|
private void catchUp(JournalStateMachine stateMachine, CopycatClient client)
throws TimeoutException, InterruptedException {
long startTime = System.currentTimeMillis();
// Wait for any outstanding snapshot to complete.
CommonUtils.waitFor("snapshotting to finish", () -> !stateMachine.isSnapshotting(),
WaitForOptions.defaults().setTimeoutMs(10 * Constants.MINUTE_MS));
// Loop until we lose leadership or convince ourselves that we are caught up and we are the only
// master serving. To convince ourselves of this, we need to accomplish three steps:
//
// 1. Write a unique ID to the copycat.
// 2. Wait for the ID to by applied to the state machine. This proves that we are
// caught up since the copycat cannot apply commits from a previous term after applying
// commits from a later term.
// 3. Wait for a quiet period to elapse without anything new being written to Copycat. This is a
// heuristic to account for the time it takes for a node to realize it is no longer the
// leader. If two nodes think they are leader at the same time, they will both write unique
// IDs to the journal, but only the second one has a chance of becoming leader. The first
// will see that an entry was written after its ID, and double check that it is still the
// leader before trying again.
while (true) {
if (mPrimarySelector.getState() != PrimarySelector.State.PRIMARY) {
return;
}
long lastAppliedSN = stateMachine.getLastAppliedSequenceNumber();
long gainPrimacySN = ThreadLocalRandom.current().nextLong(Long.MIN_VALUE, 0);
LOG.info("Performing catchup. Last applied SN: {}. Catchup ID: {}",
lastAppliedSN, gainPrimacySN);
CompletableFuture<Void> future = client.submit(new JournalEntryCommand(
JournalEntry.newBuilder().setSequenceNumber(gainPrimacySN).build()));
try {
future.get(5, TimeUnit.SECONDS);
} catch (TimeoutException | ExecutionException e) {
LOG.info("Exception submitting term start entry: {}", e.toString());
continue;
}
try {
CommonUtils.waitFor("term start entry " + gainPrimacySN
+ " to be applied to state machine", () ->
stateMachine.getLastPrimaryStartSequenceNumber() == gainPrimacySN,
WaitForOptions.defaults()
.setInterval(Constants.SECOND_MS)
.setTimeoutMs(5 * Constants.SECOND_MS));
} catch (TimeoutException e) {
LOG.info(e.toString());
continue;
}
// Wait 2 election timeouts so that this master and other masters have time to realize they
// are not leader.
CommonUtils.sleepMs(2 * mConf.getElectionTimeoutMs());
if (stateMachine.getLastAppliedSequenceNumber() != lastAppliedSN
|| stateMachine.getLastPrimaryStartSequenceNumber() != gainPrimacySN) {
// Someone has committed a journal entry since we started trying to catch up.
// Restart the catchup process.
continue;
}
LOG.info("Caught up in {}ms. Last sequence number from previous term: {}.",
System.currentTimeMillis() - startTime, stateMachine.getLastAppliedSequenceNumber());
return;
}
}
|
java
|
private void catchUp(JournalStateMachine stateMachine, CopycatClient client)
throws TimeoutException, InterruptedException {
long startTime = System.currentTimeMillis();
// Wait for any outstanding snapshot to complete.
CommonUtils.waitFor("snapshotting to finish", () -> !stateMachine.isSnapshotting(),
WaitForOptions.defaults().setTimeoutMs(10 * Constants.MINUTE_MS));
// Loop until we lose leadership or convince ourselves that we are caught up and we are the only
// master serving. To convince ourselves of this, we need to accomplish three steps:
//
// 1. Write a unique ID to the copycat.
// 2. Wait for the ID to by applied to the state machine. This proves that we are
// caught up since the copycat cannot apply commits from a previous term after applying
// commits from a later term.
// 3. Wait for a quiet period to elapse without anything new being written to Copycat. This is a
// heuristic to account for the time it takes for a node to realize it is no longer the
// leader. If two nodes think they are leader at the same time, they will both write unique
// IDs to the journal, but only the second one has a chance of becoming leader. The first
// will see that an entry was written after its ID, and double check that it is still the
// leader before trying again.
while (true) {
if (mPrimarySelector.getState() != PrimarySelector.State.PRIMARY) {
return;
}
long lastAppliedSN = stateMachine.getLastAppliedSequenceNumber();
long gainPrimacySN = ThreadLocalRandom.current().nextLong(Long.MIN_VALUE, 0);
LOG.info("Performing catchup. Last applied SN: {}. Catchup ID: {}",
lastAppliedSN, gainPrimacySN);
CompletableFuture<Void> future = client.submit(new JournalEntryCommand(
JournalEntry.newBuilder().setSequenceNumber(gainPrimacySN).build()));
try {
future.get(5, TimeUnit.SECONDS);
} catch (TimeoutException | ExecutionException e) {
LOG.info("Exception submitting term start entry: {}", e.toString());
continue;
}
try {
CommonUtils.waitFor("term start entry " + gainPrimacySN
+ " to be applied to state machine", () ->
stateMachine.getLastPrimaryStartSequenceNumber() == gainPrimacySN,
WaitForOptions.defaults()
.setInterval(Constants.SECOND_MS)
.setTimeoutMs(5 * Constants.SECOND_MS));
} catch (TimeoutException e) {
LOG.info(e.toString());
continue;
}
// Wait 2 election timeouts so that this master and other masters have time to realize they
// are not leader.
CommonUtils.sleepMs(2 * mConf.getElectionTimeoutMs());
if (stateMachine.getLastAppliedSequenceNumber() != lastAppliedSN
|| stateMachine.getLastPrimaryStartSequenceNumber() != gainPrimacySN) {
// Someone has committed a journal entry since we started trying to catch up.
// Restart the catchup process.
continue;
}
LOG.info("Caught up in {}ms. Last sequence number from previous term: {}.",
System.currentTimeMillis() - startTime, stateMachine.getLastAppliedSequenceNumber());
return;
}
}
|
[
"private",
"void",
"catchUp",
"(",
"JournalStateMachine",
"stateMachine",
",",
"CopycatClient",
"client",
")",
"throws",
"TimeoutException",
",",
"InterruptedException",
"{",
"long",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"// Wait for any outstanding snapshot to complete.",
"CommonUtils",
".",
"waitFor",
"(",
"\"snapshotting to finish\"",
",",
"(",
")",
"->",
"!",
"stateMachine",
".",
"isSnapshotting",
"(",
")",
",",
"WaitForOptions",
".",
"defaults",
"(",
")",
".",
"setTimeoutMs",
"(",
"10",
"*",
"Constants",
".",
"MINUTE_MS",
")",
")",
";",
"// Loop until we lose leadership or convince ourselves that we are caught up and we are the only",
"// master serving. To convince ourselves of this, we need to accomplish three steps:",
"//",
"// 1. Write a unique ID to the copycat.",
"// 2. Wait for the ID to by applied to the state machine. This proves that we are",
"// caught up since the copycat cannot apply commits from a previous term after applying",
"// commits from a later term.",
"// 3. Wait for a quiet period to elapse without anything new being written to Copycat. This is a",
"// heuristic to account for the time it takes for a node to realize it is no longer the",
"// leader. If two nodes think they are leader at the same time, they will both write unique",
"// IDs to the journal, but only the second one has a chance of becoming leader. The first",
"// will see that an entry was written after its ID, and double check that it is still the",
"// leader before trying again.",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"mPrimarySelector",
".",
"getState",
"(",
")",
"!=",
"PrimarySelector",
".",
"State",
".",
"PRIMARY",
")",
"{",
"return",
";",
"}",
"long",
"lastAppliedSN",
"=",
"stateMachine",
".",
"getLastAppliedSequenceNumber",
"(",
")",
";",
"long",
"gainPrimacySN",
"=",
"ThreadLocalRandom",
".",
"current",
"(",
")",
".",
"nextLong",
"(",
"Long",
".",
"MIN_VALUE",
",",
"0",
")",
";",
"LOG",
".",
"info",
"(",
"\"Performing catchup. Last applied SN: {}. Catchup ID: {}\"",
",",
"lastAppliedSN",
",",
"gainPrimacySN",
")",
";",
"CompletableFuture",
"<",
"Void",
">",
"future",
"=",
"client",
".",
"submit",
"(",
"new",
"JournalEntryCommand",
"(",
"JournalEntry",
".",
"newBuilder",
"(",
")",
".",
"setSequenceNumber",
"(",
"gainPrimacySN",
")",
".",
"build",
"(",
")",
")",
")",
";",
"try",
"{",
"future",
".",
"get",
"(",
"5",
",",
"TimeUnit",
".",
"SECONDS",
")",
";",
"}",
"catch",
"(",
"TimeoutException",
"|",
"ExecutionException",
"e",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Exception submitting term start entry: {}\"",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"continue",
";",
"}",
"try",
"{",
"CommonUtils",
".",
"waitFor",
"(",
"\"term start entry \"",
"+",
"gainPrimacySN",
"+",
"\" to be applied to state machine\"",
",",
"(",
")",
"->",
"stateMachine",
".",
"getLastPrimaryStartSequenceNumber",
"(",
")",
"==",
"gainPrimacySN",
",",
"WaitForOptions",
".",
"defaults",
"(",
")",
".",
"setInterval",
"(",
"Constants",
".",
"SECOND_MS",
")",
".",
"setTimeoutMs",
"(",
"5",
"*",
"Constants",
".",
"SECOND_MS",
")",
")",
";",
"}",
"catch",
"(",
"TimeoutException",
"e",
")",
"{",
"LOG",
".",
"info",
"(",
"e",
".",
"toString",
"(",
")",
")",
";",
"continue",
";",
"}",
"// Wait 2 election timeouts so that this master and other masters have time to realize they",
"// are not leader.",
"CommonUtils",
".",
"sleepMs",
"(",
"2",
"*",
"mConf",
".",
"getElectionTimeoutMs",
"(",
")",
")",
";",
"if",
"(",
"stateMachine",
".",
"getLastAppliedSequenceNumber",
"(",
")",
"!=",
"lastAppliedSN",
"||",
"stateMachine",
".",
"getLastPrimaryStartSequenceNumber",
"(",
")",
"!=",
"gainPrimacySN",
")",
"{",
"// Someone has committed a journal entry since we started trying to catch up.",
"// Restart the catchup process.",
"continue",
";",
"}",
"LOG",
".",
"info",
"(",
"\"Caught up in {}ms. Last sequence number from previous term: {}.\"",
",",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startTime",
",",
"stateMachine",
".",
"getLastAppliedSequenceNumber",
"(",
")",
")",
";",
"return",
";",
"}",
"}"
] |
Attempts to catch up. If the master loses leadership during this method, it will return early.
The caller is responsible for detecting and responding to leadership changes.
|
[
"Attempts",
"to",
"catch",
"up",
".",
"If",
"the",
"master",
"loses",
"leadership",
"during",
"this",
"method",
"it",
"will",
"return",
"early",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/raft/RaftJournalSystem.java#L335-L397
|
18,584
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/job/JobShell.java
|
JobShell.main
|
public static void main(String[] argv) throws IOException {
int ret;
InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
if (!ConfigurationUtils.masterHostConfigured(conf) && argv.length > 0) {
System.out.println(ConfigurationUtils
.getMasterHostNotConfiguredMessage("Alluxio job shell"));
System.exit(1);
}
try (JobShell shell = new JobShell(conf)) {
ret = shell.run(argv);
}
System.exit(ret);
}
|
java
|
public static void main(String[] argv) throws IOException {
int ret;
InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
if (!ConfigurationUtils.masterHostConfigured(conf) && argv.length > 0) {
System.out.println(ConfigurationUtils
.getMasterHostNotConfiguredMessage("Alluxio job shell"));
System.exit(1);
}
try (JobShell shell = new JobShell(conf)) {
ret = shell.run(argv);
}
System.exit(ret);
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"argv",
")",
"throws",
"IOException",
"{",
"int",
"ret",
";",
"InstancedConfiguration",
"conf",
"=",
"new",
"InstancedConfiguration",
"(",
"ConfigurationUtils",
".",
"defaults",
"(",
")",
")",
";",
"if",
"(",
"!",
"ConfigurationUtils",
".",
"masterHostConfigured",
"(",
"conf",
")",
"&&",
"argv",
".",
"length",
">",
"0",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"ConfigurationUtils",
".",
"getMasterHostNotConfiguredMessage",
"(",
"\"Alluxio job shell\"",
")",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"try",
"(",
"JobShell",
"shell",
"=",
"new",
"JobShell",
"(",
"conf",
")",
")",
"{",
"ret",
"=",
"shell",
".",
"run",
"(",
"argv",
")",
";",
"}",
"System",
".",
"exit",
"(",
"ret",
")",
";",
"}"
] |
Main method, starts a new JobShell.
@param argv array of arguments given by the user's input from the terminal
|
[
"Main",
"method",
"starts",
"a",
"new",
"JobShell",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/job/JobShell.java#L45-L59
|
18,585
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java
|
InodeLockList.lockInodeInternal
|
private void lockInodeInternal(Inode inode, LockMode mode) {
Preconditions.checkState(!endsInInode());
String lastEdgeName = ((EdgeEntry) lastEntry()).getEdge().getName();
Preconditions.checkState(inode.getName().equals(lastEdgeName),
"Expected to lock inode %s but locked inode %s", lastEdgeName, inode.getName());
mLockedInodes.add(inode);
mEntries.add(new InodeEntry(mInodeLockManager.lockInode(inode, mode), inode));
}
|
java
|
private void lockInodeInternal(Inode inode, LockMode mode) {
Preconditions.checkState(!endsInInode());
String lastEdgeName = ((EdgeEntry) lastEntry()).getEdge().getName();
Preconditions.checkState(inode.getName().equals(lastEdgeName),
"Expected to lock inode %s but locked inode %s", lastEdgeName, inode.getName());
mLockedInodes.add(inode);
mEntries.add(new InodeEntry(mInodeLockManager.lockInode(inode, mode), inode));
}
|
[
"private",
"void",
"lockInodeInternal",
"(",
"Inode",
"inode",
",",
"LockMode",
"mode",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"!",
"endsInInode",
"(",
")",
")",
";",
"String",
"lastEdgeName",
"=",
"(",
"(",
"EdgeEntry",
")",
"lastEntry",
"(",
")",
")",
".",
"getEdge",
"(",
")",
".",
"getName",
"(",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"inode",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"lastEdgeName",
")",
",",
"\"Expected to lock inode %s but locked inode %s\"",
",",
"lastEdgeName",
",",
"inode",
".",
"getName",
"(",
")",
")",
";",
"mLockedInodes",
".",
"add",
"(",
"inode",
")",
";",
"mEntries",
".",
"add",
"(",
"new",
"InodeEntry",
"(",
"mInodeLockManager",
".",
"lockInode",
"(",
"inode",
",",
"mode",
")",
",",
"inode",
")",
")",
";",
"}"
] |
Locks the next inode without checking or updating the mode.
@param inode the inode to lock
@param mode the mode to lock in
|
[
"Locks",
"the",
"next",
"inode",
"without",
"checking",
"or",
"updating",
"the",
"mode",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java#L91-L99
|
18,586
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java
|
InodeLockList.lockEdge
|
public void lockEdge(String childName, LockMode mode) {
Preconditions.checkState(endsInInode());
Preconditions.checkState(mLockMode == LockMode.READ);
lockEdgeInternal(childName, mode);
mLockMode = mode;
}
|
java
|
public void lockEdge(String childName, LockMode mode) {
Preconditions.checkState(endsInInode());
Preconditions.checkState(mLockMode == LockMode.READ);
lockEdgeInternal(childName, mode);
mLockMode = mode;
}
|
[
"public",
"void",
"lockEdge",
"(",
"String",
"childName",
",",
"LockMode",
"mode",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"endsInInode",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"mLockMode",
"==",
"LockMode",
".",
"READ",
")",
";",
"lockEdgeInternal",
"(",
"childName",
",",
"mode",
")",
";",
"mLockMode",
"=",
"mode",
";",
"}"
] |
Locks an edge leading out of the last inode in the list.
For example, if the lock list is [a, a->b, b], lockEdge(c) will add b->c to the list, resulting
in [a, a->b, b, b->c].
@param childName the child to lock
@param mode the mode to lock in
|
[
"Locks",
"an",
"edge",
"leading",
"out",
"of",
"the",
"last",
"inode",
"in",
"the",
"list",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java#L110-L116
|
18,587
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java
|
InodeLockList.lockEdgeInternal
|
public void lockEdgeInternal(String childName, LockMode mode) {
Preconditions.checkState(endsInInode());
Inode lastInode = get(numLockedInodes() - 1);
Edge edge = new Edge(lastInode.getId(), childName);
mEntries.add(new EdgeEntry(mInodeLockManager.lockEdge(edge, mode), edge));
}
|
java
|
public void lockEdgeInternal(String childName, LockMode mode) {
Preconditions.checkState(endsInInode());
Inode lastInode = get(numLockedInodes() - 1);
Edge edge = new Edge(lastInode.getId(), childName);
mEntries.add(new EdgeEntry(mInodeLockManager.lockEdge(edge, mode), edge));
}
|
[
"public",
"void",
"lockEdgeInternal",
"(",
"String",
"childName",
",",
"LockMode",
"mode",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"endsInInode",
"(",
")",
")",
";",
"Inode",
"lastInode",
"=",
"get",
"(",
"numLockedInodes",
"(",
")",
"-",
"1",
")",
";",
"Edge",
"edge",
"=",
"new",
"Edge",
"(",
"lastInode",
".",
"getId",
"(",
")",
",",
"childName",
")",
";",
"mEntries",
".",
"add",
"(",
"new",
"EdgeEntry",
"(",
"mInodeLockManager",
".",
"lockEdge",
"(",
"edge",
",",
"mode",
")",
",",
"edge",
")",
")",
";",
"}"
] |
Locks the next edge without checking or updating the mode.
@param childName the child to lock
@param mode the mode to lock in
|
[
"Locks",
"the",
"next",
"edge",
"without",
"checking",
"or",
"updating",
"the",
"mode",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java#L124-L130
|
18,588
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java
|
InodeLockList.lockRootEdge
|
public void lockRootEdge(LockMode mode) {
Preconditions.checkState(mEntries.isEmpty());
mEntries.add(new EdgeEntry(mInodeLockManager.lockEdge(ROOT_EDGE, mode), ROOT_EDGE));
mLockMode = mode;
}
|
java
|
public void lockRootEdge(LockMode mode) {
Preconditions.checkState(mEntries.isEmpty());
mEntries.add(new EdgeEntry(mInodeLockManager.lockEdge(ROOT_EDGE, mode), ROOT_EDGE));
mLockMode = mode;
}
|
[
"public",
"void",
"lockRootEdge",
"(",
"LockMode",
"mode",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"mEntries",
".",
"isEmpty",
"(",
")",
")",
";",
"mEntries",
".",
"add",
"(",
"new",
"EdgeEntry",
"(",
"mInodeLockManager",
".",
"lockEdge",
"(",
"ROOT_EDGE",
",",
"mode",
")",
",",
"ROOT_EDGE",
")",
")",
";",
"mLockMode",
"=",
"mode",
";",
"}"
] |
Locks the root edge in the specified mode.
@param mode the mode to lock in
|
[
"Locks",
"the",
"root",
"edge",
"in",
"the",
"specified",
"mode",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java#L137-L142
|
18,589
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java
|
InodeLockList.pushWriteLockedEdge
|
public void pushWriteLockedEdge(Inode inode, String childName) {
Preconditions.checkState(!endsInInode());
Preconditions.checkState(mLockMode == LockMode.WRITE);
if (mEntries.isEmpty()) {
// Cannot modify the base lock list, and the new inode is already implicitly locked.
return;
}
int edgeIndex = mEntries.size() - 1;
lockInodeInternal(inode, LockMode.READ);
lockEdgeInternal(childName, LockMode.WRITE);
downgradeEdge(edgeIndex);
}
|
java
|
public void pushWriteLockedEdge(Inode inode, String childName) {
Preconditions.checkState(!endsInInode());
Preconditions.checkState(mLockMode == LockMode.WRITE);
if (mEntries.isEmpty()) {
// Cannot modify the base lock list, and the new inode is already implicitly locked.
return;
}
int edgeIndex = mEntries.size() - 1;
lockInodeInternal(inode, LockMode.READ);
lockEdgeInternal(childName, LockMode.WRITE);
downgradeEdge(edgeIndex);
}
|
[
"public",
"void",
"pushWriteLockedEdge",
"(",
"Inode",
"inode",
",",
"String",
"childName",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"!",
"endsInInode",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"mLockMode",
"==",
"LockMode",
".",
"WRITE",
")",
";",
"if",
"(",
"mEntries",
".",
"isEmpty",
"(",
")",
")",
"{",
"// Cannot modify the base lock list, and the new inode is already implicitly locked.",
"return",
";",
"}",
"int",
"edgeIndex",
"=",
"mEntries",
".",
"size",
"(",
")",
"-",
"1",
";",
"lockInodeInternal",
"(",
"inode",
",",
"LockMode",
".",
"READ",
")",
";",
"lockEdgeInternal",
"(",
"childName",
",",
"LockMode",
".",
"WRITE",
")",
";",
"downgradeEdge",
"(",
"edgeIndex",
")",
";",
"}"
] |
Leapfrogs the edge write lock forward, reducing the lock list's write-locked scope.
For example, if the lock list is in write mode with entries [a, a->b, b, b->c],
pushWriteLockedEdge(c, d) will change the list to [a, a->b, b, b->c, c, c->d]. The c->d edge
will be write locked instead of the b->c edge. At least a read lock on b->c will be maintained
throughout the process so that other threads cannot interfere with creates, deletes, or
renames.
For composite lock lists, this method will do nothing if the base lock is is write locked.
@param inode the inode to add to the lock list
@param childName the child name for the edge to add to the lock list
|
[
"Leapfrogs",
"the",
"edge",
"write",
"lock",
"forward",
"reducing",
"the",
"lock",
"list",
"s",
"write",
"-",
"locked",
"scope",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java#L158-L171
|
18,590
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java
|
InodeLockList.unlockLastInode
|
public void unlockLastInode() {
Preconditions.checkState(endsInInode());
Preconditions.checkState(!mEntries.isEmpty());
mLockedInodes.remove(mLockedInodes.size() - 1);
mEntries.remove(mEntries.size() - 1).mLock.close();
mLockMode = LockMode.READ;
}
|
java
|
public void unlockLastInode() {
Preconditions.checkState(endsInInode());
Preconditions.checkState(!mEntries.isEmpty());
mLockedInodes.remove(mLockedInodes.size() - 1);
mEntries.remove(mEntries.size() - 1).mLock.close();
mLockMode = LockMode.READ;
}
|
[
"public",
"void",
"unlockLastInode",
"(",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"endsInInode",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"!",
"mEntries",
".",
"isEmpty",
"(",
")",
")",
";",
"mLockedInodes",
".",
"remove",
"(",
"mLockedInodes",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"mEntries",
".",
"remove",
"(",
"mEntries",
".",
"size",
"(",
")",
"-",
"1",
")",
".",
"mLock",
".",
"close",
"(",
")",
";",
"mLockMode",
"=",
"LockMode",
".",
"READ",
";",
"}"
] |
Unlocks the last locked inode.
|
[
"Unlocks",
"the",
"last",
"locked",
"inode",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java#L183-L190
|
18,591
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java
|
InodeLockList.downgradeLastInode
|
public void downgradeLastInode() {
Preconditions.checkState(endsInInode());
Preconditions.checkState(!mEntries.isEmpty());
Preconditions.checkState(mLockMode == LockMode.WRITE);
InodeEntry last = (InodeEntry) mEntries.get(mEntries.size() - 1);
LockResource lock = mInodeLockManager.lockInode(last.getInode(), LockMode.READ);
last.getLock().close();
mEntries.set(mEntries.size() - 1, new InodeEntry(lock, last.mInode));
mLockMode = LockMode.READ;
}
|
java
|
public void downgradeLastInode() {
Preconditions.checkState(endsInInode());
Preconditions.checkState(!mEntries.isEmpty());
Preconditions.checkState(mLockMode == LockMode.WRITE);
InodeEntry last = (InodeEntry) mEntries.get(mEntries.size() - 1);
LockResource lock = mInodeLockManager.lockInode(last.getInode(), LockMode.READ);
last.getLock().close();
mEntries.set(mEntries.size() - 1, new InodeEntry(lock, last.mInode));
mLockMode = LockMode.READ;
}
|
[
"public",
"void",
"downgradeLastInode",
"(",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"endsInInode",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"!",
"mEntries",
".",
"isEmpty",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"mLockMode",
"==",
"LockMode",
".",
"WRITE",
")",
";",
"InodeEntry",
"last",
"=",
"(",
"InodeEntry",
")",
"mEntries",
".",
"get",
"(",
"mEntries",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"LockResource",
"lock",
"=",
"mInodeLockManager",
".",
"lockInode",
"(",
"last",
".",
"getInode",
"(",
")",
",",
"LockMode",
".",
"READ",
")",
";",
"last",
".",
"getLock",
"(",
")",
".",
"close",
"(",
")",
";",
"mEntries",
".",
"set",
"(",
"mEntries",
".",
"size",
"(",
")",
"-",
"1",
",",
"new",
"InodeEntry",
"(",
"lock",
",",
"last",
".",
"mInode",
")",
")",
";",
"mLockMode",
"=",
"LockMode",
".",
"READ",
";",
"}"
] |
Downgrades the last inode from a write lock to a read lock. The read lock is acquired before
releasing the write lock.
|
[
"Downgrades",
"the",
"last",
"inode",
"from",
"a",
"write",
"lock",
"to",
"a",
"read",
"lock",
".",
"The",
"read",
"lock",
"is",
"acquired",
"before",
"releasing",
"the",
"write",
"lock",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java#L207-L217
|
18,592
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java
|
InodeLockList.downgradeLastEdge
|
public void downgradeLastEdge() {
Preconditions.checkNotNull(!endsInInode());
Preconditions.checkState(!mEntries.isEmpty());
Preconditions.checkState(mLockMode == LockMode.WRITE);
downgradeEdge(mEntries.size() - 1);
mLockMode = LockMode.READ;
}
|
java
|
public void downgradeLastEdge() {
Preconditions.checkNotNull(!endsInInode());
Preconditions.checkState(!mEntries.isEmpty());
Preconditions.checkState(mLockMode == LockMode.WRITE);
downgradeEdge(mEntries.size() - 1);
mLockMode = LockMode.READ;
}
|
[
"public",
"void",
"downgradeLastEdge",
"(",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"!",
"endsInInode",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"!",
"mEntries",
".",
"isEmpty",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"mLockMode",
"==",
"LockMode",
".",
"WRITE",
")",
";",
"downgradeEdge",
"(",
"mEntries",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"mLockMode",
"=",
"LockMode",
".",
"READ",
";",
"}"
] |
Downgrades the last edge lock in the lock list from WRITE lock to READ lock.
|
[
"Downgrades",
"the",
"last",
"edge",
"lock",
"in",
"the",
"lock",
"list",
"from",
"WRITE",
"lock",
"to",
"READ",
"lock",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java#L222-L229
|
18,593
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java
|
InodeLockList.downgradeEdgeToInode
|
public void downgradeEdgeToInode(Inode inode, LockMode mode) {
Preconditions.checkState(!endsInInode());
Preconditions.checkState(!mEntries.isEmpty());
Preconditions.checkState(mLockMode == LockMode.WRITE);
EdgeEntry last = (EdgeEntry) mEntries.get(mEntries.size() - 1);
LockResource inodeLock = mInodeLockManager.lockInode(inode, mode);
LockResource edgeLock = mInodeLockManager.lockEdge(last.mEdge, LockMode.READ);
last.getLock().close();
mEntries.set(mEntries.size() - 1, new EdgeEntry(edgeLock, last.getEdge()));
mEntries.add(new InodeEntry(inodeLock, inode));
mLockedInodes.add(inode);
mLockMode = mode;
}
|
java
|
public void downgradeEdgeToInode(Inode inode, LockMode mode) {
Preconditions.checkState(!endsInInode());
Preconditions.checkState(!mEntries.isEmpty());
Preconditions.checkState(mLockMode == LockMode.WRITE);
EdgeEntry last = (EdgeEntry) mEntries.get(mEntries.size() - 1);
LockResource inodeLock = mInodeLockManager.lockInode(inode, mode);
LockResource edgeLock = mInodeLockManager.lockEdge(last.mEdge, LockMode.READ);
last.getLock().close();
mEntries.set(mEntries.size() - 1, new EdgeEntry(edgeLock, last.getEdge()));
mEntries.add(new InodeEntry(inodeLock, inode));
mLockedInodes.add(inode);
mLockMode = mode;
}
|
[
"public",
"void",
"downgradeEdgeToInode",
"(",
"Inode",
"inode",
",",
"LockMode",
"mode",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"!",
"endsInInode",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"!",
"mEntries",
".",
"isEmpty",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"mLockMode",
"==",
"LockMode",
".",
"WRITE",
")",
";",
"EdgeEntry",
"last",
"=",
"(",
"EdgeEntry",
")",
"mEntries",
".",
"get",
"(",
"mEntries",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"LockResource",
"inodeLock",
"=",
"mInodeLockManager",
".",
"lockInode",
"(",
"inode",
",",
"mode",
")",
";",
"LockResource",
"edgeLock",
"=",
"mInodeLockManager",
".",
"lockEdge",
"(",
"last",
".",
"mEdge",
",",
"LockMode",
".",
"READ",
")",
";",
"last",
".",
"getLock",
"(",
")",
".",
"close",
"(",
")",
";",
"mEntries",
".",
"set",
"(",
"mEntries",
".",
"size",
"(",
")",
"-",
"1",
",",
"new",
"EdgeEntry",
"(",
"edgeLock",
",",
"last",
".",
"getEdge",
"(",
")",
")",
")",
";",
"mEntries",
".",
"add",
"(",
"new",
"InodeEntry",
"(",
"inodeLock",
",",
"inode",
")",
")",
";",
"mLockedInodes",
".",
"add",
"(",
"inode",
")",
";",
"mLockMode",
"=",
"mode",
";",
"}"
] |
Downgrades from edge write-locking to inode write-locking. This reduces the scope of the write
lock by pushing it forward one entry.
For example, if the lock list is in write mode with entries [a, a->b, b, b->c],
downgradeEdgeToInode(c, mode) will change the list to [a, a->b, b, b->c, c], with b->c
downgraded to a read lock. c will be locked according to the mode.
The read lock on the final edge is taken before releasing the write lock.
@param inode the next inode in the lock list
@param mode the mode to downgrade to
|
[
"Downgrades",
"from",
"edge",
"write",
"-",
"locking",
"to",
"inode",
"write",
"-",
"locking",
".",
"This",
"reduces",
"the",
"scope",
"of",
"the",
"write",
"lock",
"by",
"pushing",
"it",
"forward",
"one",
"entry",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java#L244-L257
|
18,594
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java
|
InodeLockList.downgradeEdge
|
private void downgradeEdge(int edgeEntryIndex) {
EdgeEntry entry = (EdgeEntry) mEntries.get(edgeEntryIndex);
LockResource lock = mInodeLockManager.lockEdge(entry.mEdge, LockMode.READ);
entry.getLock().close();
mEntries.set(edgeEntryIndex, new EdgeEntry(lock, entry.getEdge()));
}
|
java
|
private void downgradeEdge(int edgeEntryIndex) {
EdgeEntry entry = (EdgeEntry) mEntries.get(edgeEntryIndex);
LockResource lock = mInodeLockManager.lockEdge(entry.mEdge, LockMode.READ);
entry.getLock().close();
mEntries.set(edgeEntryIndex, new EdgeEntry(lock, entry.getEdge()));
}
|
[
"private",
"void",
"downgradeEdge",
"(",
"int",
"edgeEntryIndex",
")",
"{",
"EdgeEntry",
"entry",
"=",
"(",
"EdgeEntry",
")",
"mEntries",
".",
"get",
"(",
"edgeEntryIndex",
")",
";",
"LockResource",
"lock",
"=",
"mInodeLockManager",
".",
"lockEdge",
"(",
"entry",
".",
"mEdge",
",",
"LockMode",
".",
"READ",
")",
";",
"entry",
".",
"getLock",
"(",
")",
".",
"close",
"(",
")",
";",
"mEntries",
".",
"set",
"(",
"edgeEntryIndex",
",",
"new",
"EdgeEntry",
"(",
"lock",
",",
"entry",
".",
"getEdge",
"(",
")",
")",
")",
";",
"}"
] |
Downgrades the edge at the specified entry index.
|
[
"Downgrades",
"the",
"edge",
"at",
"the",
"specified",
"entry",
"index",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/InodeLockList.java#L262-L267
|
18,595
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/AlluxioURI.java
|
AlluxioURI.hasWindowsDrive
|
public static boolean hasWindowsDrive(String path, boolean slashed) {
int start = slashed ? 1 : 0;
return path.length() >= start + 2
&& (!slashed || path.charAt(0) == '/')
&& path.charAt(start + 1) == ':'
&& ((path.charAt(start) >= 'A' && path.charAt(start) <= 'Z') || (path.charAt(start) >= 'a'
&& path.charAt(start) <= 'z'));
}
|
java
|
public static boolean hasWindowsDrive(String path, boolean slashed) {
int start = slashed ? 1 : 0;
return path.length() >= start + 2
&& (!slashed || path.charAt(0) == '/')
&& path.charAt(start + 1) == ':'
&& ((path.charAt(start) >= 'A' && path.charAt(start) <= 'Z') || (path.charAt(start) >= 'a'
&& path.charAt(start) <= 'z'));
}
|
[
"public",
"static",
"boolean",
"hasWindowsDrive",
"(",
"String",
"path",
",",
"boolean",
"slashed",
")",
"{",
"int",
"start",
"=",
"slashed",
"?",
"1",
":",
"0",
";",
"return",
"path",
".",
"length",
"(",
")",
">=",
"start",
"+",
"2",
"&&",
"(",
"!",
"slashed",
"||",
"path",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"&&",
"path",
".",
"charAt",
"(",
"start",
"+",
"1",
")",
"==",
"'",
"'",
"&&",
"(",
"(",
"path",
".",
"charAt",
"(",
"start",
")",
">=",
"'",
"'",
"&&",
"path",
".",
"charAt",
"(",
"start",
")",
"<=",
"'",
"'",
")",
"||",
"(",
"path",
".",
"charAt",
"(",
"start",
")",
">=",
"'",
"'",
"&&",
"path",
".",
"charAt",
"(",
"start",
")",
"<=",
"'",
"'",
")",
")",
";",
"}"
] |
Checks if the path is a windows path. This should be platform independent.
@param path the path to check
@param slashed if the path starts with a slash
@return true if it is a windows path, false otherwise
|
[
"Checks",
"if",
"the",
"path",
"is",
"a",
"windows",
"path",
".",
"This",
"should",
"be",
"platform",
"independent",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/AlluxioURI.java#L335-L342
|
18,596
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/AlluxioURI.java
|
AlluxioURI.isAncestorOf
|
public boolean isAncestorOf(AlluxioURI alluxioURI) throws InvalidPathException {
// To be an ancestor of another URI, authority and scheme must match
if (!Objects.equals(getAuthority(), alluxioURI.getAuthority())) {
return false;
}
if (!Objects.equals(getScheme(), alluxioURI.getScheme())) {
return false;
}
return PathUtils.hasPrefix(PathUtils.normalizePath(alluxioURI.getPath(), SEPARATOR),
PathUtils.normalizePath(getPath(), SEPARATOR));
}
|
java
|
public boolean isAncestorOf(AlluxioURI alluxioURI) throws InvalidPathException {
// To be an ancestor of another URI, authority and scheme must match
if (!Objects.equals(getAuthority(), alluxioURI.getAuthority())) {
return false;
}
if (!Objects.equals(getScheme(), alluxioURI.getScheme())) {
return false;
}
return PathUtils.hasPrefix(PathUtils.normalizePath(alluxioURI.getPath(), SEPARATOR),
PathUtils.normalizePath(getPath(), SEPARATOR));
}
|
[
"public",
"boolean",
"isAncestorOf",
"(",
"AlluxioURI",
"alluxioURI",
")",
"throws",
"InvalidPathException",
"{",
"// To be an ancestor of another URI, authority and scheme must match",
"if",
"(",
"!",
"Objects",
".",
"equals",
"(",
"getAuthority",
"(",
")",
",",
"alluxioURI",
".",
"getAuthority",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"Objects",
".",
"equals",
"(",
"getScheme",
"(",
")",
",",
"alluxioURI",
".",
"getScheme",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"PathUtils",
".",
"hasPrefix",
"(",
"PathUtils",
".",
"normalizePath",
"(",
"alluxioURI",
".",
"getPath",
"(",
")",
",",
"SEPARATOR",
")",
",",
"PathUtils",
".",
"normalizePath",
"(",
"getPath",
"(",
")",
",",
"SEPARATOR",
")",
")",
";",
"}"
] |
Returns true if the current AlluxioURI is an ancestor of another AlluxioURI.
otherwise, return false.
@param alluxioURI potential children to check
@return true the current alluxioURI is an ancestor of the AlluxioURI
|
[
"Returns",
"true",
"if",
"the",
"current",
"AlluxioURI",
"is",
"an",
"ancestor",
"of",
"another",
"AlluxioURI",
".",
"otherwise",
"return",
"false",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/AlluxioURI.java#L454-L465
|
18,597
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/stream/LocalFileDataWriter.java
|
LocalFileDataWriter.ensureReserved
|
private void ensureReserved(long pos) throws IOException {
if (pos <= mPosReserved) {
return;
}
long toReserve = Math.max(pos - mPosReserved, mFileBufferBytes);
CreateLocalBlockRequest request = mCreateRequest.toBuilder().setSpaceToReserve(toReserve)
.setOnlyReserveSpace(true).build();
mStream.send(request, mDataTimeoutMs);
CreateLocalBlockResponse response = mStream.receive(mDataTimeoutMs);
Preconditions.checkState(response != null,
String.format("Stream closed while waiting for reserve request %s", request.toString()));
Preconditions.checkState(!response.hasPath(),
String.format("Invalid response for reserve request %s", request.toString()));
mPosReserved += toReserve;
}
|
java
|
private void ensureReserved(long pos) throws IOException {
if (pos <= mPosReserved) {
return;
}
long toReserve = Math.max(pos - mPosReserved, mFileBufferBytes);
CreateLocalBlockRequest request = mCreateRequest.toBuilder().setSpaceToReserve(toReserve)
.setOnlyReserveSpace(true).build();
mStream.send(request, mDataTimeoutMs);
CreateLocalBlockResponse response = mStream.receive(mDataTimeoutMs);
Preconditions.checkState(response != null,
String.format("Stream closed while waiting for reserve request %s", request.toString()));
Preconditions.checkState(!response.hasPath(),
String.format("Invalid response for reserve request %s", request.toString()));
mPosReserved += toReserve;
}
|
[
"private",
"void",
"ensureReserved",
"(",
"long",
"pos",
")",
"throws",
"IOException",
"{",
"if",
"(",
"pos",
"<=",
"mPosReserved",
")",
"{",
"return",
";",
"}",
"long",
"toReserve",
"=",
"Math",
".",
"max",
"(",
"pos",
"-",
"mPosReserved",
",",
"mFileBufferBytes",
")",
";",
"CreateLocalBlockRequest",
"request",
"=",
"mCreateRequest",
".",
"toBuilder",
"(",
")",
".",
"setSpaceToReserve",
"(",
"toReserve",
")",
".",
"setOnlyReserveSpace",
"(",
"true",
")",
".",
"build",
"(",
")",
";",
"mStream",
".",
"send",
"(",
"request",
",",
"mDataTimeoutMs",
")",
";",
"CreateLocalBlockResponse",
"response",
"=",
"mStream",
".",
"receive",
"(",
"mDataTimeoutMs",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"response",
"!=",
"null",
",",
"String",
".",
"format",
"(",
"\"Stream closed while waiting for reserve request %s\"",
",",
"request",
".",
"toString",
"(",
")",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"!",
"response",
".",
"hasPath",
"(",
")",
",",
"String",
".",
"format",
"(",
"\"Invalid response for reserve request %s\"",
",",
"request",
".",
"toString",
"(",
")",
")",
")",
";",
"mPosReserved",
"+=",
"toReserve",
";",
"}"
] |
Reserves enough space in the block worker.
@param pos the pos of the file/block to reserve to
|
[
"Reserves",
"enough",
"space",
"in",
"the",
"block",
"worker",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/stream/LocalFileDataWriter.java#L198-L212
|
18,598
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/LogLevel.java
|
LogLevel.logLevel
|
public static void logLevel(String[] args, AlluxioConfiguration alluxioConf)
throws ParseException, IOException {
CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse(OPTIONS, args, true /* stopAtNonOption */);
List<TargetInfo> targets = parseOptTarget(cmd, alluxioConf);
String logName = parseOptLogName(cmd);
String level = parseOptLevel(cmd);
for (TargetInfo targetInfo : targets) {
setLogLevel(targetInfo, logName, level);
}
}
|
java
|
public static void logLevel(String[] args, AlluxioConfiguration alluxioConf)
throws ParseException, IOException {
CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse(OPTIONS, args, true /* stopAtNonOption */);
List<TargetInfo> targets = parseOptTarget(cmd, alluxioConf);
String logName = parseOptLogName(cmd);
String level = parseOptLevel(cmd);
for (TargetInfo targetInfo : targets) {
setLogLevel(targetInfo, logName, level);
}
}
|
[
"public",
"static",
"void",
"logLevel",
"(",
"String",
"[",
"]",
"args",
",",
"AlluxioConfiguration",
"alluxioConf",
")",
"throws",
"ParseException",
",",
"IOException",
"{",
"CommandLineParser",
"parser",
"=",
"new",
"DefaultParser",
"(",
")",
";",
"CommandLine",
"cmd",
"=",
"parser",
".",
"parse",
"(",
"OPTIONS",
",",
"args",
",",
"true",
"/* stopAtNonOption */",
")",
";",
"List",
"<",
"TargetInfo",
">",
"targets",
"=",
"parseOptTarget",
"(",
"cmd",
",",
"alluxioConf",
")",
";",
"String",
"logName",
"=",
"parseOptLogName",
"(",
"cmd",
")",
";",
"String",
"level",
"=",
"parseOptLevel",
"(",
"cmd",
")",
";",
"for",
"(",
"TargetInfo",
"targetInfo",
":",
"targets",
")",
"{",
"setLogLevel",
"(",
"targetInfo",
",",
"logName",
",",
"level",
")",
";",
"}",
"}"
] |
Implements log level setting and getting.
@param args list of arguments contains target, logName and level
@param alluxioConf Alluxio configuration
@exception ParseException if there is an error in parsing
|
[
"Implements",
"log",
"level",
"setting",
"and",
"getting",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/LogLevel.java#L106-L118
|
18,599
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/LogLevel.java
|
LogLevel.main
|
public static void main(String[] args) {
int exitCode = 1;
try {
logLevel(args, new InstancedConfiguration(ConfigurationUtils.defaults()));
exitCode = 0;
} catch (ParseException e) {
printHelp("Unable to parse input args: " + e.getMessage());
} catch (IOException e) {
e.printStackTrace();
System.err.println(String.format("Failed to set log level: %s", e.getMessage()));
}
System.exit(exitCode);
}
|
java
|
public static void main(String[] args) {
int exitCode = 1;
try {
logLevel(args, new InstancedConfiguration(ConfigurationUtils.defaults()));
exitCode = 0;
} catch (ParseException e) {
printHelp("Unable to parse input args: " + e.getMessage());
} catch (IOException e) {
e.printStackTrace();
System.err.println(String.format("Failed to set log level: %s", e.getMessage()));
}
System.exit(exitCode);
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"int",
"exitCode",
"=",
"1",
";",
"try",
"{",
"logLevel",
"(",
"args",
",",
"new",
"InstancedConfiguration",
"(",
"ConfigurationUtils",
".",
"defaults",
"(",
")",
")",
")",
";",
"exitCode",
"=",
"0",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"printHelp",
"(",
"\"Unable to parse input args: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"System",
".",
"err",
".",
"println",
"(",
"String",
".",
"format",
"(",
"\"Failed to set log level: %s\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"System",
".",
"exit",
"(",
"exitCode",
")",
";",
"}"
] |
Sets or gets log level of master and worker through their REST API.
@param args same arguments as {@link LogLevel}
|
[
"Sets",
"or",
"gets",
"log",
"level",
"of",
"master",
"and",
"worker",
"through",
"their",
"REST",
"API",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/LogLevel.java#L210-L222
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.