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,300
|
Alluxio/alluxio
|
underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java
|
S3ALowLevelOutputStream.initMultiPartUpload
|
private void initMultiPartUpload() throws IOException {
// Generate the object metadata by setting server side encryption, md5 checksum,
// and encoding as octet stream since no assumptions are made about the file type
ObjectMetadata meta = new ObjectMetadata();
if (mSseEnabled) {
meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
}
if (mHash != null) {
meta.setContentMD5(Base64.encodeAsString(mHash.digest()));
}
meta.setContentType(Mimetypes.MIMETYPE_OCTET_STREAM);
AmazonClientException lastException;
InitiateMultipartUploadRequest initRequest =
new InitiateMultipartUploadRequest(mBucketName, mKey).withObjectMetadata(meta);
do {
try {
mUploadId = mClient.initiateMultipartUpload(initRequest).getUploadId();
return;
} catch (AmazonClientException e) {
lastException = e;
}
} while (mRetryPolicy.attempt());
// This point is only reached if the operation failed more
// than the allowed retry count
throw new IOException("Unable to init multipart upload to " + mKey, lastException);
}
|
java
|
private void initMultiPartUpload() throws IOException {
// Generate the object metadata by setting server side encryption, md5 checksum,
// and encoding as octet stream since no assumptions are made about the file type
ObjectMetadata meta = new ObjectMetadata();
if (mSseEnabled) {
meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION);
}
if (mHash != null) {
meta.setContentMD5(Base64.encodeAsString(mHash.digest()));
}
meta.setContentType(Mimetypes.MIMETYPE_OCTET_STREAM);
AmazonClientException lastException;
InitiateMultipartUploadRequest initRequest =
new InitiateMultipartUploadRequest(mBucketName, mKey).withObjectMetadata(meta);
do {
try {
mUploadId = mClient.initiateMultipartUpload(initRequest).getUploadId();
return;
} catch (AmazonClientException e) {
lastException = e;
}
} while (mRetryPolicy.attempt());
// This point is only reached if the operation failed more
// than the allowed retry count
throw new IOException("Unable to init multipart upload to " + mKey, lastException);
}
|
[
"private",
"void",
"initMultiPartUpload",
"(",
")",
"throws",
"IOException",
"{",
"// Generate the object metadata by setting server side encryption, md5 checksum,",
"// and encoding as octet stream since no assumptions are made about the file type",
"ObjectMetadata",
"meta",
"=",
"new",
"ObjectMetadata",
"(",
")",
";",
"if",
"(",
"mSseEnabled",
")",
"{",
"meta",
".",
"setSSEAlgorithm",
"(",
"ObjectMetadata",
".",
"AES_256_SERVER_SIDE_ENCRYPTION",
")",
";",
"}",
"if",
"(",
"mHash",
"!=",
"null",
")",
"{",
"meta",
".",
"setContentMD5",
"(",
"Base64",
".",
"encodeAsString",
"(",
"mHash",
".",
"digest",
"(",
")",
")",
")",
";",
"}",
"meta",
".",
"setContentType",
"(",
"Mimetypes",
".",
"MIMETYPE_OCTET_STREAM",
")",
";",
"AmazonClientException",
"lastException",
";",
"InitiateMultipartUploadRequest",
"initRequest",
"=",
"new",
"InitiateMultipartUploadRequest",
"(",
"mBucketName",
",",
"mKey",
")",
".",
"withObjectMetadata",
"(",
"meta",
")",
";",
"do",
"{",
"try",
"{",
"mUploadId",
"=",
"mClient",
".",
"initiateMultipartUpload",
"(",
"initRequest",
")",
".",
"getUploadId",
"(",
")",
";",
"return",
";",
"}",
"catch",
"(",
"AmazonClientException",
"e",
")",
"{",
"lastException",
"=",
"e",
";",
"}",
"}",
"while",
"(",
"mRetryPolicy",
".",
"attempt",
"(",
")",
")",
";",
"// This point is only reached if the operation failed more",
"// than the allowed retry count",
"throw",
"new",
"IOException",
"(",
"\"Unable to init multipart upload to \"",
"+",
"mKey",
",",
"lastException",
")",
";",
"}"
] |
Initializes multipart upload.
|
[
"Initializes",
"multipart",
"upload",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java#L278-L304
|
18,301
|
Alluxio/alluxio
|
underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java
|
S3ALowLevelOutputStream.initNewFile
|
private void initNewFile() throws IOException {
mFile = new File(PathUtils.concatPath(CommonUtils.getTmpDir(mTmpDirs), UUID.randomUUID()));
if (mHash != null) {
mLocalOutputStream =
new BufferedOutputStream(new DigestOutputStream(new FileOutputStream(mFile), mHash));
} else {
mLocalOutputStream = new BufferedOutputStream(new FileOutputStream(mFile));
}
mPartitionOffset = 0;
LOG.debug("Init new temp file @ {}", mFile.getPath());
}
|
java
|
private void initNewFile() throws IOException {
mFile = new File(PathUtils.concatPath(CommonUtils.getTmpDir(mTmpDirs), UUID.randomUUID()));
if (mHash != null) {
mLocalOutputStream =
new BufferedOutputStream(new DigestOutputStream(new FileOutputStream(mFile), mHash));
} else {
mLocalOutputStream = new BufferedOutputStream(new FileOutputStream(mFile));
}
mPartitionOffset = 0;
LOG.debug("Init new temp file @ {}", mFile.getPath());
}
|
[
"private",
"void",
"initNewFile",
"(",
")",
"throws",
"IOException",
"{",
"mFile",
"=",
"new",
"File",
"(",
"PathUtils",
".",
"concatPath",
"(",
"CommonUtils",
".",
"getTmpDir",
"(",
"mTmpDirs",
")",
",",
"UUID",
".",
"randomUUID",
"(",
")",
")",
")",
";",
"if",
"(",
"mHash",
"!=",
"null",
")",
"{",
"mLocalOutputStream",
"=",
"new",
"BufferedOutputStream",
"(",
"new",
"DigestOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"mFile",
")",
",",
"mHash",
")",
")",
";",
"}",
"else",
"{",
"mLocalOutputStream",
"=",
"new",
"BufferedOutputStream",
"(",
"new",
"FileOutputStream",
"(",
"mFile",
")",
")",
";",
"}",
"mPartitionOffset",
"=",
"0",
";",
"LOG",
".",
"debug",
"(",
"\"Init new temp file @ {}\"",
",",
"mFile",
".",
"getPath",
"(",
")",
")",
";",
"}"
] |
Creates a new temp file to write to.
|
[
"Creates",
"a",
"new",
"temp",
"file",
"to",
"write",
"to",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java#L309-L319
|
18,302
|
Alluxio/alluxio
|
underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java
|
S3ALowLevelOutputStream.uploadPart
|
private void uploadPart() throws IOException {
if (mFile == null) {
return;
}
mLocalOutputStream.close();
int partNumber = mPartNumber.getAndIncrement();
File newFileToUpload = new File(mFile.getPath());
mFile = null;
mLocalOutputStream = null;
UploadPartRequest uploadRequest = new UploadPartRequest()
.withBucketName(mBucketName)
.withKey(mKey)
.withUploadId(mUploadId)
.withPartNumber(partNumber)
.withFile(newFileToUpload)
.withPartSize(newFileToUpload.length());
execUpload(uploadRequest);
}
|
java
|
private void uploadPart() throws IOException {
if (mFile == null) {
return;
}
mLocalOutputStream.close();
int partNumber = mPartNumber.getAndIncrement();
File newFileToUpload = new File(mFile.getPath());
mFile = null;
mLocalOutputStream = null;
UploadPartRequest uploadRequest = new UploadPartRequest()
.withBucketName(mBucketName)
.withKey(mKey)
.withUploadId(mUploadId)
.withPartNumber(partNumber)
.withFile(newFileToUpload)
.withPartSize(newFileToUpload.length());
execUpload(uploadRequest);
}
|
[
"private",
"void",
"uploadPart",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mFile",
"==",
"null",
")",
"{",
"return",
";",
"}",
"mLocalOutputStream",
".",
"close",
"(",
")",
";",
"int",
"partNumber",
"=",
"mPartNumber",
".",
"getAndIncrement",
"(",
")",
";",
"File",
"newFileToUpload",
"=",
"new",
"File",
"(",
"mFile",
".",
"getPath",
"(",
")",
")",
";",
"mFile",
"=",
"null",
";",
"mLocalOutputStream",
"=",
"null",
";",
"UploadPartRequest",
"uploadRequest",
"=",
"new",
"UploadPartRequest",
"(",
")",
".",
"withBucketName",
"(",
"mBucketName",
")",
".",
"withKey",
"(",
"mKey",
")",
".",
"withUploadId",
"(",
"mUploadId",
")",
".",
"withPartNumber",
"(",
"partNumber",
")",
".",
"withFile",
"(",
"newFileToUpload",
")",
".",
"withPartSize",
"(",
"newFileToUpload",
".",
"length",
"(",
")",
")",
";",
"execUpload",
"(",
"uploadRequest",
")",
";",
"}"
] |
Uploads part async.
|
[
"Uploads",
"part",
"async",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java#L324-L341
|
18,303
|
Alluxio/alluxio
|
underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java
|
S3ALowLevelOutputStream.execUpload
|
private void execUpload(UploadPartRequest request) {
File file = request.getFile();
ListenableFuture<PartETag> futureTag =
mExecutor.submit((Callable) () -> {
PartETag partETag;
AmazonClientException lastException;
try {
do {
try {
partETag = mClient.uploadPart(request).getPartETag();
return partETag;
} catch (AmazonClientException e) {
lastException = e;
}
} while (mRetryPolicy.attempt());
} finally {
// Delete the uploaded or failed to upload file
if (!file.delete()) {
LOG.error("Failed to delete temporary file @ {}", file.getPath());
}
}
throw new IOException("Fail to upload part " + request.getPartNumber()
+ " to " + request.getKey(), lastException);
});
mTagFutures.add(futureTag);
LOG.debug("Submit upload part request. key={}, partNum={}, file={}, fileSize={}, lastPart={}.",
mKey, request.getPartNumber(), file.getPath(), file.length(), request.isLastPart());
}
|
java
|
private void execUpload(UploadPartRequest request) {
File file = request.getFile();
ListenableFuture<PartETag> futureTag =
mExecutor.submit((Callable) () -> {
PartETag partETag;
AmazonClientException lastException;
try {
do {
try {
partETag = mClient.uploadPart(request).getPartETag();
return partETag;
} catch (AmazonClientException e) {
lastException = e;
}
} while (mRetryPolicy.attempt());
} finally {
// Delete the uploaded or failed to upload file
if (!file.delete()) {
LOG.error("Failed to delete temporary file @ {}", file.getPath());
}
}
throw new IOException("Fail to upload part " + request.getPartNumber()
+ " to " + request.getKey(), lastException);
});
mTagFutures.add(futureTag);
LOG.debug("Submit upload part request. key={}, partNum={}, file={}, fileSize={}, lastPart={}.",
mKey, request.getPartNumber(), file.getPath(), file.length(), request.isLastPart());
}
|
[
"private",
"void",
"execUpload",
"(",
"UploadPartRequest",
"request",
")",
"{",
"File",
"file",
"=",
"request",
".",
"getFile",
"(",
")",
";",
"ListenableFuture",
"<",
"PartETag",
">",
"futureTag",
"=",
"mExecutor",
".",
"submit",
"(",
"(",
"Callable",
")",
"(",
")",
"->",
"{",
"PartETag",
"partETag",
";",
"AmazonClientException",
"lastException",
";",
"try",
"{",
"do",
"{",
"try",
"{",
"partETag",
"=",
"mClient",
".",
"uploadPart",
"(",
"request",
")",
".",
"getPartETag",
"(",
")",
";",
"return",
"partETag",
";",
"}",
"catch",
"(",
"AmazonClientException",
"e",
")",
"{",
"lastException",
"=",
"e",
";",
"}",
"}",
"while",
"(",
"mRetryPolicy",
".",
"attempt",
"(",
")",
")",
";",
"}",
"finally",
"{",
"// Delete the uploaded or failed to upload file",
"if",
"(",
"!",
"file",
".",
"delete",
"(",
")",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to delete temporary file @ {}\"",
",",
"file",
".",
"getPath",
"(",
")",
")",
";",
"}",
"}",
"throw",
"new",
"IOException",
"(",
"\"Fail to upload part \"",
"+",
"request",
".",
"getPartNumber",
"(",
")",
"+",
"\" to \"",
"+",
"request",
".",
"getKey",
"(",
")",
",",
"lastException",
")",
";",
"}",
")",
";",
"mTagFutures",
".",
"add",
"(",
"futureTag",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Submit upload part request. key={}, partNum={}, file={}, fileSize={}, lastPart={}.\"",
",",
"mKey",
",",
"request",
".",
"getPartNumber",
"(",
")",
",",
"file",
".",
"getPath",
"(",
")",
",",
"file",
".",
"length",
"(",
")",
",",
"request",
".",
"isLastPart",
"(",
")",
")",
";",
"}"
] |
Executes the upload part request.
@param request the upload part request
|
[
"Executes",
"the",
"upload",
"part",
"request",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java#L348-L375
|
18,304
|
Alluxio/alluxio
|
underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java
|
S3ALowLevelOutputStream.waitForAllPartsUpload
|
private void waitForAllPartsUpload() throws IOException {
int beforeSize = mTags.size();
try {
for (ListenableFuture<PartETag> future : mTagFutures) {
mTags.add(future.get());
}
} catch (ExecutionException e) {
// No recover ways so that we need to cancel all the upload tasks
// and abort the multipart upload
Futures.allAsList(mTagFutures).cancel(true);
abortMultiPartUpload();
throw new IOException("Part upload failed in multipart upload with "
+ "id '" + mUploadId + "' to " + mKey, e);
} catch (InterruptedException e) {
LOG.warn("Interrupted object upload.", e);
Futures.allAsList(mTagFutures).cancel(true);
abortMultiPartUpload();
Thread.currentThread().interrupt();
}
mTagFutures = new ArrayList<>();
if (mTags.size() != beforeSize) {
LOG.debug("Uploaded {} partitions of id '{}' to {}.", mTags.size(), mUploadId, mKey);
}
}
|
java
|
private void waitForAllPartsUpload() throws IOException {
int beforeSize = mTags.size();
try {
for (ListenableFuture<PartETag> future : mTagFutures) {
mTags.add(future.get());
}
} catch (ExecutionException e) {
// No recover ways so that we need to cancel all the upload tasks
// and abort the multipart upload
Futures.allAsList(mTagFutures).cancel(true);
abortMultiPartUpload();
throw new IOException("Part upload failed in multipart upload with "
+ "id '" + mUploadId + "' to " + mKey, e);
} catch (InterruptedException e) {
LOG.warn("Interrupted object upload.", e);
Futures.allAsList(mTagFutures).cancel(true);
abortMultiPartUpload();
Thread.currentThread().interrupt();
}
mTagFutures = new ArrayList<>();
if (mTags.size() != beforeSize) {
LOG.debug("Uploaded {} partitions of id '{}' to {}.", mTags.size(), mUploadId, mKey);
}
}
|
[
"private",
"void",
"waitForAllPartsUpload",
"(",
")",
"throws",
"IOException",
"{",
"int",
"beforeSize",
"=",
"mTags",
".",
"size",
"(",
")",
";",
"try",
"{",
"for",
"(",
"ListenableFuture",
"<",
"PartETag",
">",
"future",
":",
"mTagFutures",
")",
"{",
"mTags",
".",
"add",
"(",
"future",
".",
"get",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"// No recover ways so that we need to cancel all the upload tasks",
"// and abort the multipart upload",
"Futures",
".",
"allAsList",
"(",
"mTagFutures",
")",
".",
"cancel",
"(",
"true",
")",
";",
"abortMultiPartUpload",
"(",
")",
";",
"throw",
"new",
"IOException",
"(",
"\"Part upload failed in multipart upload with \"",
"+",
"\"id '\"",
"+",
"mUploadId",
"+",
"\"' to \"",
"+",
"mKey",
",",
"e",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Interrupted object upload.\"",
",",
"e",
")",
";",
"Futures",
".",
"allAsList",
"(",
"mTagFutures",
")",
".",
"cancel",
"(",
"true",
")",
";",
"abortMultiPartUpload",
"(",
")",
";",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"mTagFutures",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"if",
"(",
"mTags",
".",
"size",
"(",
")",
"!=",
"beforeSize",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Uploaded {} partitions of id '{}' to {}.\"",
",",
"mTags",
".",
"size",
"(",
")",
",",
"mUploadId",
",",
"mKey",
")",
";",
"}",
"}"
] |
Waits for the submitted upload tasks to finish.
|
[
"Waits",
"for",
"the",
"submitted",
"upload",
"tasks",
"to",
"finish",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java#L380-L403
|
18,305
|
Alluxio/alluxio
|
underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java
|
S3ALowLevelOutputStream.completeMultiPartUpload
|
private void completeMultiPartUpload() throws IOException {
AmazonClientException lastException;
CompleteMultipartUploadRequest completeRequest = new CompleteMultipartUploadRequest(mBucketName,
mKey, mUploadId, mTags);
do {
try {
mClient.completeMultipartUpload(completeRequest);
LOG.debug("Completed multipart upload for key {} and id '{}' with {} partitions.",
mKey, mUploadId, mTags.size());
return;
} catch (AmazonClientException e) {
lastException = e;
}
} while (mRetryPolicy.attempt());
// This point is only reached if the operation failed more
// than the allowed retry count
throw new IOException("Unable to complete multipart upload with id '"
+ mUploadId + "' to " + mKey, lastException);
}
|
java
|
private void completeMultiPartUpload() throws IOException {
AmazonClientException lastException;
CompleteMultipartUploadRequest completeRequest = new CompleteMultipartUploadRequest(mBucketName,
mKey, mUploadId, mTags);
do {
try {
mClient.completeMultipartUpload(completeRequest);
LOG.debug("Completed multipart upload for key {} and id '{}' with {} partitions.",
mKey, mUploadId, mTags.size());
return;
} catch (AmazonClientException e) {
lastException = e;
}
} while (mRetryPolicy.attempt());
// This point is only reached if the operation failed more
// than the allowed retry count
throw new IOException("Unable to complete multipart upload with id '"
+ mUploadId + "' to " + mKey, lastException);
}
|
[
"private",
"void",
"completeMultiPartUpload",
"(",
")",
"throws",
"IOException",
"{",
"AmazonClientException",
"lastException",
";",
"CompleteMultipartUploadRequest",
"completeRequest",
"=",
"new",
"CompleteMultipartUploadRequest",
"(",
"mBucketName",
",",
"mKey",
",",
"mUploadId",
",",
"mTags",
")",
";",
"do",
"{",
"try",
"{",
"mClient",
".",
"completeMultipartUpload",
"(",
"completeRequest",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Completed multipart upload for key {} and id '{}' with {} partitions.\"",
",",
"mKey",
",",
"mUploadId",
",",
"mTags",
".",
"size",
"(",
")",
")",
";",
"return",
";",
"}",
"catch",
"(",
"AmazonClientException",
"e",
")",
"{",
"lastException",
"=",
"e",
";",
"}",
"}",
"while",
"(",
"mRetryPolicy",
".",
"attempt",
"(",
")",
")",
";",
"// This point is only reached if the operation failed more",
"// than the allowed retry count",
"throw",
"new",
"IOException",
"(",
"\"Unable to complete multipart upload with id '\"",
"+",
"mUploadId",
"+",
"\"' to \"",
"+",
"mKey",
",",
"lastException",
")",
";",
"}"
] |
Completes multipart upload.
|
[
"Completes",
"multipart",
"upload",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java#L408-L426
|
18,306
|
Alluxio/alluxio
|
underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java
|
S3ALowLevelOutputStream.abortMultiPartUpload
|
private void abortMultiPartUpload() {
AmazonClientException lastException;
do {
try {
mClient.abortMultipartUpload(new AbortMultipartUploadRequest(mBucketName,
mKey, mUploadId));
LOG.warn("Aborted multipart upload for key {} and id '{}' to bucket {}",
mKey, mUploadId, mBucketName);
return;
} catch (AmazonClientException e) {
lastException = e;
}
} while (mRetryPolicy.attempt());
// This point is only reached if the operation failed more
// than the allowed retry count
LOG.warn("Unable to abort multipart upload for key '{}' and id '{}' to bucket {}. "
+ "You may need to enable the periodical cleanup by setting property {}"
+ "to be true.", mKey, mUploadId, mBucketName,
PropertyKey.UNDERFS_CLEANUP_ENABLED.getName(),
lastException);
}
|
java
|
private void abortMultiPartUpload() {
AmazonClientException lastException;
do {
try {
mClient.abortMultipartUpload(new AbortMultipartUploadRequest(mBucketName,
mKey, mUploadId));
LOG.warn("Aborted multipart upload for key {} and id '{}' to bucket {}",
mKey, mUploadId, mBucketName);
return;
} catch (AmazonClientException e) {
lastException = e;
}
} while (mRetryPolicy.attempt());
// This point is only reached if the operation failed more
// than the allowed retry count
LOG.warn("Unable to abort multipart upload for key '{}' and id '{}' to bucket {}. "
+ "You may need to enable the periodical cleanup by setting property {}"
+ "to be true.", mKey, mUploadId, mBucketName,
PropertyKey.UNDERFS_CLEANUP_ENABLED.getName(),
lastException);
}
|
[
"private",
"void",
"abortMultiPartUpload",
"(",
")",
"{",
"AmazonClientException",
"lastException",
";",
"do",
"{",
"try",
"{",
"mClient",
".",
"abortMultipartUpload",
"(",
"new",
"AbortMultipartUploadRequest",
"(",
"mBucketName",
",",
"mKey",
",",
"mUploadId",
")",
")",
";",
"LOG",
".",
"warn",
"(",
"\"Aborted multipart upload for key {} and id '{}' to bucket {}\"",
",",
"mKey",
",",
"mUploadId",
",",
"mBucketName",
")",
";",
"return",
";",
"}",
"catch",
"(",
"AmazonClientException",
"e",
")",
"{",
"lastException",
"=",
"e",
";",
"}",
"}",
"while",
"(",
"mRetryPolicy",
".",
"attempt",
"(",
")",
")",
";",
"// This point is only reached if the operation failed more",
"// than the allowed retry count",
"LOG",
".",
"warn",
"(",
"\"Unable to abort multipart upload for key '{}' and id '{}' to bucket {}. \"",
"+",
"\"You may need to enable the periodical cleanup by setting property {}\"",
"+",
"\"to be true.\"",
",",
"mKey",
",",
"mUploadId",
",",
"mBucketName",
",",
"PropertyKey",
".",
"UNDERFS_CLEANUP_ENABLED",
".",
"getName",
"(",
")",
",",
"lastException",
")",
";",
"}"
] |
Aborts multipart upload.
|
[
"Aborts",
"multipart",
"upload",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/s3a/src/main/java/alluxio/underfs/s3a/S3ALowLevelOutputStream.java#L431-L451
|
18,307
|
Alluxio/alluxio
|
integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java
|
AlluxioFuseUtils.getGidFromGroupName
|
public static long getGidFromGroupName(String groupName) throws IOException {
String result = "";
if (OSUtils.isLinux()) {
String script = "getent group " + groupName + " | cut -d: -f3";
result = ShellUtils.execCommand("bash", "-c", script).trim();
} else if (OSUtils.isMacOS()) {
String script = "dscl . -read /Groups/" + groupName
+ " | awk '($1 == \"PrimaryGroupID:\") { print $2 }'";
result = ShellUtils.execCommand("bash", "-c", script).trim();
}
try {
return Long.parseLong(result);
} catch (NumberFormatException e) {
LOG.error("Failed to get gid from group name {}.", groupName);
return -1;
}
}
|
java
|
public static long getGidFromGroupName(String groupName) throws IOException {
String result = "";
if (OSUtils.isLinux()) {
String script = "getent group " + groupName + " | cut -d: -f3";
result = ShellUtils.execCommand("bash", "-c", script).trim();
} else if (OSUtils.isMacOS()) {
String script = "dscl . -read /Groups/" + groupName
+ " | awk '($1 == \"PrimaryGroupID:\") { print $2 }'";
result = ShellUtils.execCommand("bash", "-c", script).trim();
}
try {
return Long.parseLong(result);
} catch (NumberFormatException e) {
LOG.error("Failed to get gid from group name {}.", groupName);
return -1;
}
}
|
[
"public",
"static",
"long",
"getGidFromGroupName",
"(",
"String",
"groupName",
")",
"throws",
"IOException",
"{",
"String",
"result",
"=",
"\"\"",
";",
"if",
"(",
"OSUtils",
".",
"isLinux",
"(",
")",
")",
"{",
"String",
"script",
"=",
"\"getent group \"",
"+",
"groupName",
"+",
"\" | cut -d: -f3\"",
";",
"result",
"=",
"ShellUtils",
".",
"execCommand",
"(",
"\"bash\"",
",",
"\"-c\"",
",",
"script",
")",
".",
"trim",
"(",
")",
";",
"}",
"else",
"if",
"(",
"OSUtils",
".",
"isMacOS",
"(",
")",
")",
"{",
"String",
"script",
"=",
"\"dscl . -read /Groups/\"",
"+",
"groupName",
"+",
"\" | awk '($1 == \\\"PrimaryGroupID:\\\") { print $2 }'\"",
";",
"result",
"=",
"ShellUtils",
".",
"execCommand",
"(",
"\"bash\"",
",",
"\"-c\"",
",",
"script",
")",
".",
"trim",
"(",
")",
";",
"}",
"try",
"{",
"return",
"Long",
".",
"parseLong",
"(",
"result",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to get gid from group name {}.\"",
",",
"groupName",
")",
";",
"return",
"-",
"1",
";",
"}",
"}"
] |
Retrieves the gid of the given group.
@param groupName the group name
@return gid
|
[
"Retrieves",
"the",
"gid",
"of",
"the",
"given",
"group",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java#L69-L85
|
18,308
|
Alluxio/alluxio
|
integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java
|
AlluxioFuseUtils.getUserName
|
public static String getUserName(long uid) throws IOException {
return ShellUtils.execCommand("id", "-nu", Long.toString(uid)).trim();
}
|
java
|
public static String getUserName(long uid) throws IOException {
return ShellUtils.execCommand("id", "-nu", Long.toString(uid)).trim();
}
|
[
"public",
"static",
"String",
"getUserName",
"(",
"long",
"uid",
")",
"throws",
"IOException",
"{",
"return",
"ShellUtils",
".",
"execCommand",
"(",
"\"id\"",
",",
"\"-nu\"",
",",
"Long",
".",
"toString",
"(",
"uid",
")",
")",
".",
"trim",
"(",
")",
";",
"}"
] |
Gets the user name from the user id.
@param uid user id
@return user name
|
[
"Gets",
"the",
"user",
"name",
"from",
"the",
"user",
"id",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java#L93-L95
|
18,309
|
Alluxio/alluxio
|
integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java
|
AlluxioFuseUtils.getGroupName
|
public static String getGroupName(long gid) throws IOException {
if (OSUtils.isLinux()) {
String script = "getent group " + gid + " | cut -d: -f1";
return ShellUtils.execCommand("bash", "-c", script).trim();
} else if (OSUtils.isMacOS()) {
String script = "dscl . list /Groups PrimaryGroupID | awk '($2 == \""
+ gid + "\") { print $1 }'";
return ShellUtils.execCommand("bash", "-c", script).trim();
}
return "";
}
|
java
|
public static String getGroupName(long gid) throws IOException {
if (OSUtils.isLinux()) {
String script = "getent group " + gid + " | cut -d: -f1";
return ShellUtils.execCommand("bash", "-c", script).trim();
} else if (OSUtils.isMacOS()) {
String script = "dscl . list /Groups PrimaryGroupID | awk '($2 == \""
+ gid + "\") { print $1 }'";
return ShellUtils.execCommand("bash", "-c", script).trim();
}
return "";
}
|
[
"public",
"static",
"String",
"getGroupName",
"(",
"long",
"gid",
")",
"throws",
"IOException",
"{",
"if",
"(",
"OSUtils",
".",
"isLinux",
"(",
")",
")",
"{",
"String",
"script",
"=",
"\"getent group \"",
"+",
"gid",
"+",
"\" | cut -d: -f1\"",
";",
"return",
"ShellUtils",
".",
"execCommand",
"(",
"\"bash\"",
",",
"\"-c\"",
",",
"script",
")",
".",
"trim",
"(",
")",
";",
"}",
"else",
"if",
"(",
"OSUtils",
".",
"isMacOS",
"(",
")",
")",
"{",
"String",
"script",
"=",
"\"dscl . list /Groups PrimaryGroupID | awk '($2 == \\\"\"",
"+",
"gid",
"+",
"\"\\\") { print $1 }'\"",
";",
"return",
"ShellUtils",
".",
"execCommand",
"(",
"\"bash\"",
",",
"\"-c\"",
",",
"script",
")",
".",
"trim",
"(",
")",
";",
"}",
"return",
"\"\"",
";",
"}"
] |
Gets the group name from the group id.
@param gid the group id
@return group name
|
[
"Gets",
"the",
"group",
"name",
"from",
"the",
"group",
"id",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java#L113-L123
|
18,310
|
Alluxio/alluxio
|
integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java
|
AlluxioFuseUtils.isFuseInstalled
|
public static boolean isFuseInstalled() {
try {
if (OSUtils.isLinux()) {
String result = ShellUtils.execCommand("fusermount", "-V");
return !result.isEmpty();
} else if (OSUtils.isMacOS()) {
String result = ShellUtils.execCommand("bash", "-c", "mount | grep FUSE");
return !result.isEmpty();
}
} catch (Exception e) {
return false;
}
return false;
}
|
java
|
public static boolean isFuseInstalled() {
try {
if (OSUtils.isLinux()) {
String result = ShellUtils.execCommand("fusermount", "-V");
return !result.isEmpty();
} else if (OSUtils.isMacOS()) {
String result = ShellUtils.execCommand("bash", "-c", "mount | grep FUSE");
return !result.isEmpty();
}
} catch (Exception e) {
return false;
}
return false;
}
|
[
"public",
"static",
"boolean",
"isFuseInstalled",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"OSUtils",
".",
"isLinux",
"(",
")",
")",
"{",
"String",
"result",
"=",
"ShellUtils",
".",
"execCommand",
"(",
"\"fusermount\"",
",",
"\"-V\"",
")",
";",
"return",
"!",
"result",
".",
"isEmpty",
"(",
")",
";",
"}",
"else",
"if",
"(",
"OSUtils",
".",
"isMacOS",
"(",
")",
")",
"{",
"String",
"result",
"=",
"ShellUtils",
".",
"execCommand",
"(",
"\"bash\"",
",",
"\"-c\"",
",",
"\"mount | grep FUSE\"",
")",
";",
"return",
"!",
"result",
".",
"isEmpty",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks whether fuse is installed in local file system.
Alluxio-Fuse only support mac and linux.
@return true if fuse is installed, false otherwise
|
[
"Checks",
"whether",
"fuse",
"is",
"installed",
"in",
"local",
"file",
"system",
".",
"Alluxio",
"-",
"Fuse",
"only",
"support",
"mac",
"and",
"linux",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java#L131-L144
|
18,311
|
Alluxio/alluxio
|
integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java
|
AlluxioFuseUtils.getIdInfo
|
private static long getIdInfo(String option, String username) {
String output;
try {
output = ShellUtils.execCommand("id", option, username).trim();
} catch (IOException e) {
LOG.error("Failed to get id from {} with option {}", username, option);
return -1;
}
return Long.parseLong(output);
}
|
java
|
private static long getIdInfo(String option, String username) {
String output;
try {
output = ShellUtils.execCommand("id", option, username).trim();
} catch (IOException e) {
LOG.error("Failed to get id from {} with option {}", username, option);
return -1;
}
return Long.parseLong(output);
}
|
[
"private",
"static",
"long",
"getIdInfo",
"(",
"String",
"option",
",",
"String",
"username",
")",
"{",
"String",
"output",
";",
"try",
"{",
"output",
"=",
"ShellUtils",
".",
"execCommand",
"(",
"\"id\"",
",",
"option",
",",
"username",
")",
".",
"trim",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to get id from {} with option {}\"",
",",
"username",
",",
"option",
")",
";",
"return",
"-",
"1",
";",
"}",
"return",
"Long",
".",
"parseLong",
"(",
"output",
")",
";",
"}"
] |
Runs the "id" command with the given options on the passed username.
@param option option to pass to id (either -u or -g)
@param username the username on which to run the command
@return the uid (-u) or gid (-g) of username
|
[
"Runs",
"the",
"id",
"command",
"with",
"the",
"given",
"options",
"on",
"the",
"passed",
"username",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java#L153-L162
|
18,312
|
Alluxio/alluxio
|
integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java
|
AlluxioFuseUtils.getErrorCode
|
public static int getErrorCode(Throwable t) {
// Error codes and their explanations are described in
// the Errno.java in jnr-constants
if (t instanceof AlluxioException) {
return getAlluxioErrorCode((AlluxioException) t);
} else if (t instanceof IOException) {
return -ErrorCodes.EIO();
} else {
return -ErrorCodes.EBADMSG();
}
}
|
java
|
public static int getErrorCode(Throwable t) {
// Error codes and their explanations are described in
// the Errno.java in jnr-constants
if (t instanceof AlluxioException) {
return getAlluxioErrorCode((AlluxioException) t);
} else if (t instanceof IOException) {
return -ErrorCodes.EIO();
} else {
return -ErrorCodes.EBADMSG();
}
}
|
[
"public",
"static",
"int",
"getErrorCode",
"(",
"Throwable",
"t",
")",
"{",
"// Error codes and their explanations are described in",
"// the Errno.java in jnr-constants",
"if",
"(",
"t",
"instanceof",
"AlluxioException",
")",
"{",
"return",
"getAlluxioErrorCode",
"(",
"(",
"AlluxioException",
")",
"t",
")",
";",
"}",
"else",
"if",
"(",
"t",
"instanceof",
"IOException",
")",
"{",
"return",
"-",
"ErrorCodes",
".",
"EIO",
"(",
")",
";",
"}",
"else",
"{",
"return",
"-",
"ErrorCodes",
".",
"EBADMSG",
"(",
")",
";",
"}",
"}"
] |
Gets the corresponding error code of a throwable.
@param t throwable
@return the corresponding error code
|
[
"Gets",
"the",
"corresponding",
"error",
"code",
"of",
"a",
"throwable",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java#L170-L180
|
18,313
|
Alluxio/alluxio
|
integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java
|
AlluxioFuseUtils.getAlluxioErrorCode
|
private static int getAlluxioErrorCode(AlluxioException e) {
try {
throw e;
} catch (FileDoesNotExistException ex) {
return -ErrorCodes.ENOENT();
} catch (FileAlreadyExistsException ex) {
return -ErrorCodes.EEXIST();
} catch (InvalidPathException ex) {
return -ErrorCodes.EFAULT();
} catch (BlockDoesNotExistException ex) {
return -ErrorCodes.ENODATA();
} catch (DirectoryNotEmptyException ex) {
return -ErrorCodes.ENOTEMPTY();
} catch (AccessControlException ex) {
return -ErrorCodes.EACCES();
} catch (ConnectionFailedException ex) {
return -ErrorCodes.ECONNREFUSED();
} catch (FileAlreadyCompletedException ex) {
return -ErrorCodes.EOPNOTSUPP();
} catch (AlluxioException ex) {
return -ErrorCodes.EBADMSG();
}
}
|
java
|
private static int getAlluxioErrorCode(AlluxioException e) {
try {
throw e;
} catch (FileDoesNotExistException ex) {
return -ErrorCodes.ENOENT();
} catch (FileAlreadyExistsException ex) {
return -ErrorCodes.EEXIST();
} catch (InvalidPathException ex) {
return -ErrorCodes.EFAULT();
} catch (BlockDoesNotExistException ex) {
return -ErrorCodes.ENODATA();
} catch (DirectoryNotEmptyException ex) {
return -ErrorCodes.ENOTEMPTY();
} catch (AccessControlException ex) {
return -ErrorCodes.EACCES();
} catch (ConnectionFailedException ex) {
return -ErrorCodes.ECONNREFUSED();
} catch (FileAlreadyCompletedException ex) {
return -ErrorCodes.EOPNOTSUPP();
} catch (AlluxioException ex) {
return -ErrorCodes.EBADMSG();
}
}
|
[
"private",
"static",
"int",
"getAlluxioErrorCode",
"(",
"AlluxioException",
"e",
")",
"{",
"try",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"FileDoesNotExistException",
"ex",
")",
"{",
"return",
"-",
"ErrorCodes",
".",
"ENOENT",
"(",
")",
";",
"}",
"catch",
"(",
"FileAlreadyExistsException",
"ex",
")",
"{",
"return",
"-",
"ErrorCodes",
".",
"EEXIST",
"(",
")",
";",
"}",
"catch",
"(",
"InvalidPathException",
"ex",
")",
"{",
"return",
"-",
"ErrorCodes",
".",
"EFAULT",
"(",
")",
";",
"}",
"catch",
"(",
"BlockDoesNotExistException",
"ex",
")",
"{",
"return",
"-",
"ErrorCodes",
".",
"ENODATA",
"(",
")",
";",
"}",
"catch",
"(",
"DirectoryNotEmptyException",
"ex",
")",
"{",
"return",
"-",
"ErrorCodes",
".",
"ENOTEMPTY",
"(",
")",
";",
"}",
"catch",
"(",
"AccessControlException",
"ex",
")",
"{",
"return",
"-",
"ErrorCodes",
".",
"EACCES",
"(",
")",
";",
"}",
"catch",
"(",
"ConnectionFailedException",
"ex",
")",
"{",
"return",
"-",
"ErrorCodes",
".",
"ECONNREFUSED",
"(",
")",
";",
"}",
"catch",
"(",
"FileAlreadyCompletedException",
"ex",
")",
"{",
"return",
"-",
"ErrorCodes",
".",
"EOPNOTSUPP",
"(",
")",
";",
"}",
"catch",
"(",
"AlluxioException",
"ex",
")",
"{",
"return",
"-",
"ErrorCodes",
".",
"EBADMSG",
"(",
")",
";",
"}",
"}"
] |
Gets the corresponding error code of an Alluxio exception.
@param e an Alluxio exception
@return the corresponding error code
|
[
"Gets",
"the",
"corresponding",
"error",
"code",
"of",
"an",
"Alluxio",
"exception",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/AlluxioFuseUtils.java#L188-L210
|
18,314
|
Alluxio/alluxio
|
job/common/src/main/java/alluxio/job/util/TimeSeries.java
|
TimeSeries.record
|
public void record(long timeNano, int numEvents) {
long leftEndPoint = bucket(timeNano);
mSeries.put(leftEndPoint, mSeries.getOrDefault(leftEndPoint, 0) + numEvents);
}
|
java
|
public void record(long timeNano, int numEvents) {
long leftEndPoint = bucket(timeNano);
mSeries.put(leftEndPoint, mSeries.getOrDefault(leftEndPoint, 0) + numEvents);
}
|
[
"public",
"void",
"record",
"(",
"long",
"timeNano",
",",
"int",
"numEvents",
")",
"{",
"long",
"leftEndPoint",
"=",
"bucket",
"(",
"timeNano",
")",
";",
"mSeries",
".",
"put",
"(",
"leftEndPoint",
",",
"mSeries",
".",
"getOrDefault",
"(",
"leftEndPoint",
",",
"0",
")",
"+",
"numEvents",
")",
";",
"}"
] |
Record events at a timestamp into the time series.
@param timeNano the time in nano seconds
@param numEvents the number of events happened at timeNano
|
[
"Record",
"events",
"at",
"a",
"timestamp",
"into",
"the",
"time",
"series",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/common/src/main/java/alluxio/job/util/TimeSeries.java#L81-L84
|
18,315
|
Alluxio/alluxio
|
job/common/src/main/java/alluxio/job/util/TimeSeries.java
|
TimeSeries.add
|
public void add(TimeSeries other) {
TreeMap<Long, Integer> otherSeries = other.getSeries();
for (Map.Entry<Long, Integer> event : otherSeries.entrySet()) {
record(event.getKey() + other.getWidthNano() / 2, event.getValue());
}
}
|
java
|
public void add(TimeSeries other) {
TreeMap<Long, Integer> otherSeries = other.getSeries();
for (Map.Entry<Long, Integer> event : otherSeries.entrySet()) {
record(event.getKey() + other.getWidthNano() / 2, event.getValue());
}
}
|
[
"public",
"void",
"add",
"(",
"TimeSeries",
"other",
")",
"{",
"TreeMap",
"<",
"Long",
",",
"Integer",
">",
"otherSeries",
"=",
"other",
".",
"getSeries",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Long",
",",
"Integer",
">",
"event",
":",
"otherSeries",
".",
"entrySet",
"(",
")",
")",
"{",
"record",
"(",
"event",
".",
"getKey",
"(",
")",
"+",
"other",
".",
"getWidthNano",
"(",
")",
"/",
"2",
",",
"event",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] |
Add one histogram to the current one. We preserve the width in the current TimeSeries.
@param other the TimeSeries instance to add
|
[
"Add",
"one",
"histogram",
"to",
"the",
"current",
"one",
".",
"We",
"preserve",
"the",
"width",
"in",
"the",
"current",
"TimeSeries",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/common/src/main/java/alluxio/job/util/TimeSeries.java#L114-L119
|
18,316
|
Alluxio/alluxio
|
job/common/src/main/java/alluxio/job/util/TimeSeries.java
|
TimeSeries.sparsePrint
|
public void sparsePrint(PrintStream stream) {
if (mSeries.isEmpty()) {
return;
}
long start = mSeries.firstKey();
stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano);
for (Map.Entry<Long, Integer> entry : mSeries.entrySet()) {
stream.printf("%d %d%n", (entry.getKey() - start) / mWidthNano, entry.getValue());
}
}
|
java
|
public void sparsePrint(PrintStream stream) {
if (mSeries.isEmpty()) {
return;
}
long start = mSeries.firstKey();
stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano);
for (Map.Entry<Long, Integer> entry : mSeries.entrySet()) {
stream.printf("%d %d%n", (entry.getKey() - start) / mWidthNano, entry.getValue());
}
}
|
[
"public",
"void",
"sparsePrint",
"(",
"PrintStream",
"stream",
")",
"{",
"if",
"(",
"mSeries",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"long",
"start",
"=",
"mSeries",
".",
"firstKey",
"(",
")",
";",
"stream",
".",
"printf",
"(",
"\"Time series starts at %d with width %d.%n\"",
",",
"start",
",",
"mWidthNano",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Long",
",",
"Integer",
">",
"entry",
":",
"mSeries",
".",
"entrySet",
"(",
")",
")",
"{",
"stream",
".",
"printf",
"(",
"\"%d %d%n\"",
",",
"(",
"entry",
".",
"getKey",
"(",
")",
"-",
"start",
")",
"/",
"mWidthNano",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] |
Print the time series sparsely, i.e. it ignores buckets with 0 events.
@param stream the print stream
|
[
"Print",
"the",
"time",
"series",
"sparsely",
"i",
".",
"e",
".",
"it",
"ignores",
"buckets",
"with",
"0",
"events",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/common/src/main/java/alluxio/job/util/TimeSeries.java#L171-L181
|
18,317
|
Alluxio/alluxio
|
job/common/src/main/java/alluxio/job/util/TimeSeries.java
|
TimeSeries.print
|
public void print(PrintStream stream) {
if (mSeries.isEmpty()) {
return;
}
long start = mSeries.firstKey();
stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano);
int bucketIndex = 0;
Iterator<Map.Entry<Long, Integer>> it = mSeries.entrySet().iterator();
Map.Entry<Long, Integer> current = it.next();
while (current != null) {
int numEvents = 0;
if (bucketIndex * mWidthNano + start == current.getKey()) {
numEvents = current.getValue();
current = null;
if (it.hasNext()) {
current = it.next();
}
}
stream.printf("%d %d%n", bucketIndex, numEvents);
bucketIndex++;
}
}
|
java
|
public void print(PrintStream stream) {
if (mSeries.isEmpty()) {
return;
}
long start = mSeries.firstKey();
stream.printf("Time series starts at %d with width %d.%n", start, mWidthNano);
int bucketIndex = 0;
Iterator<Map.Entry<Long, Integer>> it = mSeries.entrySet().iterator();
Map.Entry<Long, Integer> current = it.next();
while (current != null) {
int numEvents = 0;
if (bucketIndex * mWidthNano + start == current.getKey()) {
numEvents = current.getValue();
current = null;
if (it.hasNext()) {
current = it.next();
}
}
stream.printf("%d %d%n", bucketIndex, numEvents);
bucketIndex++;
}
}
|
[
"public",
"void",
"print",
"(",
"PrintStream",
"stream",
")",
"{",
"if",
"(",
"mSeries",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"long",
"start",
"=",
"mSeries",
".",
"firstKey",
"(",
")",
";",
"stream",
".",
"printf",
"(",
"\"Time series starts at %d with width %d.%n\"",
",",
"start",
",",
"mWidthNano",
")",
";",
"int",
"bucketIndex",
"=",
"0",
";",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"Long",
",",
"Integer",
">",
">",
"it",
"=",
"mSeries",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"Map",
".",
"Entry",
"<",
"Long",
",",
"Integer",
">",
"current",
"=",
"it",
".",
"next",
"(",
")",
";",
"while",
"(",
"current",
"!=",
"null",
")",
"{",
"int",
"numEvents",
"=",
"0",
";",
"if",
"(",
"bucketIndex",
"*",
"mWidthNano",
"+",
"start",
"==",
"current",
".",
"getKey",
"(",
")",
")",
"{",
"numEvents",
"=",
"current",
".",
"getValue",
"(",
")",
";",
"current",
"=",
"null",
";",
"if",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"current",
"=",
"it",
".",
"next",
"(",
")",
";",
"}",
"}",
"stream",
".",
"printf",
"(",
"\"%d %d%n\"",
",",
"bucketIndex",
",",
"numEvents",
")",
";",
"bucketIndex",
"++",
";",
"}",
"}"
] |
Print the time series densely, i.e. it doesn't ignore buckets with 0 events.
@param stream the print stream
|
[
"Print",
"the",
"time",
"series",
"densely",
"i",
".",
"e",
".",
"it",
"doesn",
"t",
"ignore",
"buckets",
"with",
"0",
"events",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/common/src/main/java/alluxio/job/util/TimeSeries.java#L188-L210
|
18,318
|
Alluxio/alluxio
|
underfs/s3a/src/main/java/alluxio/underfs/s3a/S3AUnderFileSystem.java
|
S3AUnderFileSystem.memoize
|
private static <T> Supplier<T> memoize(Supplier<T> original) {
return new Supplier<T>() {
Supplier<T> mDelegate = this::firstTime;
boolean mInitialized;
public T get() {
return mDelegate.get();
}
private synchronized T firstTime() {
if (!mInitialized) {
T value = original.get();
mDelegate = () -> value;
mInitialized = true;
}
return mDelegate.get();
}
};
}
|
java
|
private static <T> Supplier<T> memoize(Supplier<T> original) {
return new Supplier<T>() {
Supplier<T> mDelegate = this::firstTime;
boolean mInitialized;
public T get() {
return mDelegate.get();
}
private synchronized T firstTime() {
if (!mInitialized) {
T value = original.get();
mDelegate = () -> value;
mInitialized = true;
}
return mDelegate.get();
}
};
}
|
[
"private",
"static",
"<",
"T",
">",
"Supplier",
"<",
"T",
">",
"memoize",
"(",
"Supplier",
"<",
"T",
">",
"original",
")",
"{",
"return",
"new",
"Supplier",
"<",
"T",
">",
"(",
")",
"{",
"Supplier",
"<",
"T",
">",
"mDelegate",
"=",
"this",
"::",
"firstTime",
";",
"boolean",
"mInitialized",
";",
"public",
"T",
"get",
"(",
")",
"{",
"return",
"mDelegate",
".",
"get",
"(",
")",
";",
"}",
"private",
"synchronized",
"T",
"firstTime",
"(",
")",
"{",
"if",
"(",
"!",
"mInitialized",
")",
"{",
"T",
"value",
"=",
"original",
".",
"get",
"(",
")",
";",
"mDelegate",
"=",
"(",
")",
"->",
"value",
";",
"mInitialized",
"=",
"true",
";",
"}",
"return",
"mDelegate",
".",
"get",
"(",
")",
";",
"}",
"}",
";",
"}"
] |
Memoize implementation for java.util.function.supplier.
|
[
"Memoize",
"implementation",
"for",
"java",
".",
"util",
".",
"function",
".",
"supplier",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/s3a/src/main/java/alluxio/underfs/s3a/S3AUnderFileSystem.java#L111-L128
|
18,319
|
Alluxio/alluxio
|
underfs/swift/src/main/java/alluxio/underfs/swift/http/SwiftDirectClient.java
|
SwiftDirectClient.put
|
public static SwiftOutputStream put(Access access, String objectName) throws IOException {
LOG.debug("PUT method, object : {}", objectName);
URL url = new URL(access.getPublicURL() + "/" + objectName);
URLConnection connection = url.openConnection();
if (!(connection instanceof HttpURLConnection)) {
throw new IOException("Connection is not an instance of HTTP URL Connection");
}
HttpURLConnection httpCon = (HttpURLConnection) connection;
httpCon.setRequestMethod("PUT");
httpCon.addRequestProperty("X-Auth-Token", access.getToken());
httpCon.addRequestProperty("Content-Type", "binary/octet-stream");
httpCon.setDoInput(true);
httpCon.setRequestProperty("Connection", "close");
httpCon.setReadTimeout(HTTP_READ_TIMEOUT);
httpCon.setRequestProperty("Transfer-Encoding", "chunked");
httpCon.setDoOutput(true);
httpCon.setChunkedStreamingMode(HTTP_CHUNK_STREAMING);
httpCon.connect();
return new SwiftOutputStream(httpCon);
}
|
java
|
public static SwiftOutputStream put(Access access, String objectName) throws IOException {
LOG.debug("PUT method, object : {}", objectName);
URL url = new URL(access.getPublicURL() + "/" + objectName);
URLConnection connection = url.openConnection();
if (!(connection instanceof HttpURLConnection)) {
throw new IOException("Connection is not an instance of HTTP URL Connection");
}
HttpURLConnection httpCon = (HttpURLConnection) connection;
httpCon.setRequestMethod("PUT");
httpCon.addRequestProperty("X-Auth-Token", access.getToken());
httpCon.addRequestProperty("Content-Type", "binary/octet-stream");
httpCon.setDoInput(true);
httpCon.setRequestProperty("Connection", "close");
httpCon.setReadTimeout(HTTP_READ_TIMEOUT);
httpCon.setRequestProperty("Transfer-Encoding", "chunked");
httpCon.setDoOutput(true);
httpCon.setChunkedStreamingMode(HTTP_CHUNK_STREAMING);
httpCon.connect();
return new SwiftOutputStream(httpCon);
}
|
[
"public",
"static",
"SwiftOutputStream",
"put",
"(",
"Access",
"access",
",",
"String",
"objectName",
")",
"throws",
"IOException",
"{",
"LOG",
".",
"debug",
"(",
"\"PUT method, object : {}\"",
",",
"objectName",
")",
";",
"URL",
"url",
"=",
"new",
"URL",
"(",
"access",
".",
"getPublicURL",
"(",
")",
"+",
"\"/\"",
"+",
"objectName",
")",
";",
"URLConnection",
"connection",
"=",
"url",
".",
"openConnection",
"(",
")",
";",
"if",
"(",
"!",
"(",
"connection",
"instanceof",
"HttpURLConnection",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Connection is not an instance of HTTP URL Connection\"",
")",
";",
"}",
"HttpURLConnection",
"httpCon",
"=",
"(",
"HttpURLConnection",
")",
"connection",
";",
"httpCon",
".",
"setRequestMethod",
"(",
"\"PUT\"",
")",
";",
"httpCon",
".",
"addRequestProperty",
"(",
"\"X-Auth-Token\"",
",",
"access",
".",
"getToken",
"(",
")",
")",
";",
"httpCon",
".",
"addRequestProperty",
"(",
"\"Content-Type\"",
",",
"\"binary/octet-stream\"",
")",
";",
"httpCon",
".",
"setDoInput",
"(",
"true",
")",
";",
"httpCon",
".",
"setRequestProperty",
"(",
"\"Connection\"",
",",
"\"close\"",
")",
";",
"httpCon",
".",
"setReadTimeout",
"(",
"HTTP_READ_TIMEOUT",
")",
";",
"httpCon",
".",
"setRequestProperty",
"(",
"\"Transfer-Encoding\"",
",",
"\"chunked\"",
")",
";",
"httpCon",
".",
"setDoOutput",
"(",
"true",
")",
";",
"httpCon",
".",
"setChunkedStreamingMode",
"(",
"HTTP_CHUNK_STREAMING",
")",
";",
"httpCon",
".",
"connect",
"(",
")",
";",
"return",
"new",
"SwiftOutputStream",
"(",
"httpCon",
")",
";",
"}"
] |
Swift HTTP PUT request.
@param access JOSS access object
@param objectName name of the object to create
@return SwiftOutputStream that will be used to upload data to Swift
|
[
"Swift",
"HTTP",
"PUT",
"request",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/swift/src/main/java/alluxio/underfs/swift/http/SwiftDirectClient.java#L50-L70
|
18,320
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/security/authentication/DefaultAuthenticationServer.java
|
DefaultAuthenticationServer.cleanupStaleClients
|
private void cleanupStaleClients() {
LocalTime cleanupTime = LocalTime.now();
LOG.debug("Starting cleanup authentication registry at {}", cleanupTime);
// Get a list of stale clients under read lock.
List<UUID> staleChannels = new ArrayList<>();
for (Map.Entry<UUID, AuthenticatedChannelInfo> clientEntry : mChannels.entrySet()) {
LocalTime lat = clientEntry.getValue().getLastAccessTime();
if (lat.plusSeconds(mCleanupIntervalMs / 1000).isBefore(cleanupTime)) {
staleChannels.add(clientEntry.getKey());
}
}
// Unregister stale clients.
LOG.debug("Found {} stale channels for cleanup.", staleChannels.size());
for (UUID clientId : staleChannels) {
unregisterChannel(clientId);
}
LOG.debug("Finished state channel cleanup at {}", LocalTime.now());
}
|
java
|
private void cleanupStaleClients() {
LocalTime cleanupTime = LocalTime.now();
LOG.debug("Starting cleanup authentication registry at {}", cleanupTime);
// Get a list of stale clients under read lock.
List<UUID> staleChannels = new ArrayList<>();
for (Map.Entry<UUID, AuthenticatedChannelInfo> clientEntry : mChannels.entrySet()) {
LocalTime lat = clientEntry.getValue().getLastAccessTime();
if (lat.plusSeconds(mCleanupIntervalMs / 1000).isBefore(cleanupTime)) {
staleChannels.add(clientEntry.getKey());
}
}
// Unregister stale clients.
LOG.debug("Found {} stale channels for cleanup.", staleChannels.size());
for (UUID clientId : staleChannels) {
unregisterChannel(clientId);
}
LOG.debug("Finished state channel cleanup at {}", LocalTime.now());
}
|
[
"private",
"void",
"cleanupStaleClients",
"(",
")",
"{",
"LocalTime",
"cleanupTime",
"=",
"LocalTime",
".",
"now",
"(",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Starting cleanup authentication registry at {}\"",
",",
"cleanupTime",
")",
";",
"// Get a list of stale clients under read lock.",
"List",
"<",
"UUID",
">",
"staleChannels",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"UUID",
",",
"AuthenticatedChannelInfo",
">",
"clientEntry",
":",
"mChannels",
".",
"entrySet",
"(",
")",
")",
"{",
"LocalTime",
"lat",
"=",
"clientEntry",
".",
"getValue",
"(",
")",
".",
"getLastAccessTime",
"(",
")",
";",
"if",
"(",
"lat",
".",
"plusSeconds",
"(",
"mCleanupIntervalMs",
"/",
"1000",
")",
".",
"isBefore",
"(",
"cleanupTime",
")",
")",
"{",
"staleChannels",
".",
"add",
"(",
"clientEntry",
".",
"getKey",
"(",
")",
")",
";",
"}",
"}",
"// Unregister stale clients.",
"LOG",
".",
"debug",
"(",
"\"Found {} stale channels for cleanup.\"",
",",
"staleChannels",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"UUID",
"clientId",
":",
"staleChannels",
")",
"{",
"unregisterChannel",
"(",
"clientId",
")",
";",
"}",
"LOG",
".",
"debug",
"(",
"\"Finished state channel cleanup at {}\"",
",",
"LocalTime",
".",
"now",
"(",
")",
")",
";",
"}"
] |
Primitive that is invoked periodically for cleaning the registry from clients that has become
stale.
|
[
"Primitive",
"that",
"is",
"invoked",
"periodically",
"for",
"cleaning",
"the",
"registry",
"from",
"clients",
"that",
"has",
"become",
"stale",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/security/authentication/DefaultAuthenticationServer.java#L148-L166
|
18,321
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/security/authentication/DefaultAuthenticationServer.java
|
DefaultAuthenticationServer.checkSupported
|
protected void checkSupported(AuthType authType) {
switch (authType) {
case NOSASL:
case SIMPLE:
case CUSTOM:
return;
default:
throw new RuntimeException("Authentication type not supported:" + authType.name());
}
}
|
java
|
protected void checkSupported(AuthType authType) {
switch (authType) {
case NOSASL:
case SIMPLE:
case CUSTOM:
return;
default:
throw new RuntimeException("Authentication type not supported:" + authType.name());
}
}
|
[
"protected",
"void",
"checkSupported",
"(",
"AuthType",
"authType",
")",
"{",
"switch",
"(",
"authType",
")",
"{",
"case",
"NOSASL",
":",
"case",
"SIMPLE",
":",
"case",
"CUSTOM",
":",
"return",
";",
"default",
":",
"throw",
"new",
"RuntimeException",
"(",
"\"Authentication type not supported:\"",
"+",
"authType",
".",
"name",
"(",
")",
")",
";",
"}",
"}"
] |
Used to check if given authentication is supported by the server.
@param authType authentication type
@throws RuntimeException if not supported
|
[
"Used",
"to",
"check",
"if",
"given",
"authentication",
"is",
"supported",
"by",
"the",
"server",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/security/authentication/DefaultAuthenticationServer.java#L174-L183
|
18,322
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/AsyncBlockRemover.java
|
AsyncBlockRemover.addBlocksToDelete
|
public void addBlocksToDelete(List<Long> blocks) {
for (long id : blocks) {
if (mRemovingBlocks.contains(id)) {
LOG.debug("{} is being removed. Current queue size is {}.", id, mBlocksToRemove.size());
continue;
}
try {
mBlocksToRemove.put(id);
mRemovingBlocks.add(id);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.warn("AsyncBlockRemover got interrupted while it was putting block {}.", id);
}
}
}
|
java
|
public void addBlocksToDelete(List<Long> blocks) {
for (long id : blocks) {
if (mRemovingBlocks.contains(id)) {
LOG.debug("{} is being removed. Current queue size is {}.", id, mBlocksToRemove.size());
continue;
}
try {
mBlocksToRemove.put(id);
mRemovingBlocks.add(id);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.warn("AsyncBlockRemover got interrupted while it was putting block {}.", id);
}
}
}
|
[
"public",
"void",
"addBlocksToDelete",
"(",
"List",
"<",
"Long",
">",
"blocks",
")",
"{",
"for",
"(",
"long",
"id",
":",
"blocks",
")",
"{",
"if",
"(",
"mRemovingBlocks",
".",
"contains",
"(",
"id",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"{} is being removed. Current queue size is {}.\"",
",",
"id",
",",
"mBlocksToRemove",
".",
"size",
"(",
")",
")",
";",
"continue",
";",
"}",
"try",
"{",
"mBlocksToRemove",
".",
"put",
"(",
"id",
")",
";",
"mRemovingBlocks",
".",
"add",
"(",
"id",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"LOG",
".",
"warn",
"(",
"\"AsyncBlockRemover got interrupted while it was putting block {}.\"",
",",
"id",
")",
";",
"}",
"}",
"}"
] |
Put blocks into async block remover. This method will take care of the duplicate blocks.
@param blocks blocks to be deleted
|
[
"Put",
"blocks",
"into",
"async",
"block",
"remover",
".",
"This",
"method",
"will",
"take",
"care",
"of",
"the",
"duplicate",
"blocks",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/AsyncBlockRemover.java#L69-L83
|
18,323
|
Alluxio/alluxio
|
underfs/local/src/main/java/alluxio/underfs/local/LocalUnderFileSystem.java
|
LocalUnderFileSystem.rename
|
private boolean rename(String src, String dst) throws IOException {
src = stripPath(src);
dst = stripPath(dst);
File file = new File(src);
return file.renameTo(new File(dst));
}
|
java
|
private boolean rename(String src, String dst) throws IOException {
src = stripPath(src);
dst = stripPath(dst);
File file = new File(src);
return file.renameTo(new File(dst));
}
|
[
"private",
"boolean",
"rename",
"(",
"String",
"src",
",",
"String",
"dst",
")",
"throws",
"IOException",
"{",
"src",
"=",
"stripPath",
"(",
"src",
")",
";",
"dst",
"=",
"stripPath",
"(",
"dst",
")",
";",
"File",
"file",
"=",
"new",
"File",
"(",
"src",
")",
";",
"return",
"file",
".",
"renameTo",
"(",
"new",
"File",
"(",
"dst",
")",
")",
";",
"}"
] |
Rename a file to a file or a directory to a directory.
@param src path of source file or directory
@param dst path of destination file or directory
@return true if rename succeeds
|
[
"Rename",
"a",
"file",
"to",
"a",
"file",
"or",
"a",
"directory",
"to",
"a",
"directory",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/local/src/main/java/alluxio/underfs/local/LocalUnderFileSystem.java#L426-L431
|
18,324
|
Alluxio/alluxio
|
core/server/proxy/src/main/java/alluxio/proxy/s3/S3RestServiceHandler.java
|
S3RestServiceHandler.completeMultipartUpload
|
private Response completeMultipartUpload(final String bucket, final String object,
final long uploadId) {
return S3RestUtils.call(bucket, new S3RestUtils.RestCallable<CompleteMultipartUploadResult>() {
@Override
public CompleteMultipartUploadResult call() throws S3Exception {
String bucketPath = parseBucketPath(AlluxioURI.SEPARATOR + bucket);
checkBucketIsAlluxioDirectory(bucketPath);
String objectPath = bucketPath + AlluxioURI.SEPARATOR + object;
AlluxioURI multipartTemporaryDir =
new AlluxioURI(S3RestUtils.getMultipartTemporaryDirForObject(bucketPath, object));
checkUploadId(multipartTemporaryDir, uploadId);
try {
List<URIStatus> parts = mFileSystem.listStatus(multipartTemporaryDir);
Collections.sort(parts, new URIStatusNameComparator());
CreateFilePOptions options = CreateFilePOptions.newBuilder().setRecursive(true)
.setWriteType(getS3WriteType()).build();
FileOutStream os = mFileSystem.createFile(new AlluxioURI(objectPath), options);
MessageDigest md5 = MessageDigest.getInstance("MD5");
DigestOutputStream digestOutputStream = new DigestOutputStream(os, md5);
try {
for (URIStatus part : parts) {
try (FileInStream is = mFileSystem.openFile(new AlluxioURI(part.getPath()))) {
ByteStreams.copy(is, digestOutputStream);
}
}
} finally {
digestOutputStream.close();
}
mFileSystem.delete(multipartTemporaryDir,
DeletePOptions.newBuilder().setRecursive(true).build());
String entityTag = Hex.encodeHexString(md5.digest());
return new CompleteMultipartUploadResult(objectPath, bucket, object, entityTag);
} catch (Exception e) {
throw toObjectS3Exception(e, objectPath);
}
}
});
}
|
java
|
private Response completeMultipartUpload(final String bucket, final String object,
final long uploadId) {
return S3RestUtils.call(bucket, new S3RestUtils.RestCallable<CompleteMultipartUploadResult>() {
@Override
public CompleteMultipartUploadResult call() throws S3Exception {
String bucketPath = parseBucketPath(AlluxioURI.SEPARATOR + bucket);
checkBucketIsAlluxioDirectory(bucketPath);
String objectPath = bucketPath + AlluxioURI.SEPARATOR + object;
AlluxioURI multipartTemporaryDir =
new AlluxioURI(S3RestUtils.getMultipartTemporaryDirForObject(bucketPath, object));
checkUploadId(multipartTemporaryDir, uploadId);
try {
List<URIStatus> parts = mFileSystem.listStatus(multipartTemporaryDir);
Collections.sort(parts, new URIStatusNameComparator());
CreateFilePOptions options = CreateFilePOptions.newBuilder().setRecursive(true)
.setWriteType(getS3WriteType()).build();
FileOutStream os = mFileSystem.createFile(new AlluxioURI(objectPath), options);
MessageDigest md5 = MessageDigest.getInstance("MD5");
DigestOutputStream digestOutputStream = new DigestOutputStream(os, md5);
try {
for (URIStatus part : parts) {
try (FileInStream is = mFileSystem.openFile(new AlluxioURI(part.getPath()))) {
ByteStreams.copy(is, digestOutputStream);
}
}
} finally {
digestOutputStream.close();
}
mFileSystem.delete(multipartTemporaryDir,
DeletePOptions.newBuilder().setRecursive(true).build());
String entityTag = Hex.encodeHexString(md5.digest());
return new CompleteMultipartUploadResult(objectPath, bucket, object, entityTag);
} catch (Exception e) {
throw toObjectS3Exception(e, objectPath);
}
}
});
}
|
[
"private",
"Response",
"completeMultipartUpload",
"(",
"final",
"String",
"bucket",
",",
"final",
"String",
"object",
",",
"final",
"long",
"uploadId",
")",
"{",
"return",
"S3RestUtils",
".",
"call",
"(",
"bucket",
",",
"new",
"S3RestUtils",
".",
"RestCallable",
"<",
"CompleteMultipartUploadResult",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"CompleteMultipartUploadResult",
"call",
"(",
")",
"throws",
"S3Exception",
"{",
"String",
"bucketPath",
"=",
"parseBucketPath",
"(",
"AlluxioURI",
".",
"SEPARATOR",
"+",
"bucket",
")",
";",
"checkBucketIsAlluxioDirectory",
"(",
"bucketPath",
")",
";",
"String",
"objectPath",
"=",
"bucketPath",
"+",
"AlluxioURI",
".",
"SEPARATOR",
"+",
"object",
";",
"AlluxioURI",
"multipartTemporaryDir",
"=",
"new",
"AlluxioURI",
"(",
"S3RestUtils",
".",
"getMultipartTemporaryDirForObject",
"(",
"bucketPath",
",",
"object",
")",
")",
";",
"checkUploadId",
"(",
"multipartTemporaryDir",
",",
"uploadId",
")",
";",
"try",
"{",
"List",
"<",
"URIStatus",
">",
"parts",
"=",
"mFileSystem",
".",
"listStatus",
"(",
"multipartTemporaryDir",
")",
";",
"Collections",
".",
"sort",
"(",
"parts",
",",
"new",
"URIStatusNameComparator",
"(",
")",
")",
";",
"CreateFilePOptions",
"options",
"=",
"CreateFilePOptions",
".",
"newBuilder",
"(",
")",
".",
"setRecursive",
"(",
"true",
")",
".",
"setWriteType",
"(",
"getS3WriteType",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"FileOutStream",
"os",
"=",
"mFileSystem",
".",
"createFile",
"(",
"new",
"AlluxioURI",
"(",
"objectPath",
")",
",",
"options",
")",
";",
"MessageDigest",
"md5",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"MD5\"",
")",
";",
"DigestOutputStream",
"digestOutputStream",
"=",
"new",
"DigestOutputStream",
"(",
"os",
",",
"md5",
")",
";",
"try",
"{",
"for",
"(",
"URIStatus",
"part",
":",
"parts",
")",
"{",
"try",
"(",
"FileInStream",
"is",
"=",
"mFileSystem",
".",
"openFile",
"(",
"new",
"AlluxioURI",
"(",
"part",
".",
"getPath",
"(",
")",
")",
")",
")",
"{",
"ByteStreams",
".",
"copy",
"(",
"is",
",",
"digestOutputStream",
")",
";",
"}",
"}",
"}",
"finally",
"{",
"digestOutputStream",
".",
"close",
"(",
")",
";",
"}",
"mFileSystem",
".",
"delete",
"(",
"multipartTemporaryDir",
",",
"DeletePOptions",
".",
"newBuilder",
"(",
")",
".",
"setRecursive",
"(",
"true",
")",
".",
"build",
"(",
")",
")",
";",
"String",
"entityTag",
"=",
"Hex",
".",
"encodeHexString",
"(",
"md5",
".",
"digest",
"(",
")",
")",
";",
"return",
"new",
"CompleteMultipartUploadResult",
"(",
"objectPath",
",",
"bucket",
",",
"object",
",",
"entityTag",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"toObjectS3Exception",
"(",
"e",
",",
"objectPath",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] |
under the temporary multipart upload directory are combined into the final object.
|
[
"under",
"the",
"temporary",
"multipart",
"upload",
"directory",
"are",
"combined",
"into",
"the",
"final",
"object",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/proxy/src/main/java/alluxio/proxy/s3/S3RestServiceHandler.java#L330-L372
|
18,325
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.getMasterRpcAddresses
|
public static List<InetSocketAddress> getMasterRpcAddresses(AlluxioConfiguration conf) {
// First check whether rpc addresses are explicitly configured.
if (conf.isSet(PropertyKey.MASTER_RPC_ADDRESSES)) {
return parseInetSocketAddresses(conf.getList(PropertyKey.MASTER_RPC_ADDRESSES, ","));
}
// Fall back on server-side journal configuration.
int rpcPort = NetworkAddressUtils.getPort(NetworkAddressUtils.ServiceType.MASTER_RPC, conf);
return overridePort(getEmbeddedJournalAddresses(conf, ServiceType.MASTER_RAFT), rpcPort);
}
|
java
|
public static List<InetSocketAddress> getMasterRpcAddresses(AlluxioConfiguration conf) {
// First check whether rpc addresses are explicitly configured.
if (conf.isSet(PropertyKey.MASTER_RPC_ADDRESSES)) {
return parseInetSocketAddresses(conf.getList(PropertyKey.MASTER_RPC_ADDRESSES, ","));
}
// Fall back on server-side journal configuration.
int rpcPort = NetworkAddressUtils.getPort(NetworkAddressUtils.ServiceType.MASTER_RPC, conf);
return overridePort(getEmbeddedJournalAddresses(conf, ServiceType.MASTER_RAFT), rpcPort);
}
|
[
"public",
"static",
"List",
"<",
"InetSocketAddress",
">",
"getMasterRpcAddresses",
"(",
"AlluxioConfiguration",
"conf",
")",
"{",
"// First check whether rpc addresses are explicitly configured.",
"if",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"MASTER_RPC_ADDRESSES",
")",
")",
"{",
"return",
"parseInetSocketAddresses",
"(",
"conf",
".",
"getList",
"(",
"PropertyKey",
".",
"MASTER_RPC_ADDRESSES",
",",
"\",\"",
")",
")",
";",
"}",
"// Fall back on server-side journal configuration.",
"int",
"rpcPort",
"=",
"NetworkAddressUtils",
".",
"getPort",
"(",
"NetworkAddressUtils",
".",
"ServiceType",
".",
"MASTER_RPC",
",",
"conf",
")",
";",
"return",
"overridePort",
"(",
"getEmbeddedJournalAddresses",
"(",
"conf",
",",
"ServiceType",
".",
"MASTER_RAFT",
")",
",",
"rpcPort",
")",
";",
"}"
] |
Gets the RPC addresses of all masters based on the configuration.
@param conf the configuration to use
@return the master rpc addresses
|
[
"Gets",
"the",
"RPC",
"addresses",
"of",
"all",
"masters",
"based",
"on",
"the",
"configuration",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L136-L145
|
18,326
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.getJobMasterRpcAddresses
|
public static List<InetSocketAddress> getJobMasterRpcAddresses(AlluxioConfiguration conf) {
// First check whether job rpc addresses are explicitly configured.
if (conf.isSet(PropertyKey.JOB_MASTER_RPC_ADDRESSES)) {
return parseInetSocketAddresses(
conf.getList(PropertyKey.JOB_MASTER_RPC_ADDRESSES, ","));
}
int jobRpcPort =
NetworkAddressUtils.getPort(NetworkAddressUtils.ServiceType.JOB_MASTER_RPC, conf);
// Fall back on explicitly configured regular master rpc addresses.
if (conf.isSet(PropertyKey.MASTER_RPC_ADDRESSES)) {
List<InetSocketAddress> addrs =
parseInetSocketAddresses(conf.getList(PropertyKey.MASTER_RPC_ADDRESSES, ","));
return overridePort(addrs, jobRpcPort);
}
// Fall back on server-side journal configuration.
return overridePort(getEmbeddedJournalAddresses(conf, ServiceType.JOB_MASTER_RAFT), jobRpcPort);
}
|
java
|
public static List<InetSocketAddress> getJobMasterRpcAddresses(AlluxioConfiguration conf) {
// First check whether job rpc addresses are explicitly configured.
if (conf.isSet(PropertyKey.JOB_MASTER_RPC_ADDRESSES)) {
return parseInetSocketAddresses(
conf.getList(PropertyKey.JOB_MASTER_RPC_ADDRESSES, ","));
}
int jobRpcPort =
NetworkAddressUtils.getPort(NetworkAddressUtils.ServiceType.JOB_MASTER_RPC, conf);
// Fall back on explicitly configured regular master rpc addresses.
if (conf.isSet(PropertyKey.MASTER_RPC_ADDRESSES)) {
List<InetSocketAddress> addrs =
parseInetSocketAddresses(conf.getList(PropertyKey.MASTER_RPC_ADDRESSES, ","));
return overridePort(addrs, jobRpcPort);
}
// Fall back on server-side journal configuration.
return overridePort(getEmbeddedJournalAddresses(conf, ServiceType.JOB_MASTER_RAFT), jobRpcPort);
}
|
[
"public",
"static",
"List",
"<",
"InetSocketAddress",
">",
"getJobMasterRpcAddresses",
"(",
"AlluxioConfiguration",
"conf",
")",
"{",
"// First check whether job rpc addresses are explicitly configured.",
"if",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"JOB_MASTER_RPC_ADDRESSES",
")",
")",
"{",
"return",
"parseInetSocketAddresses",
"(",
"conf",
".",
"getList",
"(",
"PropertyKey",
".",
"JOB_MASTER_RPC_ADDRESSES",
",",
"\",\"",
")",
")",
";",
"}",
"int",
"jobRpcPort",
"=",
"NetworkAddressUtils",
".",
"getPort",
"(",
"NetworkAddressUtils",
".",
"ServiceType",
".",
"JOB_MASTER_RPC",
",",
"conf",
")",
";",
"// Fall back on explicitly configured regular master rpc addresses.",
"if",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"MASTER_RPC_ADDRESSES",
")",
")",
"{",
"List",
"<",
"InetSocketAddress",
">",
"addrs",
"=",
"parseInetSocketAddresses",
"(",
"conf",
".",
"getList",
"(",
"PropertyKey",
".",
"MASTER_RPC_ADDRESSES",
",",
"\",\"",
")",
")",
";",
"return",
"overridePort",
"(",
"addrs",
",",
"jobRpcPort",
")",
";",
"}",
"// Fall back on server-side journal configuration.",
"return",
"overridePort",
"(",
"getEmbeddedJournalAddresses",
"(",
"conf",
",",
"ServiceType",
".",
"JOB_MASTER_RAFT",
")",
",",
"jobRpcPort",
")",
";",
"}"
] |
Gets the RPC addresses of all job masters based on the configuration.
@param conf the configuration to use
@return the job master rpc addresses
|
[
"Gets",
"the",
"RPC",
"addresses",
"of",
"all",
"job",
"masters",
"based",
"on",
"the",
"configuration",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L153-L171
|
18,327
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.loadPropertiesFromResource
|
@Nullable
public static Properties loadPropertiesFromResource(URL resource) {
try (InputStream stream = resource.openStream()) {
return loadProperties(stream);
} catch (IOException e) {
LOG.warn("Failed to read properties from {}: {}", resource, e.toString());
return null;
}
}
|
java
|
@Nullable
public static Properties loadPropertiesFromResource(URL resource) {
try (InputStream stream = resource.openStream()) {
return loadProperties(stream);
} catch (IOException e) {
LOG.warn("Failed to read properties from {}: {}", resource, e.toString());
return null;
}
}
|
[
"@",
"Nullable",
"public",
"static",
"Properties",
"loadPropertiesFromResource",
"(",
"URL",
"resource",
")",
"{",
"try",
"(",
"InputStream",
"stream",
"=",
"resource",
".",
"openStream",
"(",
")",
")",
"{",
"return",
"loadProperties",
"(",
"stream",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to read properties from {}: {}\"",
",",
"resource",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Loads properties from a resource.
@param resource url of the properties file
@return a set of properties on success, or null if failed
|
[
"Loads",
"properties",
"from",
"a",
"resource",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L199-L207
|
18,328
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.loadPropertiesFromFile
|
@Nullable
public static Properties loadPropertiesFromFile(String filePath) {
try (FileInputStream fileInputStream = new FileInputStream(filePath)) {
return loadProperties(fileInputStream);
} catch (FileNotFoundException e) {
return null;
} catch (IOException e) {
LOG.warn("Failed to close property input stream from {}: {}", filePath, e.toString());
return null;
}
}
|
java
|
@Nullable
public static Properties loadPropertiesFromFile(String filePath) {
try (FileInputStream fileInputStream = new FileInputStream(filePath)) {
return loadProperties(fileInputStream);
} catch (FileNotFoundException e) {
return null;
} catch (IOException e) {
LOG.warn("Failed to close property input stream from {}: {}", filePath, e.toString());
return null;
}
}
|
[
"@",
"Nullable",
"public",
"static",
"Properties",
"loadPropertiesFromFile",
"(",
"String",
"filePath",
")",
"{",
"try",
"(",
"FileInputStream",
"fileInputStream",
"=",
"new",
"FileInputStream",
"(",
"filePath",
")",
")",
"{",
"return",
"loadProperties",
"(",
"fileInputStream",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to close property input stream from {}: {}\"",
",",
"filePath",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Loads properties from the given file.
@param filePath the absolute path of the file to load properties
@return a set of properties on success, or null if failed
|
[
"Loads",
"properties",
"from",
"the",
"given",
"file",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L215-L225
|
18,329
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.searchPropertiesFile
|
@Nullable
public static String searchPropertiesFile(String propertiesFile,
String[] confPathList) {
if (propertiesFile == null || confPathList == null) {
return null;
}
for (String path : confPathList) {
String file = PathUtils.concatPath(path, propertiesFile);
Properties properties = loadPropertiesFromFile(file);
if (properties != null) {
// If a site conf is successfully loaded, stop trying different paths.
return file;
}
}
return null;
}
|
java
|
@Nullable
public static String searchPropertiesFile(String propertiesFile,
String[] confPathList) {
if (propertiesFile == null || confPathList == null) {
return null;
}
for (String path : confPathList) {
String file = PathUtils.concatPath(path, propertiesFile);
Properties properties = loadPropertiesFromFile(file);
if (properties != null) {
// If a site conf is successfully loaded, stop trying different paths.
return file;
}
}
return null;
}
|
[
"@",
"Nullable",
"public",
"static",
"String",
"searchPropertiesFile",
"(",
"String",
"propertiesFile",
",",
"String",
"[",
"]",
"confPathList",
")",
"{",
"if",
"(",
"propertiesFile",
"==",
"null",
"||",
"confPathList",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"String",
"path",
":",
"confPathList",
")",
"{",
"String",
"file",
"=",
"PathUtils",
".",
"concatPath",
"(",
"path",
",",
"propertiesFile",
")",
";",
"Properties",
"properties",
"=",
"loadPropertiesFromFile",
"(",
"file",
")",
";",
"if",
"(",
"properties",
"!=",
"null",
")",
"{",
"// If a site conf is successfully loaded, stop trying different paths.",
"return",
"file",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Searches the given properties file from a list of paths.
@param propertiesFile the file to load properties
@param confPathList a list of paths to search the propertiesFile
@return the site properties file on success search, or null if failed
|
[
"Searches",
"the",
"given",
"properties",
"file",
"from",
"a",
"list",
"of",
"paths",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L250-L265
|
18,330
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.getMasterHostNotConfiguredMessage
|
public static String getMasterHostNotConfiguredMessage(String serviceName) {
return getHostNotConfiguredMessage(serviceName, "master", PropertyKey.MASTER_HOSTNAME,
PropertyKey.MASTER_EMBEDDED_JOURNAL_ADDRESSES);
}
|
java
|
public static String getMasterHostNotConfiguredMessage(String serviceName) {
return getHostNotConfiguredMessage(serviceName, "master", PropertyKey.MASTER_HOSTNAME,
PropertyKey.MASTER_EMBEDDED_JOURNAL_ADDRESSES);
}
|
[
"public",
"static",
"String",
"getMasterHostNotConfiguredMessage",
"(",
"String",
"serviceName",
")",
"{",
"return",
"getHostNotConfiguredMessage",
"(",
"serviceName",
",",
"\"master\"",
",",
"PropertyKey",
".",
"MASTER_HOSTNAME",
",",
"PropertyKey",
".",
"MASTER_EMBEDDED_JOURNAL_ADDRESSES",
")",
";",
"}"
] |
Returns a unified message for cases when the master hostname cannot be determined.
@param serviceName the name of the service that couldn't run. i.e. Alluxio worker, fsadmin
shell, etc.
@return a string with the message
|
[
"Returns",
"a",
"unified",
"message",
"for",
"cases",
"when",
"the",
"master",
"hostname",
"cannot",
"be",
"determined",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L286-L289
|
18,331
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.getJobMasterHostNotConfiguredMessage
|
public static String getJobMasterHostNotConfiguredMessage(String serviceName) {
return getHostNotConfiguredMessage(serviceName, "job master", PropertyKey.JOB_MASTER_HOSTNAME,
PropertyKey.JOB_MASTER_EMBEDDED_JOURNAL_ADDRESSES);
}
|
java
|
public static String getJobMasterHostNotConfiguredMessage(String serviceName) {
return getHostNotConfiguredMessage(serviceName, "job master", PropertyKey.JOB_MASTER_HOSTNAME,
PropertyKey.JOB_MASTER_EMBEDDED_JOURNAL_ADDRESSES);
}
|
[
"public",
"static",
"String",
"getJobMasterHostNotConfiguredMessage",
"(",
"String",
"serviceName",
")",
"{",
"return",
"getHostNotConfiguredMessage",
"(",
"serviceName",
",",
"\"job master\"",
",",
"PropertyKey",
".",
"JOB_MASTER_HOSTNAME",
",",
"PropertyKey",
".",
"JOB_MASTER_EMBEDDED_JOURNAL_ADDRESSES",
")",
";",
"}"
] |
Returns a unified message for cases when the job master hostname cannot be determined.
@param serviceName the name of the service that couldn't run. i.e. Alluxio worker, fsadmin
shell, etc.
@return a string with the message
|
[
"Returns",
"a",
"unified",
"message",
"for",
"cases",
"when",
"the",
"job",
"master",
"hostname",
"cannot",
"be",
"determined",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L298-L301
|
18,332
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.checkRatio
|
public static float checkRatio(AlluxioConfiguration conf, PropertyKey key) {
float value = conf.getFloat(key);
Preconditions.checkState(value <= 1.0, "Property %s must not exceed 1, but it is set to %s",
key.getName(), value);
Preconditions.checkState(value >= 0.0, "Property %s must be non-negative, but it is set to %s",
key.getName(), value);
return value;
}
|
java
|
public static float checkRatio(AlluxioConfiguration conf, PropertyKey key) {
float value = conf.getFloat(key);
Preconditions.checkState(value <= 1.0, "Property %s must not exceed 1, but it is set to %s",
key.getName(), value);
Preconditions.checkState(value >= 0.0, "Property %s must be non-negative, but it is set to %s",
key.getName(), value);
return value;
}
|
[
"public",
"static",
"float",
"checkRatio",
"(",
"AlluxioConfiguration",
"conf",
",",
"PropertyKey",
"key",
")",
"{",
"float",
"value",
"=",
"conf",
".",
"getFloat",
"(",
"key",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"value",
"<=",
"1.0",
",",
"\"Property %s must not exceed 1, but it is set to %s\"",
",",
"key",
".",
"getName",
"(",
")",
",",
"value",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"value",
">=",
"0.0",
",",
"\"Property %s must be non-negative, but it is set to %s\"",
",",
"key",
".",
"getName",
"(",
")",
",",
"value",
")",
";",
"return",
"value",
";",
"}"
] |
Checks that the given property key is a ratio from 0.0 and 1.0, throwing an exception if it is
not.
@param conf the configuration for looking up the property key
@param key the property key
@return the property value
|
[
"Checks",
"that",
"the",
"given",
"property",
"key",
"is",
"a",
"ratio",
"from",
"0",
".",
"0",
"and",
"1",
".",
"0",
"throwing",
"an",
"exception",
"if",
"it",
"is",
"not",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L318-L325
|
18,333
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.getConfiguration
|
public static List<ConfigProperty> getConfiguration(AlluxioConfiguration conf, Scope scope) {
ConfigurationValueOptions useRawDisplayValue =
ConfigurationValueOptions.defaults().useDisplayValue(true).useRawValue(true);
List<ConfigProperty> configs = new ArrayList<>();
List<PropertyKey> selectedKeys =
conf.keySet().stream()
.filter(key -> GrpcUtils.contains(key.getScope(), scope))
.filter(key -> key.isValid(key.getName()))
.collect(toList());
for (PropertyKey key : selectedKeys) {
ConfigProperty.Builder configProp = ConfigProperty.newBuilder().setName(key.getName())
.setSource(conf.getSource(key).toString());
if (conf.isSet(key)) {
configProp.setValue(conf.get(key, useRawDisplayValue));
}
configs.add(configProp.build());
}
return configs;
}
|
java
|
public static List<ConfigProperty> getConfiguration(AlluxioConfiguration conf, Scope scope) {
ConfigurationValueOptions useRawDisplayValue =
ConfigurationValueOptions.defaults().useDisplayValue(true).useRawValue(true);
List<ConfigProperty> configs = new ArrayList<>();
List<PropertyKey> selectedKeys =
conf.keySet().stream()
.filter(key -> GrpcUtils.contains(key.getScope(), scope))
.filter(key -> key.isValid(key.getName()))
.collect(toList());
for (PropertyKey key : selectedKeys) {
ConfigProperty.Builder configProp = ConfigProperty.newBuilder().setName(key.getName())
.setSource(conf.getSource(key).toString());
if (conf.isSet(key)) {
configProp.setValue(conf.get(key, useRawDisplayValue));
}
configs.add(configProp.build());
}
return configs;
}
|
[
"public",
"static",
"List",
"<",
"ConfigProperty",
">",
"getConfiguration",
"(",
"AlluxioConfiguration",
"conf",
",",
"Scope",
"scope",
")",
"{",
"ConfigurationValueOptions",
"useRawDisplayValue",
"=",
"ConfigurationValueOptions",
".",
"defaults",
"(",
")",
".",
"useDisplayValue",
"(",
"true",
")",
".",
"useRawValue",
"(",
"true",
")",
";",
"List",
"<",
"ConfigProperty",
">",
"configs",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"PropertyKey",
">",
"selectedKeys",
"=",
"conf",
".",
"keySet",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"key",
"->",
"GrpcUtils",
".",
"contains",
"(",
"key",
".",
"getScope",
"(",
")",
",",
"scope",
")",
")",
".",
"filter",
"(",
"key",
"->",
"key",
".",
"isValid",
"(",
"key",
".",
"getName",
"(",
")",
")",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
";",
"for",
"(",
"PropertyKey",
"key",
":",
"selectedKeys",
")",
"{",
"ConfigProperty",
".",
"Builder",
"configProp",
"=",
"ConfigProperty",
".",
"newBuilder",
"(",
")",
".",
"setName",
"(",
"key",
".",
"getName",
"(",
")",
")",
".",
"setSource",
"(",
"conf",
".",
"getSource",
"(",
"key",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"conf",
".",
"isSet",
"(",
"key",
")",
")",
"{",
"configProp",
".",
"setValue",
"(",
"conf",
".",
"get",
"(",
"key",
",",
"useRawDisplayValue",
")",
")",
";",
"}",
"configs",
".",
"add",
"(",
"configProp",
".",
"build",
"(",
")",
")",
";",
"}",
"return",
"configs",
";",
"}"
] |
Gets all configuration properties filtered by the specified scope.
@param conf the configuration to use
@param scope the scope to filter by
@return the properties
|
[
"Gets",
"all",
"configuration",
"properties",
"filtered",
"by",
"the",
"specified",
"scope",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L354-L374
|
18,334
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.reloadProperties
|
public static void reloadProperties() {
synchronized (DEFAULT_PROPERTIES_LOCK) {
// Step1: bootstrap the configuration. This is necessary because we need to resolve alluxio
// .home (likely to be in system properties) to locate the conf dir to search for the site
// property file.
AlluxioProperties properties = new AlluxioProperties();
InstancedConfiguration conf = new InstancedConfiguration(properties);
properties.merge(System.getProperties(), Source.SYSTEM_PROPERTY);
// Step2: Load site specific properties file if not in test mode. Note that we decide
// whether in test mode by default properties and system properties (via getBoolean).
if (conf.getBoolean(PropertyKey.TEST_MODE)) {
conf.validate();
sDefaultProperties = properties;
return;
}
// we are not in test mode, load site properties
String confPaths = conf.get(PropertyKey.SITE_CONF_DIR);
String[] confPathList = confPaths.split(",");
String sitePropertyFile = ConfigurationUtils
.searchPropertiesFile(Constants.SITE_PROPERTIES, confPathList);
Properties siteProps = null;
if (sitePropertyFile != null) {
siteProps = loadPropertiesFromFile(sitePropertyFile);
sSourcePropertyFile = sitePropertyFile;
} else {
URL resource =
ConfigurationUtils.class.getClassLoader().getResource(Constants.SITE_PROPERTIES);
if (resource != null) {
siteProps = loadPropertiesFromResource(resource);
if (siteProps != null) {
sSourcePropertyFile = resource.getPath();
}
}
}
properties.merge(siteProps, Source.siteProperty(sSourcePropertyFile));
conf.validate();
sDefaultProperties = properties;
}
}
|
java
|
public static void reloadProperties() {
synchronized (DEFAULT_PROPERTIES_LOCK) {
// Step1: bootstrap the configuration. This is necessary because we need to resolve alluxio
// .home (likely to be in system properties) to locate the conf dir to search for the site
// property file.
AlluxioProperties properties = new AlluxioProperties();
InstancedConfiguration conf = new InstancedConfiguration(properties);
properties.merge(System.getProperties(), Source.SYSTEM_PROPERTY);
// Step2: Load site specific properties file if not in test mode. Note that we decide
// whether in test mode by default properties and system properties (via getBoolean).
if (conf.getBoolean(PropertyKey.TEST_MODE)) {
conf.validate();
sDefaultProperties = properties;
return;
}
// we are not in test mode, load site properties
String confPaths = conf.get(PropertyKey.SITE_CONF_DIR);
String[] confPathList = confPaths.split(",");
String sitePropertyFile = ConfigurationUtils
.searchPropertiesFile(Constants.SITE_PROPERTIES, confPathList);
Properties siteProps = null;
if (sitePropertyFile != null) {
siteProps = loadPropertiesFromFile(sitePropertyFile);
sSourcePropertyFile = sitePropertyFile;
} else {
URL resource =
ConfigurationUtils.class.getClassLoader().getResource(Constants.SITE_PROPERTIES);
if (resource != null) {
siteProps = loadPropertiesFromResource(resource);
if (siteProps != null) {
sSourcePropertyFile = resource.getPath();
}
}
}
properties.merge(siteProps, Source.siteProperty(sSourcePropertyFile));
conf.validate();
sDefaultProperties = properties;
}
}
|
[
"public",
"static",
"void",
"reloadProperties",
"(",
")",
"{",
"synchronized",
"(",
"DEFAULT_PROPERTIES_LOCK",
")",
"{",
"// Step1: bootstrap the configuration. This is necessary because we need to resolve alluxio",
"// .home (likely to be in system properties) to locate the conf dir to search for the site",
"// property file.",
"AlluxioProperties",
"properties",
"=",
"new",
"AlluxioProperties",
"(",
")",
";",
"InstancedConfiguration",
"conf",
"=",
"new",
"InstancedConfiguration",
"(",
"properties",
")",
";",
"properties",
".",
"merge",
"(",
"System",
".",
"getProperties",
"(",
")",
",",
"Source",
".",
"SYSTEM_PROPERTY",
")",
";",
"// Step2: Load site specific properties file if not in test mode. Note that we decide",
"// whether in test mode by default properties and system properties (via getBoolean).",
"if",
"(",
"conf",
".",
"getBoolean",
"(",
"PropertyKey",
".",
"TEST_MODE",
")",
")",
"{",
"conf",
".",
"validate",
"(",
")",
";",
"sDefaultProperties",
"=",
"properties",
";",
"return",
";",
"}",
"// we are not in test mode, load site properties",
"String",
"confPaths",
"=",
"conf",
".",
"get",
"(",
"PropertyKey",
".",
"SITE_CONF_DIR",
")",
";",
"String",
"[",
"]",
"confPathList",
"=",
"confPaths",
".",
"split",
"(",
"\",\"",
")",
";",
"String",
"sitePropertyFile",
"=",
"ConfigurationUtils",
".",
"searchPropertiesFile",
"(",
"Constants",
".",
"SITE_PROPERTIES",
",",
"confPathList",
")",
";",
"Properties",
"siteProps",
"=",
"null",
";",
"if",
"(",
"sitePropertyFile",
"!=",
"null",
")",
"{",
"siteProps",
"=",
"loadPropertiesFromFile",
"(",
"sitePropertyFile",
")",
";",
"sSourcePropertyFile",
"=",
"sitePropertyFile",
";",
"}",
"else",
"{",
"URL",
"resource",
"=",
"ConfigurationUtils",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"Constants",
".",
"SITE_PROPERTIES",
")",
";",
"if",
"(",
"resource",
"!=",
"null",
")",
"{",
"siteProps",
"=",
"loadPropertiesFromResource",
"(",
"resource",
")",
";",
"if",
"(",
"siteProps",
"!=",
"null",
")",
"{",
"sSourcePropertyFile",
"=",
"resource",
".",
"getPath",
"(",
")",
";",
"}",
"}",
"}",
"properties",
".",
"merge",
"(",
"siteProps",
",",
"Source",
".",
"siteProperty",
"(",
"sSourcePropertyFile",
")",
")",
";",
"conf",
".",
"validate",
"(",
")",
";",
"sDefaultProperties",
"=",
"properties",
";",
"}",
"}"
] |
Reloads site properties from disk.
|
[
"Reloads",
"site",
"properties",
"from",
"disk",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L406-L446
|
18,335
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.loadConfiguration
|
private static GetConfigurationPResponse loadConfiguration(InetSocketAddress address,
AlluxioConfiguration conf) throws AlluxioStatusException {
GrpcChannel channel = null;
try {
LOG.info("Alluxio client (version {}) is trying to load configuration from meta master {}",
RuntimeConstants.VERSION, address);
channel = GrpcChannelBuilder.newBuilder(new GrpcServerAddress(address), conf)
.disableAuthentication().build();
MetaMasterConfigurationServiceGrpc.MetaMasterConfigurationServiceBlockingStub client =
MetaMasterConfigurationServiceGrpc.newBlockingStub(channel);
GetConfigurationPResponse response = client.getConfiguration(
GetConfigurationPOptions.newBuilder().setRawValue(true).build());
LOG.info("Alluxio client has loaded configuration from meta master {}", address);
return response;
} catch (io.grpc.StatusRuntimeException e) {
throw new UnavailableException(String.format(
"Failed to handshake with master %s to load cluster default configuration values: %s",
address, e.getMessage()), e);
} catch (UnauthenticatedException e) {
throw new RuntimeException(String.format(
"Received authentication exception during boot-strap connect with host:%s", address),
e);
} finally {
if (channel != null) {
channel.shutdown();
}
}
}
|
java
|
private static GetConfigurationPResponse loadConfiguration(InetSocketAddress address,
AlluxioConfiguration conf) throws AlluxioStatusException {
GrpcChannel channel = null;
try {
LOG.info("Alluxio client (version {}) is trying to load configuration from meta master {}",
RuntimeConstants.VERSION, address);
channel = GrpcChannelBuilder.newBuilder(new GrpcServerAddress(address), conf)
.disableAuthentication().build();
MetaMasterConfigurationServiceGrpc.MetaMasterConfigurationServiceBlockingStub client =
MetaMasterConfigurationServiceGrpc.newBlockingStub(channel);
GetConfigurationPResponse response = client.getConfiguration(
GetConfigurationPOptions.newBuilder().setRawValue(true).build());
LOG.info("Alluxio client has loaded configuration from meta master {}", address);
return response;
} catch (io.grpc.StatusRuntimeException e) {
throw new UnavailableException(String.format(
"Failed to handshake with master %s to load cluster default configuration values: %s",
address, e.getMessage()), e);
} catch (UnauthenticatedException e) {
throw new RuntimeException(String.format(
"Received authentication exception during boot-strap connect with host:%s", address),
e);
} finally {
if (channel != null) {
channel.shutdown();
}
}
}
|
[
"private",
"static",
"GetConfigurationPResponse",
"loadConfiguration",
"(",
"InetSocketAddress",
"address",
",",
"AlluxioConfiguration",
"conf",
")",
"throws",
"AlluxioStatusException",
"{",
"GrpcChannel",
"channel",
"=",
"null",
";",
"try",
"{",
"LOG",
".",
"info",
"(",
"\"Alluxio client (version {}) is trying to load configuration from meta master {}\"",
",",
"RuntimeConstants",
".",
"VERSION",
",",
"address",
")",
";",
"channel",
"=",
"GrpcChannelBuilder",
".",
"newBuilder",
"(",
"new",
"GrpcServerAddress",
"(",
"address",
")",
",",
"conf",
")",
".",
"disableAuthentication",
"(",
")",
".",
"build",
"(",
")",
";",
"MetaMasterConfigurationServiceGrpc",
".",
"MetaMasterConfigurationServiceBlockingStub",
"client",
"=",
"MetaMasterConfigurationServiceGrpc",
".",
"newBlockingStub",
"(",
"channel",
")",
";",
"GetConfigurationPResponse",
"response",
"=",
"client",
".",
"getConfiguration",
"(",
"GetConfigurationPOptions",
".",
"newBuilder",
"(",
")",
".",
"setRawValue",
"(",
"true",
")",
".",
"build",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Alluxio client has loaded configuration from meta master {}\"",
",",
"address",
")",
";",
"return",
"response",
";",
"}",
"catch",
"(",
"io",
".",
"grpc",
".",
"StatusRuntimeException",
"e",
")",
"{",
"throw",
"new",
"UnavailableException",
"(",
"String",
".",
"format",
"(",
"\"Failed to handshake with master %s to load cluster default configuration values: %s\"",
",",
"address",
",",
"e",
".",
"getMessage",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"catch",
"(",
"UnauthenticatedException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"String",
".",
"format",
"(",
"\"Received authentication exception during boot-strap connect with host:%s\"",
",",
"address",
")",
",",
"e",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"channel",
"!=",
"null",
")",
"{",
"channel",
".",
"shutdown",
"(",
")",
";",
"}",
"}",
"}"
] |
Loads configuration from meta master.
@param address the meta master address
@return the RPC response
|
[
"Loads",
"configuration",
"from",
"meta",
"master",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L471-L498
|
18,336
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.loadClientProperties
|
private static Properties loadClientProperties(List<ConfigProperty> properties,
BiFunction<PropertyKey, String, String> logMessage) {
Properties props = new Properties();
for (ConfigProperty property : properties) {
String name = property.getName();
// TODO(binfan): support propagating unsetting properties from master
if (PropertyKey.isValid(name) && property.hasValue()) {
PropertyKey key = PropertyKey.fromString(name);
if (!GrpcUtils.contains(key.getScope(), Scope.CLIENT)) {
// Only propagate client properties.
continue;
}
String value = property.getValue();
props.put(key, value);
LOG.debug(logMessage.apply(key, value));
}
}
return props;
}
|
java
|
private static Properties loadClientProperties(List<ConfigProperty> properties,
BiFunction<PropertyKey, String, String> logMessage) {
Properties props = new Properties();
for (ConfigProperty property : properties) {
String name = property.getName();
// TODO(binfan): support propagating unsetting properties from master
if (PropertyKey.isValid(name) && property.hasValue()) {
PropertyKey key = PropertyKey.fromString(name);
if (!GrpcUtils.contains(key.getScope(), Scope.CLIENT)) {
// Only propagate client properties.
continue;
}
String value = property.getValue();
props.put(key, value);
LOG.debug(logMessage.apply(key, value));
}
}
return props;
}
|
[
"private",
"static",
"Properties",
"loadClientProperties",
"(",
"List",
"<",
"ConfigProperty",
">",
"properties",
",",
"BiFunction",
"<",
"PropertyKey",
",",
"String",
",",
"String",
">",
"logMessage",
")",
"{",
"Properties",
"props",
"=",
"new",
"Properties",
"(",
")",
";",
"for",
"(",
"ConfigProperty",
"property",
":",
"properties",
")",
"{",
"String",
"name",
"=",
"property",
".",
"getName",
"(",
")",
";",
"// TODO(binfan): support propagating unsetting properties from master",
"if",
"(",
"PropertyKey",
".",
"isValid",
"(",
"name",
")",
"&&",
"property",
".",
"hasValue",
"(",
")",
")",
"{",
"PropertyKey",
"key",
"=",
"PropertyKey",
".",
"fromString",
"(",
"name",
")",
";",
"if",
"(",
"!",
"GrpcUtils",
".",
"contains",
"(",
"key",
".",
"getScope",
"(",
")",
",",
"Scope",
".",
"CLIENT",
")",
")",
"{",
"// Only propagate client properties.",
"continue",
";",
"}",
"String",
"value",
"=",
"property",
".",
"getValue",
"(",
")",
";",
"props",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"LOG",
".",
"debug",
"(",
"logMessage",
".",
"apply",
"(",
"key",
",",
"value",
")",
")",
";",
"}",
"}",
"return",
"props",
";",
"}"
] |
Loads client scope properties from the property list returned by grpc.
@param properties the property list returned by grpc
@param logMessage a function with key and value as parameter and returns debug log message
@return the loaded properties
|
[
"Loads",
"client",
"scope",
"properties",
"from",
"the",
"property",
"list",
"returned",
"by",
"grpc",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L507-L525
|
18,337
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.loadClusterConfiguration
|
private static AlluxioConfiguration loadClusterConfiguration(GetConfigurationPResponse response,
AlluxioConfiguration conf) {
String clientVersion = conf.get(PropertyKey.VERSION);
LOG.info("Alluxio client (version {}) is trying to load cluster level configurations",
clientVersion);
List<alluxio.grpc.ConfigProperty> clusterConfig = response.getConfigsList();
Properties clusterProps = loadClientProperties(clusterConfig, (key, value) ->
String.format("Loading property: %s (%s) -> %s", key, key.getScope(), value));
// Check version.
String clusterVersion = clusterProps.get(PropertyKey.VERSION).toString();
if (!clientVersion.equals(clusterVersion)) {
LOG.warn("Alluxio client version ({}) does not match Alluxio cluster version ({})",
clientVersion, clusterVersion);
clusterProps.remove(PropertyKey.VERSION);
}
// Merge conf returned by master as the cluster default into conf object
AlluxioProperties props = conf.copyProperties();
props.merge(clusterProps, Source.CLUSTER_DEFAULT);
// Use the constructor to set cluster defaults as being loaded.
InstancedConfiguration updatedConf = new InstancedConfiguration(props, true);
updatedConf.validate();
LOG.info("Alluxio client has loaded cluster level configurations");
return updatedConf;
}
|
java
|
private static AlluxioConfiguration loadClusterConfiguration(GetConfigurationPResponse response,
AlluxioConfiguration conf) {
String clientVersion = conf.get(PropertyKey.VERSION);
LOG.info("Alluxio client (version {}) is trying to load cluster level configurations",
clientVersion);
List<alluxio.grpc.ConfigProperty> clusterConfig = response.getConfigsList();
Properties clusterProps = loadClientProperties(clusterConfig, (key, value) ->
String.format("Loading property: %s (%s) -> %s", key, key.getScope(), value));
// Check version.
String clusterVersion = clusterProps.get(PropertyKey.VERSION).toString();
if (!clientVersion.equals(clusterVersion)) {
LOG.warn("Alluxio client version ({}) does not match Alluxio cluster version ({})",
clientVersion, clusterVersion);
clusterProps.remove(PropertyKey.VERSION);
}
// Merge conf returned by master as the cluster default into conf object
AlluxioProperties props = conf.copyProperties();
props.merge(clusterProps, Source.CLUSTER_DEFAULT);
// Use the constructor to set cluster defaults as being loaded.
InstancedConfiguration updatedConf = new InstancedConfiguration(props, true);
updatedConf.validate();
LOG.info("Alluxio client has loaded cluster level configurations");
return updatedConf;
}
|
[
"private",
"static",
"AlluxioConfiguration",
"loadClusterConfiguration",
"(",
"GetConfigurationPResponse",
"response",
",",
"AlluxioConfiguration",
"conf",
")",
"{",
"String",
"clientVersion",
"=",
"conf",
".",
"get",
"(",
"PropertyKey",
".",
"VERSION",
")",
";",
"LOG",
".",
"info",
"(",
"\"Alluxio client (version {}) is trying to load cluster level configurations\"",
",",
"clientVersion",
")",
";",
"List",
"<",
"alluxio",
".",
"grpc",
".",
"ConfigProperty",
">",
"clusterConfig",
"=",
"response",
".",
"getConfigsList",
"(",
")",
";",
"Properties",
"clusterProps",
"=",
"loadClientProperties",
"(",
"clusterConfig",
",",
"(",
"key",
",",
"value",
")",
"->",
"String",
".",
"format",
"(",
"\"Loading property: %s (%s) -> %s\"",
",",
"key",
",",
"key",
".",
"getScope",
"(",
")",
",",
"value",
")",
")",
";",
"// Check version.",
"String",
"clusterVersion",
"=",
"clusterProps",
".",
"get",
"(",
"PropertyKey",
".",
"VERSION",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"!",
"clientVersion",
".",
"equals",
"(",
"clusterVersion",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Alluxio client version ({}) does not match Alluxio cluster version ({})\"",
",",
"clientVersion",
",",
"clusterVersion",
")",
";",
"clusterProps",
".",
"remove",
"(",
"PropertyKey",
".",
"VERSION",
")",
";",
"}",
"// Merge conf returned by master as the cluster default into conf object",
"AlluxioProperties",
"props",
"=",
"conf",
".",
"copyProperties",
"(",
")",
";",
"props",
".",
"merge",
"(",
"clusterProps",
",",
"Source",
".",
"CLUSTER_DEFAULT",
")",
";",
"// Use the constructor to set cluster defaults as being loaded.",
"InstancedConfiguration",
"updatedConf",
"=",
"new",
"InstancedConfiguration",
"(",
"props",
",",
"true",
")",
";",
"updatedConf",
".",
"validate",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Alluxio client has loaded cluster level configurations\"",
")",
";",
"return",
"updatedConf",
";",
"}"
] |
Loads the cluster level configuration from the get configuration response, and merges it with
the existing configuration.
@param response the get configuration RPC response
@param conf the existing configuration
@return the merged configuration
|
[
"Loads",
"the",
"cluster",
"level",
"configuration",
"from",
"the",
"get",
"configuration",
"response",
"and",
"merges",
"it",
"with",
"the",
"existing",
"configuration",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L535-L558
|
18,338
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.loadPathConfiguration
|
private static PathConfiguration loadPathConfiguration(GetConfigurationPResponse response,
AlluxioConfiguration clusterConf) {
String clientVersion = clusterConf.get(PropertyKey.VERSION);
LOG.info("Alluxio client (version {}) is trying to load path level configurations",
clientVersion);
Map<String, AlluxioConfiguration> pathConfs = new HashMap<>();
response.getPathConfigsMap().forEach((path, conf) -> {
Properties props = loadClientProperties(conf.getPropertiesList(),
(key, value) -> String.format("Loading property: %s (%s) -> %s for path %s",
key, key.getScope(), value, path));
AlluxioProperties properties = new AlluxioProperties();
properties.merge(props, Source.PATH_DEFAULT);
pathConfs.put(path, new InstancedConfiguration(properties, true));
});
LOG.info("Alluxio client has loaded path level configurations");
return PathConfiguration.create(pathConfs);
}
|
java
|
private static PathConfiguration loadPathConfiguration(GetConfigurationPResponse response,
AlluxioConfiguration clusterConf) {
String clientVersion = clusterConf.get(PropertyKey.VERSION);
LOG.info("Alluxio client (version {}) is trying to load path level configurations",
clientVersion);
Map<String, AlluxioConfiguration> pathConfs = new HashMap<>();
response.getPathConfigsMap().forEach((path, conf) -> {
Properties props = loadClientProperties(conf.getPropertiesList(),
(key, value) -> String.format("Loading property: %s (%s) -> %s for path %s",
key, key.getScope(), value, path));
AlluxioProperties properties = new AlluxioProperties();
properties.merge(props, Source.PATH_DEFAULT);
pathConfs.put(path, new InstancedConfiguration(properties, true));
});
LOG.info("Alluxio client has loaded path level configurations");
return PathConfiguration.create(pathConfs);
}
|
[
"private",
"static",
"PathConfiguration",
"loadPathConfiguration",
"(",
"GetConfigurationPResponse",
"response",
",",
"AlluxioConfiguration",
"clusterConf",
")",
"{",
"String",
"clientVersion",
"=",
"clusterConf",
".",
"get",
"(",
"PropertyKey",
".",
"VERSION",
")",
";",
"LOG",
".",
"info",
"(",
"\"Alluxio client (version {}) is trying to load path level configurations\"",
",",
"clientVersion",
")",
";",
"Map",
"<",
"String",
",",
"AlluxioConfiguration",
">",
"pathConfs",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"response",
".",
"getPathConfigsMap",
"(",
")",
".",
"forEach",
"(",
"(",
"path",
",",
"conf",
")",
"->",
"{",
"Properties",
"props",
"=",
"loadClientProperties",
"(",
"conf",
".",
"getPropertiesList",
"(",
")",
",",
"(",
"key",
",",
"value",
")",
"->",
"String",
".",
"format",
"(",
"\"Loading property: %s (%s) -> %s for path %s\"",
",",
"key",
",",
"key",
".",
"getScope",
"(",
")",
",",
"value",
",",
"path",
")",
")",
";",
"AlluxioProperties",
"properties",
"=",
"new",
"AlluxioProperties",
"(",
")",
";",
"properties",
".",
"merge",
"(",
"props",
",",
"Source",
".",
"PATH_DEFAULT",
")",
";",
"pathConfs",
".",
"put",
"(",
"path",
",",
"new",
"InstancedConfiguration",
"(",
"properties",
",",
"true",
")",
")",
";",
"}",
")",
";",
"LOG",
".",
"info",
"(",
"\"Alluxio client has loaded path level configurations\"",
")",
";",
"return",
"PathConfiguration",
".",
"create",
"(",
"pathConfs",
")",
";",
"}"
] |
Loads the path level configuration from the get configuration response.
Only client scope properties will be loaded.
@param response the get configuration RPC response
@param clusterConf cluster level configuration
@return the loaded path level configuration
|
[
"Loads",
"the",
"path",
"level",
"configuration",
"from",
"the",
"get",
"configuration",
"response",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L569-L585
|
18,339
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ConfigurationUtils.java
|
ConfigurationUtils.loadClusterAndPathDefaults
|
public static Pair<AlluxioConfiguration, PathConfiguration> loadClusterAndPathDefaults(
InetSocketAddress address, AlluxioConfiguration clusterConf, PathConfiguration pathConf)
throws AlluxioStatusException {
if (shouldLoadClusterConfiguration(clusterConf)) {
GetConfigurationPResponse response = loadConfiguration(address, clusterConf);
clusterConf = loadClusterConfiguration(response, clusterConf);
pathConf = loadPathConfiguration(response, clusterConf);
}
return new Pair<>(clusterConf, pathConf);
}
|
java
|
public static Pair<AlluxioConfiguration, PathConfiguration> loadClusterAndPathDefaults(
InetSocketAddress address, AlluxioConfiguration clusterConf, PathConfiguration pathConf)
throws AlluxioStatusException {
if (shouldLoadClusterConfiguration(clusterConf)) {
GetConfigurationPResponse response = loadConfiguration(address, clusterConf);
clusterConf = loadClusterConfiguration(response, clusterConf);
pathConf = loadPathConfiguration(response, clusterConf);
}
return new Pair<>(clusterConf, pathConf);
}
|
[
"public",
"static",
"Pair",
"<",
"AlluxioConfiguration",
",",
"PathConfiguration",
">",
"loadClusterAndPathDefaults",
"(",
"InetSocketAddress",
"address",
",",
"AlluxioConfiguration",
"clusterConf",
",",
"PathConfiguration",
"pathConf",
")",
"throws",
"AlluxioStatusException",
"{",
"if",
"(",
"shouldLoadClusterConfiguration",
"(",
"clusterConf",
")",
")",
"{",
"GetConfigurationPResponse",
"response",
"=",
"loadConfiguration",
"(",
"address",
",",
"clusterConf",
")",
";",
"clusterConf",
"=",
"loadClusterConfiguration",
"(",
"response",
",",
"clusterConf",
")",
";",
"pathConf",
"=",
"loadPathConfiguration",
"(",
"response",
",",
"clusterConf",
")",
";",
"}",
"return",
"new",
"Pair",
"<>",
"(",
"clusterConf",
",",
"pathConf",
")",
";",
"}"
] |
Loads both cluster and path level configurations from meta master.
Only client scope properties will be loaded.
If cluster level configuration has been loaded or the feature of loading configuration from
meta master is disabled, then no RPC is issued, and both cluster and path level configuration
is kept as original
@param address the meta master address
@param clusterConf the cluster level configuration
@param pathConf the cluster level configuration
@return both cluster and path level configuration
|
[
"Loads",
"both",
"cluster",
"and",
"path",
"level",
"configurations",
"from",
"meta",
"master",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ConfigurationUtils.java#L626-L635
|
18,340
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalFile.java
|
UfsJournalFile.createLogFile
|
static UfsJournalFile createLogFile(URI location, long start, long end) {
return new UfsJournalFile(location, start, end, false);
}
|
java
|
static UfsJournalFile createLogFile(URI location, long start, long end) {
return new UfsJournalFile(location, start, end, false);
}
|
[
"static",
"UfsJournalFile",
"createLogFile",
"(",
"URI",
"location",
",",
"long",
"start",
",",
"long",
"end",
")",
"{",
"return",
"new",
"UfsJournalFile",
"(",
"location",
",",
"start",
",",
"end",
",",
"false",
")",
";",
"}"
] |
Creates a journal log file.
@param location the file location
@param start the start sequence number (inclusive)
@param end the end sequence number (exclusive)
@return the file
|
[
"Creates",
"a",
"journal",
"log",
"file",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalFile.java#L91-L93
|
18,341
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalFile.java
|
UfsJournalFile.createTmpCheckpointFile
|
static UfsJournalFile createTmpCheckpointFile(URI location) {
return new UfsJournalFile(location, UfsJournal.UNKNOWN_SEQUENCE_NUMBER,
UfsJournal.UNKNOWN_SEQUENCE_NUMBER, false);
}
|
java
|
static UfsJournalFile createTmpCheckpointFile(URI location) {
return new UfsJournalFile(location, UfsJournal.UNKNOWN_SEQUENCE_NUMBER,
UfsJournal.UNKNOWN_SEQUENCE_NUMBER, false);
}
|
[
"static",
"UfsJournalFile",
"createTmpCheckpointFile",
"(",
"URI",
"location",
")",
"{",
"return",
"new",
"UfsJournalFile",
"(",
"location",
",",
"UfsJournal",
".",
"UNKNOWN_SEQUENCE_NUMBER",
",",
"UfsJournal",
".",
"UNKNOWN_SEQUENCE_NUMBER",
",",
"false",
")",
";",
"}"
] |
Creates a temporary checkpoint file.
@param location the file location
@return the file
|
[
"Creates",
"a",
"temporary",
"checkpoint",
"file",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalFile.java#L101-L104
|
18,342
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalFile.java
|
UfsJournalFile.encodeCheckpointFileLocation
|
static URI encodeCheckpointFileLocation(UfsJournal journal, long end) {
String filename = String.format("0x%x-0x%x", 0, end);
URI location = URIUtils.appendPathOrDie(journal.getCheckpointDir(), filename);
return location;
}
|
java
|
static URI encodeCheckpointFileLocation(UfsJournal journal, long end) {
String filename = String.format("0x%x-0x%x", 0, end);
URI location = URIUtils.appendPathOrDie(journal.getCheckpointDir(), filename);
return location;
}
|
[
"static",
"URI",
"encodeCheckpointFileLocation",
"(",
"UfsJournal",
"journal",
",",
"long",
"end",
")",
"{",
"String",
"filename",
"=",
"String",
".",
"format",
"(",
"\"0x%x-0x%x\"",
",",
"0",
",",
"end",
")",
";",
"URI",
"location",
"=",
"URIUtils",
".",
"appendPathOrDie",
"(",
"journal",
".",
"getCheckpointDir",
"(",
")",
",",
"filename",
")",
";",
"return",
"location",
";",
"}"
] |
Encodes a checkpoint location under the checkpoint directory.
@param journal the UFS journal instance
@param end the end sequence number (exclusive)
@return the location
|
[
"Encodes",
"a",
"checkpoint",
"location",
"under",
"the",
"checkpoint",
"directory",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalFile.java#L113-L117
|
18,343
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalFile.java
|
UfsJournalFile.encodeLogFileLocation
|
static URI encodeLogFileLocation(UfsJournal journal, long start, long end) {
String filename = String.format("0x%x-0x%x", start, end);
URI location = URIUtils.appendPathOrDie(journal.getLogDir(), filename);
return location;
}
|
java
|
static URI encodeLogFileLocation(UfsJournal journal, long start, long end) {
String filename = String.format("0x%x-0x%x", start, end);
URI location = URIUtils.appendPathOrDie(journal.getLogDir(), filename);
return location;
}
|
[
"static",
"URI",
"encodeLogFileLocation",
"(",
"UfsJournal",
"journal",
",",
"long",
"start",
",",
"long",
"end",
")",
"{",
"String",
"filename",
"=",
"String",
".",
"format",
"(",
"\"0x%x-0x%x\"",
",",
"start",
",",
"end",
")",
";",
"URI",
"location",
"=",
"URIUtils",
".",
"appendPathOrDie",
"(",
"journal",
".",
"getLogDir",
"(",
")",
",",
"filename",
")",
";",
"return",
"location",
";",
"}"
] |
Encodes a log location under the log directory.
@param journal the UFS journal instance
@param start the start sequence number (inclusive)
@param end the end sequence number (exclusive)
@return the location
|
[
"Encodes",
"a",
"log",
"location",
"under",
"the",
"log",
"directory",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalFile.java#L127-L131
|
18,344
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalFile.java
|
UfsJournalFile.encodeTemporaryCheckpointFileLocation
|
static URI encodeTemporaryCheckpointFileLocation(UfsJournal journal) {
return URIUtils.appendPathOrDie(journal.getTmpDir(), UUID.randomUUID().toString());
}
|
java
|
static URI encodeTemporaryCheckpointFileLocation(UfsJournal journal) {
return URIUtils.appendPathOrDie(journal.getTmpDir(), UUID.randomUUID().toString());
}
|
[
"static",
"URI",
"encodeTemporaryCheckpointFileLocation",
"(",
"UfsJournal",
"journal",
")",
"{",
"return",
"URIUtils",
".",
"appendPathOrDie",
"(",
"journal",
".",
"getTmpDir",
"(",
")",
",",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Encodes a temporary location under the temporary directory.
@param journal the UFS journal instance*
@return the location
|
[
"Encodes",
"a",
"temporary",
"location",
"under",
"the",
"temporary",
"directory",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalFile.java#L139-L141
|
18,345
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/UfsFallbackBlockWriteHandler.java
|
UfsFallbackBlockWriteHandler.createUfsBlock
|
private void createUfsBlock(BlockWriteRequestContext context)
throws Exception {
BlockWriteRequest request = context.getRequest();
Protocol.CreateUfsBlockOptions createUfsBlockOptions = request.getCreateUfsBlockOptions();
UfsManager.UfsClient ufsClient = mUfsManager.get(createUfsBlockOptions.getMountId());
alluxio.resource.CloseableResource<UnderFileSystem> ufsResource =
ufsClient.acquireUfsResource();
context.setUfsResource(ufsResource);
String ufsString = MetricsSystem.escape(ufsClient.getUfsMountPointUri());
String ufsPath = BlockUtils.getUfsBlockPath(ufsClient, request.getId());
UnderFileSystem ufs = ufsResource.get();
// Set the atomic flag to be true to ensure only the creation of this file is atomic on close.
OutputStream ufsOutputStream =
ufs.create(ufsPath,
CreateOptions.defaults(ServerConfiguration.global()).setEnsureAtomic(true)
.setCreateParent(true));
context.setOutputStream(ufsOutputStream);
context.setUfsPath(ufsPath);
String counterName = Metric.getMetricNameWithTags(WorkerMetrics.BYTES_WRITTEN_UFS,
WorkerMetrics.TAG_UFS, ufsString);
String meterName = Metric.getMetricNameWithTags(WorkerMetrics.BYTES_WRITTEN_UFS_THROUGHPUT,
WorkerMetrics.TAG_UFS, ufsString);
context.setCounter(MetricsSystem.counter(counterName));
context.setMeter(MetricsSystem.meter(meterName));
}
|
java
|
private void createUfsBlock(BlockWriteRequestContext context)
throws Exception {
BlockWriteRequest request = context.getRequest();
Protocol.CreateUfsBlockOptions createUfsBlockOptions = request.getCreateUfsBlockOptions();
UfsManager.UfsClient ufsClient = mUfsManager.get(createUfsBlockOptions.getMountId());
alluxio.resource.CloseableResource<UnderFileSystem> ufsResource =
ufsClient.acquireUfsResource();
context.setUfsResource(ufsResource);
String ufsString = MetricsSystem.escape(ufsClient.getUfsMountPointUri());
String ufsPath = BlockUtils.getUfsBlockPath(ufsClient, request.getId());
UnderFileSystem ufs = ufsResource.get();
// Set the atomic flag to be true to ensure only the creation of this file is atomic on close.
OutputStream ufsOutputStream =
ufs.create(ufsPath,
CreateOptions.defaults(ServerConfiguration.global()).setEnsureAtomic(true)
.setCreateParent(true));
context.setOutputStream(ufsOutputStream);
context.setUfsPath(ufsPath);
String counterName = Metric.getMetricNameWithTags(WorkerMetrics.BYTES_WRITTEN_UFS,
WorkerMetrics.TAG_UFS, ufsString);
String meterName = Metric.getMetricNameWithTags(WorkerMetrics.BYTES_WRITTEN_UFS_THROUGHPUT,
WorkerMetrics.TAG_UFS, ufsString);
context.setCounter(MetricsSystem.counter(counterName));
context.setMeter(MetricsSystem.meter(meterName));
}
|
[
"private",
"void",
"createUfsBlock",
"(",
"BlockWriteRequestContext",
"context",
")",
"throws",
"Exception",
"{",
"BlockWriteRequest",
"request",
"=",
"context",
".",
"getRequest",
"(",
")",
";",
"Protocol",
".",
"CreateUfsBlockOptions",
"createUfsBlockOptions",
"=",
"request",
".",
"getCreateUfsBlockOptions",
"(",
")",
";",
"UfsManager",
".",
"UfsClient",
"ufsClient",
"=",
"mUfsManager",
".",
"get",
"(",
"createUfsBlockOptions",
".",
"getMountId",
"(",
")",
")",
";",
"alluxio",
".",
"resource",
".",
"CloseableResource",
"<",
"UnderFileSystem",
">",
"ufsResource",
"=",
"ufsClient",
".",
"acquireUfsResource",
"(",
")",
";",
"context",
".",
"setUfsResource",
"(",
"ufsResource",
")",
";",
"String",
"ufsString",
"=",
"MetricsSystem",
".",
"escape",
"(",
"ufsClient",
".",
"getUfsMountPointUri",
"(",
")",
")",
";",
"String",
"ufsPath",
"=",
"BlockUtils",
".",
"getUfsBlockPath",
"(",
"ufsClient",
",",
"request",
".",
"getId",
"(",
")",
")",
";",
"UnderFileSystem",
"ufs",
"=",
"ufsResource",
".",
"get",
"(",
")",
";",
"// Set the atomic flag to be true to ensure only the creation of this file is atomic on close.",
"OutputStream",
"ufsOutputStream",
"=",
"ufs",
".",
"create",
"(",
"ufsPath",
",",
"CreateOptions",
".",
"defaults",
"(",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
".",
"setEnsureAtomic",
"(",
"true",
")",
".",
"setCreateParent",
"(",
"true",
")",
")",
";",
"context",
".",
"setOutputStream",
"(",
"ufsOutputStream",
")",
";",
"context",
".",
"setUfsPath",
"(",
"ufsPath",
")",
";",
"String",
"counterName",
"=",
"Metric",
".",
"getMetricNameWithTags",
"(",
"WorkerMetrics",
".",
"BYTES_WRITTEN_UFS",
",",
"WorkerMetrics",
".",
"TAG_UFS",
",",
"ufsString",
")",
";",
"String",
"meterName",
"=",
"Metric",
".",
"getMetricNameWithTags",
"(",
"WorkerMetrics",
".",
"BYTES_WRITTEN_UFS_THROUGHPUT",
",",
"WorkerMetrics",
".",
"TAG_UFS",
",",
"ufsString",
")",
";",
"context",
".",
"setCounter",
"(",
"MetricsSystem",
".",
"counter",
"(",
"counterName",
")",
")",
";",
"context",
".",
"setMeter",
"(",
"MetricsSystem",
".",
"meter",
"(",
"meterName",
")",
")",
";",
"}"
] |
Creates a UFS block and initialize it with bytes read from block store.
@param context context of this request
|
[
"Creates",
"a",
"UFS",
"block",
"and",
"initialize",
"it",
"with",
"bytes",
"read",
"from",
"block",
"store",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/UfsFallbackBlockWriteHandler.java#L209-L234
|
18,346
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/UfsFallbackBlockWriteHandler.java
|
UfsFallbackBlockWriteHandler.transferToUfsBlock
|
private void transferToUfsBlock(BlockWriteRequestContext context, long pos) throws Exception {
OutputStream ufsOutputStream = context.getOutputStream();
long sessionId = context.getRequest().getSessionId();
long blockId = context.getRequest().getId();
TempBlockMeta block = mWorker.getBlockStore().getTempBlockMeta(sessionId, blockId);
if (block == null) {
throw new NotFoundException("block " + blockId + " not found");
}
Preconditions.checkState(Files.copy(Paths.get(block.getPath()), ufsOutputStream) == pos);
}
|
java
|
private void transferToUfsBlock(BlockWriteRequestContext context, long pos) throws Exception {
OutputStream ufsOutputStream = context.getOutputStream();
long sessionId = context.getRequest().getSessionId();
long blockId = context.getRequest().getId();
TempBlockMeta block = mWorker.getBlockStore().getTempBlockMeta(sessionId, blockId);
if (block == null) {
throw new NotFoundException("block " + blockId + " not found");
}
Preconditions.checkState(Files.copy(Paths.get(block.getPath()), ufsOutputStream) == pos);
}
|
[
"private",
"void",
"transferToUfsBlock",
"(",
"BlockWriteRequestContext",
"context",
",",
"long",
"pos",
")",
"throws",
"Exception",
"{",
"OutputStream",
"ufsOutputStream",
"=",
"context",
".",
"getOutputStream",
"(",
")",
";",
"long",
"sessionId",
"=",
"context",
".",
"getRequest",
"(",
")",
".",
"getSessionId",
"(",
")",
";",
"long",
"blockId",
"=",
"context",
".",
"getRequest",
"(",
")",
".",
"getId",
"(",
")",
";",
"TempBlockMeta",
"block",
"=",
"mWorker",
".",
"getBlockStore",
"(",
")",
".",
"getTempBlockMeta",
"(",
"sessionId",
",",
"blockId",
")",
";",
"if",
"(",
"block",
"==",
"null",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"\"block \"",
"+",
"blockId",
"+",
"\" not found\"",
")",
";",
"}",
"Preconditions",
".",
"checkState",
"(",
"Files",
".",
"copy",
"(",
"Paths",
".",
"get",
"(",
"block",
".",
"getPath",
"(",
")",
")",
",",
"ufsOutputStream",
")",
"==",
"pos",
")",
";",
"}"
] |
Transfers data from block store to UFS.
@param context context of this request
@param pos number of bytes in block store to write in the UFS block
|
[
"Transfers",
"data",
"from",
"block",
"store",
"to",
"UFS",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/UfsFallbackBlockWriteHandler.java#L242-L252
|
18,347
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journalv0/AsyncJournalWriter.java
|
AsyncJournalWriter.flush
|
public void flush(final long targetCounter) throws IOException {
if (targetCounter <= mFlushCounter.get()) {
return;
}
// Using reentrant lock, since it seems to result in higher throughput than using 'synchronized'
mFlushLock.lock();
try {
long startTime = System.nanoTime();
long flushCounter = mFlushCounter.get();
if (targetCounter <= flushCounter) {
// The specified counter is already flushed, so just return.
return;
}
long writeCounter = mWriteCounter.get();
while (targetCounter > writeCounter) {
for (;;) {
// Get, but do not remove, the head entry.
JournalEntry entry = mQueue.peek();
if (entry == null) {
// No more entries in the queue. Break out of the infinite for-loop.
break;
}
mJournalWriter.write(entry);
// Remove the head entry, after the entry was successfully written.
mQueue.poll();
writeCounter = mWriteCounter.incrementAndGet();
if (writeCounter >= targetCounter) {
if ((System.nanoTime() - startTime) >= mFlushBatchTimeNs) {
// This thread has been writing to the journal for enough time. Break out of the
// infinite for-loop.
break;
}
}
}
}
mJournalWriter.flush();
mFlushCounter.set(writeCounter);
} finally {
mFlushLock.unlock();
}
}
|
java
|
public void flush(final long targetCounter) throws IOException {
if (targetCounter <= mFlushCounter.get()) {
return;
}
// Using reentrant lock, since it seems to result in higher throughput than using 'synchronized'
mFlushLock.lock();
try {
long startTime = System.nanoTime();
long flushCounter = mFlushCounter.get();
if (targetCounter <= flushCounter) {
// The specified counter is already flushed, so just return.
return;
}
long writeCounter = mWriteCounter.get();
while (targetCounter > writeCounter) {
for (;;) {
// Get, but do not remove, the head entry.
JournalEntry entry = mQueue.peek();
if (entry == null) {
// No more entries in the queue. Break out of the infinite for-loop.
break;
}
mJournalWriter.write(entry);
// Remove the head entry, after the entry was successfully written.
mQueue.poll();
writeCounter = mWriteCounter.incrementAndGet();
if (writeCounter >= targetCounter) {
if ((System.nanoTime() - startTime) >= mFlushBatchTimeNs) {
// This thread has been writing to the journal for enough time. Break out of the
// infinite for-loop.
break;
}
}
}
}
mJournalWriter.flush();
mFlushCounter.set(writeCounter);
} finally {
mFlushLock.unlock();
}
}
|
[
"public",
"void",
"flush",
"(",
"final",
"long",
"targetCounter",
")",
"throws",
"IOException",
"{",
"if",
"(",
"targetCounter",
"<=",
"mFlushCounter",
".",
"get",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Using reentrant lock, since it seems to result in higher throughput than using 'synchronized'",
"mFlushLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"long",
"startTime",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"long",
"flushCounter",
"=",
"mFlushCounter",
".",
"get",
"(",
")",
";",
"if",
"(",
"targetCounter",
"<=",
"flushCounter",
")",
"{",
"// The specified counter is already flushed, so just return.",
"return",
";",
"}",
"long",
"writeCounter",
"=",
"mWriteCounter",
".",
"get",
"(",
")",
";",
"while",
"(",
"targetCounter",
">",
"writeCounter",
")",
"{",
"for",
"(",
";",
";",
")",
"{",
"// Get, but do not remove, the head entry.",
"JournalEntry",
"entry",
"=",
"mQueue",
".",
"peek",
"(",
")",
";",
"if",
"(",
"entry",
"==",
"null",
")",
"{",
"// No more entries in the queue. Break out of the infinite for-loop.",
"break",
";",
"}",
"mJournalWriter",
".",
"write",
"(",
"entry",
")",
";",
"// Remove the head entry, after the entry was successfully written.",
"mQueue",
".",
"poll",
"(",
")",
";",
"writeCounter",
"=",
"mWriteCounter",
".",
"incrementAndGet",
"(",
")",
";",
"if",
"(",
"writeCounter",
">=",
"targetCounter",
")",
"{",
"if",
"(",
"(",
"System",
".",
"nanoTime",
"(",
")",
"-",
"startTime",
")",
">=",
"mFlushBatchTimeNs",
")",
"{",
"// This thread has been writing to the journal for enough time. Break out of the",
"// infinite for-loop.",
"break",
";",
"}",
"}",
"}",
"}",
"mJournalWriter",
".",
"flush",
"(",
")",
";",
"mFlushCounter",
".",
"set",
"(",
"writeCounter",
")",
";",
"}",
"finally",
"{",
"mFlushLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Flushes and waits until the specified counter is flushed to the journal. If the specified
counter is already flushed, this is essentially a no-op.
@param targetCounter the counter to flush
|
[
"Flushes",
"and",
"waits",
"until",
"the",
"specified",
"counter",
"is",
"flushed",
"to",
"the",
"journal",
".",
"If",
"the",
"specified",
"counter",
"is",
"already",
"flushed",
"this",
"is",
"essentially",
"a",
"no",
"-",
"op",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journalv0/AsyncJournalWriter.java#L105-L146
|
18,348
|
Alluxio/alluxio
|
integration/fuse/src/main/java/alluxio/fuse/OpenFileEntry.java
|
OpenFileEntry.close
|
@Override
public void close() throws IOException {
if (mIn != null) {
mIn.close();
}
if (mOut != null) {
mOut.close();
}
mOffset = -1;
}
|
java
|
@Override
public void close() throws IOException {
if (mIn != null) {
mIn.close();
}
if (mOut != null) {
mOut.close();
}
mOffset = -1;
}
|
[
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mIn",
"!=",
"null",
")",
"{",
"mIn",
".",
"close",
"(",
")",
";",
"}",
"if",
"(",
"mOut",
"!=",
"null",
")",
"{",
"mOut",
".",
"close",
"(",
")",
";",
"}",
"mOffset",
"=",
"-",
"1",
";",
"}"
] |
Closes the underlying open streams.
|
[
"Closes",
"the",
"underlying",
"open",
"streams",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/fuse/src/main/java/alluxio/fuse/OpenFileEntry.java#L127-L137
|
18,349
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/conf/ServerConfiguration.java
|
ServerConfiguration.getList
|
public static List<String> getList(PropertyKey key, String delimiter) {
return sConf.getList(key, delimiter);
}
|
java
|
public static List<String> getList(PropertyKey key, String delimiter) {
return sConf.getList(key, delimiter);
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"getList",
"(",
"PropertyKey",
"key",
",",
"String",
"delimiter",
")",
"{",
"return",
"sConf",
".",
"getList",
"(",
"key",
",",
"delimiter",
")",
";",
"}"
] |
Gets the value for the given key as a list.
@param key the key to get the value for
@param delimiter the delimiter to split the values
@return the list of values for the given key
|
[
"Gets",
"the",
"value",
"for",
"the",
"given",
"key",
"as",
"a",
"list",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/conf/ServerConfiguration.java#L241-L243
|
18,350
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/conf/ServerConfiguration.java
|
ServerConfiguration.getEnum
|
public static <T extends Enum<T>> T getEnum(PropertyKey key, Class<T> enumType) {
return sConf.getEnum(key, enumType);
}
|
java
|
public static <T extends Enum<T>> T getEnum(PropertyKey key, Class<T> enumType) {
return sConf.getEnum(key, enumType);
}
|
[
"public",
"static",
"<",
"T",
"extends",
"Enum",
"<",
"T",
">",
">",
"T",
"getEnum",
"(",
"PropertyKey",
"key",
",",
"Class",
"<",
"T",
">",
"enumType",
")",
"{",
"return",
"sConf",
".",
"getEnum",
"(",
"key",
",",
"enumType",
")",
";",
"}"
] |
Gets the value for the given key as an enum value.
@param key the key to get the value for
@param enumType the type of the enum
@param <T> the type of the enum
@return the value for the given key as an enum value
|
[
"Gets",
"the",
"value",
"for",
"the",
"given",
"key",
"as",
"an",
"enum",
"value",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/conf/ServerConfiguration.java#L253-L255
|
18,351
|
Alluxio/alluxio
|
integration/checker/src/main/java/alluxio/checker/CheckerUtils.java
|
CheckerUtils.supportAlluxioHA
|
public static boolean supportAlluxioHA(PrintWriter reportWriter,
AlluxioConfiguration alluxioConf) {
if (alluxioConf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) {
reportWriter.println("Alluixo is running in high availability mode.\n");
if (!alluxioConf.isSet(PropertyKey.ZOOKEEPER_ADDRESS)) {
reportWriter.println("Please set Zookeeper address to support "
+ "Alluxio high availability mode.\n");
return false;
} else {
reportWriter.printf("Zookeeper address is: %s.%n",
alluxioConf.get(PropertyKey.ZOOKEEPER_ADDRESS));
}
}
return true;
}
|
java
|
public static boolean supportAlluxioHA(PrintWriter reportWriter,
AlluxioConfiguration alluxioConf) {
if (alluxioConf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) {
reportWriter.println("Alluixo is running in high availability mode.\n");
if (!alluxioConf.isSet(PropertyKey.ZOOKEEPER_ADDRESS)) {
reportWriter.println("Please set Zookeeper address to support "
+ "Alluxio high availability mode.\n");
return false;
} else {
reportWriter.printf("Zookeeper address is: %s.%n",
alluxioConf.get(PropertyKey.ZOOKEEPER_ADDRESS));
}
}
return true;
}
|
[
"public",
"static",
"boolean",
"supportAlluxioHA",
"(",
"PrintWriter",
"reportWriter",
",",
"AlluxioConfiguration",
"alluxioConf",
")",
"{",
"if",
"(",
"alluxioConf",
".",
"getBoolean",
"(",
"PropertyKey",
".",
"ZOOKEEPER_ENABLED",
")",
")",
"{",
"reportWriter",
".",
"println",
"(",
"\"Alluixo is running in high availability mode.\\n\"",
")",
";",
"if",
"(",
"!",
"alluxioConf",
".",
"isSet",
"(",
"PropertyKey",
".",
"ZOOKEEPER_ADDRESS",
")",
")",
"{",
"reportWriter",
".",
"println",
"(",
"\"Please set Zookeeper address to support \"",
"+",
"\"Alluxio high availability mode.\\n\"",
")",
";",
"return",
"false",
";",
"}",
"else",
"{",
"reportWriter",
".",
"printf",
"(",
"\"Zookeeper address is: %s.%n\"",
",",
"alluxioConf",
".",
"get",
"(",
"PropertyKey",
".",
"ZOOKEEPER_ADDRESS",
")",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Checks if the Zookeeper address has been set when running the Alluxio HA mode.
@param reportWriter save user-facing messages to a generated file
@param alluxioConf Alluxio configuration
@return true if Alluxio HA mode is supported, false otherwise
|
[
"Checks",
"if",
"the",
"Zookeeper",
"address",
"has",
"been",
"set",
"when",
"running",
"the",
"Alluxio",
"HA",
"mode",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/checker/src/main/java/alluxio/checker/CheckerUtils.java#L104-L118
|
18,352
|
Alluxio/alluxio
|
integration/checker/src/main/java/alluxio/checker/CheckerUtils.java
|
CheckerUtils.printNodesResults
|
public static Status printNodesResults(Map<Status, List<String>> map, PrintWriter reportWriter) {
boolean canFindClass = true;
boolean canFindFS = true;
for (Map.Entry<Status, List<String>> entry : map.entrySet()) {
String nodeAddresses = String.join(" ", entry.getValue());
switch (entry.getKey()) {
case FAIL_TO_FIND_CLASS:
canFindClass = false;
reportWriter.printf("Nodes of IP addresses: %s "
+ "cannot recognize Alluxio classes.%n%n", nodeAddresses);
break;
case FAIL_TO_FIND_FS:
canFindFS = false;
reportWriter.printf("Nodes of IP addresses: %s "
+ "cannot recognize Alluxio filesystem.%n%n", nodeAddresses);
break;
default:
reportWriter.printf("Nodes of IP addresses: %s "
+ "can recognize Alluxio filesystem.%n%n", nodeAddresses);
}
}
return canFindClass ? (canFindFS ? Status.SUCCESS : Status.FAIL_TO_FIND_FS)
: Status.FAIL_TO_FIND_CLASS;
}
|
java
|
public static Status printNodesResults(Map<Status, List<String>> map, PrintWriter reportWriter) {
boolean canFindClass = true;
boolean canFindFS = true;
for (Map.Entry<Status, List<String>> entry : map.entrySet()) {
String nodeAddresses = String.join(" ", entry.getValue());
switch (entry.getKey()) {
case FAIL_TO_FIND_CLASS:
canFindClass = false;
reportWriter.printf("Nodes of IP addresses: %s "
+ "cannot recognize Alluxio classes.%n%n", nodeAddresses);
break;
case FAIL_TO_FIND_FS:
canFindFS = false;
reportWriter.printf("Nodes of IP addresses: %s "
+ "cannot recognize Alluxio filesystem.%n%n", nodeAddresses);
break;
default:
reportWriter.printf("Nodes of IP addresses: %s "
+ "can recognize Alluxio filesystem.%n%n", nodeAddresses);
}
}
return canFindClass ? (canFindFS ? Status.SUCCESS : Status.FAIL_TO_FIND_FS)
: Status.FAIL_TO_FIND_CLASS;
}
|
[
"public",
"static",
"Status",
"printNodesResults",
"(",
"Map",
"<",
"Status",
",",
"List",
"<",
"String",
">",
">",
"map",
",",
"PrintWriter",
"reportWriter",
")",
"{",
"boolean",
"canFindClass",
"=",
"true",
";",
"boolean",
"canFindFS",
"=",
"true",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Status",
",",
"List",
"<",
"String",
">",
">",
"entry",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"nodeAddresses",
"=",
"String",
".",
"join",
"(",
"\" \"",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"switch",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
"{",
"case",
"FAIL_TO_FIND_CLASS",
":",
"canFindClass",
"=",
"false",
";",
"reportWriter",
".",
"printf",
"(",
"\"Nodes of IP addresses: %s \"",
"+",
"\"cannot recognize Alluxio classes.%n%n\"",
",",
"nodeAddresses",
")",
";",
"break",
";",
"case",
"FAIL_TO_FIND_FS",
":",
"canFindFS",
"=",
"false",
";",
"reportWriter",
".",
"printf",
"(",
"\"Nodes of IP addresses: %s \"",
"+",
"\"cannot recognize Alluxio filesystem.%n%n\"",
",",
"nodeAddresses",
")",
";",
"break",
";",
"default",
":",
"reportWriter",
".",
"printf",
"(",
"\"Nodes of IP addresses: %s \"",
"+",
"\"can recognize Alluxio filesystem.%n%n\"",
",",
"nodeAddresses",
")",
";",
"}",
"}",
"return",
"canFindClass",
"?",
"(",
"canFindFS",
"?",
"Status",
".",
"SUCCESS",
":",
"Status",
".",
"FAIL_TO_FIND_FS",
")",
":",
"Status",
".",
"FAIL_TO_FIND_CLASS",
";",
"}"
] |
Collects and saves the Status of checked nodes.
@param map the transformed integration checker results
@param reportWriter save the result to corresponding checker report
@return the result information of the checked nodes
|
[
"Collects",
"and",
"saves",
"the",
"Status",
"of",
"checked",
"nodes",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/checker/src/main/java/alluxio/checker/CheckerUtils.java#L141-L165
|
18,353
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/wire/MasterWebUIConfiguration.java
|
MasterWebUIConfiguration.setConfiguration
|
public MasterWebUIConfiguration setConfiguration(
TreeSet<Triple<String, String, String>> configuration) {
mConfiguration = configuration;
return this;
}
|
java
|
public MasterWebUIConfiguration setConfiguration(
TreeSet<Triple<String, String, String>> configuration) {
mConfiguration = configuration;
return this;
}
|
[
"public",
"MasterWebUIConfiguration",
"setConfiguration",
"(",
"TreeSet",
"<",
"Triple",
"<",
"String",
",",
"String",
",",
"String",
">",
">",
"configuration",
")",
"{",
"mConfiguration",
"=",
"configuration",
";",
"return",
"this",
";",
"}"
] |
Sets configuration.
@param configuration the configuration
@return the configuration
|
[
"Sets",
"configuration",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/wire/MasterWebUIConfiguration.java#L63-L67
|
18,354
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/MutableInodeDirectory.java
|
MutableInodeDirectory.generateClientFileInfo
|
@Override
public FileInfo generateClientFileInfo(String path) {
FileInfo ret = new FileInfo();
ret.setFileId(getId());
ret.setName(getName());
ret.setPath(path);
ret.setBlockSizeBytes(0);
ret.setCreationTimeMs(getCreationTimeMs());
ret.setCompleted(true);
ret.setFolder(isDirectory());
ret.setPinned(isPinned());
ret.setCacheable(false);
ret.setPersisted(isPersisted());
ret.setLastModificationTimeMs(getLastModificationTimeMs());
ret.setTtl(mTtl);
ret.setTtlAction(mTtlAction);
ret.setOwner(getOwner());
ret.setGroup(getGroup());
ret.setMode(getMode());
ret.setPersistenceState(getPersistenceState().toString());
ret.setMountPoint(isMountPoint());
ret.setUfsFingerprint(Constants.INVALID_UFS_FINGERPRINT);
ret.setAcl(mAcl);
ret.setDefaultAcl(mDefaultAcl);
return ret;
}
|
java
|
@Override
public FileInfo generateClientFileInfo(String path) {
FileInfo ret = new FileInfo();
ret.setFileId(getId());
ret.setName(getName());
ret.setPath(path);
ret.setBlockSizeBytes(0);
ret.setCreationTimeMs(getCreationTimeMs());
ret.setCompleted(true);
ret.setFolder(isDirectory());
ret.setPinned(isPinned());
ret.setCacheable(false);
ret.setPersisted(isPersisted());
ret.setLastModificationTimeMs(getLastModificationTimeMs());
ret.setTtl(mTtl);
ret.setTtlAction(mTtlAction);
ret.setOwner(getOwner());
ret.setGroup(getGroup());
ret.setMode(getMode());
ret.setPersistenceState(getPersistenceState().toString());
ret.setMountPoint(isMountPoint());
ret.setUfsFingerprint(Constants.INVALID_UFS_FINGERPRINT);
ret.setAcl(mAcl);
ret.setDefaultAcl(mDefaultAcl);
return ret;
}
|
[
"@",
"Override",
"public",
"FileInfo",
"generateClientFileInfo",
"(",
"String",
"path",
")",
"{",
"FileInfo",
"ret",
"=",
"new",
"FileInfo",
"(",
")",
";",
"ret",
".",
"setFileId",
"(",
"getId",
"(",
")",
")",
";",
"ret",
".",
"setName",
"(",
"getName",
"(",
")",
")",
";",
"ret",
".",
"setPath",
"(",
"path",
")",
";",
"ret",
".",
"setBlockSizeBytes",
"(",
"0",
")",
";",
"ret",
".",
"setCreationTimeMs",
"(",
"getCreationTimeMs",
"(",
")",
")",
";",
"ret",
".",
"setCompleted",
"(",
"true",
")",
";",
"ret",
".",
"setFolder",
"(",
"isDirectory",
"(",
")",
")",
";",
"ret",
".",
"setPinned",
"(",
"isPinned",
"(",
")",
")",
";",
"ret",
".",
"setCacheable",
"(",
"false",
")",
";",
"ret",
".",
"setPersisted",
"(",
"isPersisted",
"(",
")",
")",
";",
"ret",
".",
"setLastModificationTimeMs",
"(",
"getLastModificationTimeMs",
"(",
")",
")",
";",
"ret",
".",
"setTtl",
"(",
"mTtl",
")",
";",
"ret",
".",
"setTtlAction",
"(",
"mTtlAction",
")",
";",
"ret",
".",
"setOwner",
"(",
"getOwner",
"(",
")",
")",
";",
"ret",
".",
"setGroup",
"(",
"getGroup",
"(",
")",
")",
";",
"ret",
".",
"setMode",
"(",
"getMode",
"(",
")",
")",
";",
"ret",
".",
"setPersistenceState",
"(",
"getPersistenceState",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"ret",
".",
"setMountPoint",
"(",
"isMountPoint",
"(",
")",
")",
";",
"ret",
".",
"setUfsFingerprint",
"(",
"Constants",
".",
"INVALID_UFS_FINGERPRINT",
")",
";",
"ret",
".",
"setAcl",
"(",
"mAcl",
")",
";",
"ret",
".",
"setDefaultAcl",
"(",
"mDefaultAcl",
")",
";",
"return",
"ret",
";",
"}"
] |
Generates client file info for a folder.
@param path the path of the folder in the filesystem
@return the generated {@link FileInfo}
|
[
"Generates",
"client",
"file",
"info",
"for",
"a",
"folder",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/MutableInodeDirectory.java#L117-L142
|
18,355
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/MutableInodeDirectory.java
|
MutableInodeDirectory.updateFromEntry
|
public void updateFromEntry(UpdateInodeDirectoryEntry entry) {
if (entry.hasDefaultAcl()) {
setDefaultACL(
(DefaultAccessControlList) ProtoUtils.fromProto(entry.getDefaultAcl()));
}
if (entry.hasDirectChildrenLoaded()) {
setDirectChildrenLoaded(entry.getDirectChildrenLoaded());
}
if (entry.hasMountPoint()) {
setMountPoint(entry.getMountPoint());
}
}
|
java
|
public void updateFromEntry(UpdateInodeDirectoryEntry entry) {
if (entry.hasDefaultAcl()) {
setDefaultACL(
(DefaultAccessControlList) ProtoUtils.fromProto(entry.getDefaultAcl()));
}
if (entry.hasDirectChildrenLoaded()) {
setDirectChildrenLoaded(entry.getDirectChildrenLoaded());
}
if (entry.hasMountPoint()) {
setMountPoint(entry.getMountPoint());
}
}
|
[
"public",
"void",
"updateFromEntry",
"(",
"UpdateInodeDirectoryEntry",
"entry",
")",
"{",
"if",
"(",
"entry",
".",
"hasDefaultAcl",
"(",
")",
")",
"{",
"setDefaultACL",
"(",
"(",
"DefaultAccessControlList",
")",
"ProtoUtils",
".",
"fromProto",
"(",
"entry",
".",
"getDefaultAcl",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasDirectChildrenLoaded",
"(",
")",
")",
"{",
"setDirectChildrenLoaded",
"(",
"entry",
".",
"getDirectChildrenLoaded",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasMountPoint",
"(",
")",
")",
"{",
"setMountPoint",
"(",
"entry",
".",
"getMountPoint",
"(",
")",
")",
";",
"}",
"}"
] |
Updates this inode directory's state from the given entry.
@param entry the entry
|
[
"Updates",
"this",
"inode",
"directory",
"s",
"state",
"from",
"the",
"given",
"entry",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/MutableInodeDirectory.java#L149-L160
|
18,356
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/policy/LocalFirstAvoidEvictionPolicy.java
|
LocalFirstAvoidEvictionPolicy.getAvailableBytes
|
private long getAvailableBytes(BlockWorkerInfo workerInfo) {
long mCapacityBytes = workerInfo.getCapacityBytes();
long mUsedBytes = workerInfo.getUsedBytes();
return mCapacityBytes - mUsedBytes - mBlockCapacityReserved;
}
|
java
|
private long getAvailableBytes(BlockWorkerInfo workerInfo) {
long mCapacityBytes = workerInfo.getCapacityBytes();
long mUsedBytes = workerInfo.getUsedBytes();
return mCapacityBytes - mUsedBytes - mBlockCapacityReserved;
}
|
[
"private",
"long",
"getAvailableBytes",
"(",
"BlockWorkerInfo",
"workerInfo",
")",
"{",
"long",
"mCapacityBytes",
"=",
"workerInfo",
".",
"getCapacityBytes",
"(",
")",
";",
"long",
"mUsedBytes",
"=",
"workerInfo",
".",
"getUsedBytes",
"(",
")",
";",
"return",
"mCapacityBytes",
"-",
"mUsedBytes",
"-",
"mBlockCapacityReserved",
";",
"}"
] |
The information of BlockWorkerInfo is update after a file complete write. To avoid evict,
user should configure "alluxio.user.file.write.avoid.eviction.policy.reserved.size.bytes"
to reserve some space to store the block.
@param workerInfo BlockWorkerInfo of the worker
@return the available bytes of the worker
|
[
"The",
"information",
"of",
"BlockWorkerInfo",
"is",
"update",
"after",
"a",
"file",
"complete",
"write",
".",
"To",
"avoid",
"evict",
"user",
"should",
"configure",
"alluxio",
".",
"user",
".",
"file",
".",
"write",
".",
"avoid",
".",
"eviction",
".",
"policy",
".",
"reserved",
".",
"size",
".",
"bytes",
"to",
"reserve",
"some",
"space",
"to",
"store",
"the",
"block",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/policy/LocalFirstAvoidEvictionPolicy.java#L88-L92
|
18,357
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/RpcUtils.java
|
RpcUtils.streamingRPCAndLog
|
@Nullable
public static <T> T streamingRPCAndLog(Logger logger, StreamingRpcCallable<T> callable,
String methodName, String description, Object... args) {
// avoid string format for better performance if debug is off
String debugDesc = logger.isDebugEnabled() ? String.format(description, args) : null;
try (Timer.Context ctx = MetricsSystem.timer(getQualifiedMetricName(methodName)).time()) {
logger.debug("Enter: {}: {}", methodName, debugDesc);
T result = callable.call();
logger.debug("Exit (OK): {}: {}", methodName, debugDesc);
return result;
} catch (Exception e) {
logger.warn("Exit (Error): {}: {}, Error={}", methodName, String.format(description, args),
e);
MetricsSystem.counter(getQualifiedFailureMetricName(methodName)).inc();
callable.exceptionCaught(e);
}
return null;
}
|
java
|
@Nullable
public static <T> T streamingRPCAndLog(Logger logger, StreamingRpcCallable<T> callable,
String methodName, String description, Object... args) {
// avoid string format for better performance if debug is off
String debugDesc = logger.isDebugEnabled() ? String.format(description, args) : null;
try (Timer.Context ctx = MetricsSystem.timer(getQualifiedMetricName(methodName)).time()) {
logger.debug("Enter: {}: {}", methodName, debugDesc);
T result = callable.call();
logger.debug("Exit (OK): {}: {}", methodName, debugDesc);
return result;
} catch (Exception e) {
logger.warn("Exit (Error): {}: {}, Error={}", methodName, String.format(description, args),
e);
MetricsSystem.counter(getQualifiedFailureMetricName(methodName)).inc();
callable.exceptionCaught(e);
}
return null;
}
|
[
"@",
"Nullable",
"public",
"static",
"<",
"T",
">",
"T",
"streamingRPCAndLog",
"(",
"Logger",
"logger",
",",
"StreamingRpcCallable",
"<",
"T",
">",
"callable",
",",
"String",
"methodName",
",",
"String",
"description",
",",
"Object",
"...",
"args",
")",
"{",
"// avoid string format for better performance if debug is off",
"String",
"debugDesc",
"=",
"logger",
".",
"isDebugEnabled",
"(",
")",
"?",
"String",
".",
"format",
"(",
"description",
",",
"args",
")",
":",
"null",
";",
"try",
"(",
"Timer",
".",
"Context",
"ctx",
"=",
"MetricsSystem",
".",
"timer",
"(",
"getQualifiedMetricName",
"(",
"methodName",
")",
")",
".",
"time",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"Enter: {}: {}\"",
",",
"methodName",
",",
"debugDesc",
")",
";",
"T",
"result",
"=",
"callable",
".",
"call",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"\"Exit (OK): {}: {}\"",
",",
"methodName",
",",
"debugDesc",
")",
";",
"return",
"result",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"\"Exit (Error): {}: {}, Error={}\"",
",",
"methodName",
",",
"String",
".",
"format",
"(",
"description",
",",
"args",
")",
",",
"e",
")",
";",
"MetricsSystem",
".",
"counter",
"(",
"getQualifiedFailureMetricName",
"(",
"methodName",
")",
")",
".",
"inc",
"(",
")",
";",
"callable",
".",
"exceptionCaught",
"(",
"e",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Handles a streaming RPC callable with logging.
@param logger the logger to use for this call
@param callable the callable to call
@param methodName the name of the method, used for metrics
@param description the format string of the description, used for logging
@param args the arguments for the description
@param <T> the return type of the callable
@return the rpc result
|
[
"Handles",
"a",
"streaming",
"RPC",
"callable",
"with",
"logging",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/RpcUtils.java#L293-L310
|
18,358
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/Master.java
|
Master.start
|
public synchronized void start() {
Preconditions.checkState(mProcess == null, "Master is already running");
LOG.info("Starting master with port {}", mProperties.get(PropertyKey.MASTER_RPC_PORT));
mProcess = new ExternalProcess(mProperties, LimitedLifeMasterProcess.class,
new File(mLogsDir, "master.out"));
try {
mProcess.start();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
public synchronized void start() {
Preconditions.checkState(mProcess == null, "Master is already running");
LOG.info("Starting master with port {}", mProperties.get(PropertyKey.MASTER_RPC_PORT));
mProcess = new ExternalProcess(mProperties, LimitedLifeMasterProcess.class,
new File(mLogsDir, "master.out"));
try {
mProcess.start();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"synchronized",
"void",
"start",
"(",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"mProcess",
"==",
"null",
",",
"\"Master is already running\"",
")",
";",
"LOG",
".",
"info",
"(",
"\"Starting master with port {}\"",
",",
"mProperties",
".",
"get",
"(",
"PropertyKey",
".",
"MASTER_RPC_PORT",
")",
")",
";",
"mProcess",
"=",
"new",
"ExternalProcess",
"(",
"mProperties",
",",
"LimitedLifeMasterProcess",
".",
"class",
",",
"new",
"File",
"(",
"mLogsDir",
",",
"\"master.out\"",
")",
")",
";",
"try",
"{",
"mProcess",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Launches the master process.
|
[
"Launches",
"the",
"master",
"process",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/Master.java#L68-L78
|
18,359
|
Alluxio/alluxio
|
examples/src/main/java/alluxio/cli/MiniBenchmark.java
|
MiniBenchmark.usage
|
private static void usage() {
new HelpFormatter().printHelp(String.format(
"java -cp %s %s -type <[READ, WRITE]> -fileSize <fileSize> -iterations <iterations> "
+ "-concurrency <concurrency>",
RuntimeConstants.ALLUXIO_JAR, MiniBenchmark.class.getCanonicalName()),
"run a mini benchmark to write or read a file",
OPTIONS, "", true);
}
|
java
|
private static void usage() {
new HelpFormatter().printHelp(String.format(
"java -cp %s %s -type <[READ, WRITE]> -fileSize <fileSize> -iterations <iterations> "
+ "-concurrency <concurrency>",
RuntimeConstants.ALLUXIO_JAR, MiniBenchmark.class.getCanonicalName()),
"run a mini benchmark to write or read a file",
OPTIONS, "", true);
}
|
[
"private",
"static",
"void",
"usage",
"(",
")",
"{",
"new",
"HelpFormatter",
"(",
")",
".",
"printHelp",
"(",
"String",
".",
"format",
"(",
"\"java -cp %s %s -type <[READ, WRITE]> -fileSize <fileSize> -iterations <iterations> \"",
"+",
"\"-concurrency <concurrency>\"",
",",
"RuntimeConstants",
".",
"ALLUXIO_JAR",
",",
"MiniBenchmark",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
",",
"\"run a mini benchmark to write or read a file\"",
",",
"OPTIONS",
",",
"\"\"",
",",
"true",
")",
";",
"}"
] |
Prints the usage.
|
[
"Prints",
"the",
"usage",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/examples/src/main/java/alluxio/cli/MiniBenchmark.java#L72-L79
|
18,360
|
Alluxio/alluxio
|
examples/src/main/java/alluxio/cli/MiniBenchmark.java
|
MiniBenchmark.writeFile
|
private static void writeFile(CyclicBarrier barrier, AtomicLong runtime, int count,
AlluxioConfiguration alluxioConf)
throws Exception {
FileSystem fileSystem = FileSystem.Factory.create(alluxioConf);
byte[] buffer = new byte[(int) Math.min(sFileSize, 4 * Constants.MB)];
Arrays.fill(buffer, (byte) 'a');
AlluxioURI path = filename(count);
if (fileSystem.exists(path)) {
fileSystem.delete(path);
}
barrier.await();
long startTime = System.nanoTime();
long bytesWritten = 0;
try (FileOutStream outStream = fileSystem.createFile(path)) {
while (bytesWritten < sFileSize) {
outStream.write(buffer, 0, (int) Math.min(buffer.length, sFileSize - bytesWritten));
bytesWritten += buffer.length;
}
}
runtime.addAndGet(System.nanoTime() - startTime);
}
|
java
|
private static void writeFile(CyclicBarrier barrier, AtomicLong runtime, int count,
AlluxioConfiguration alluxioConf)
throws Exception {
FileSystem fileSystem = FileSystem.Factory.create(alluxioConf);
byte[] buffer = new byte[(int) Math.min(sFileSize, 4 * Constants.MB)];
Arrays.fill(buffer, (byte) 'a');
AlluxioURI path = filename(count);
if (fileSystem.exists(path)) {
fileSystem.delete(path);
}
barrier.await();
long startTime = System.nanoTime();
long bytesWritten = 0;
try (FileOutStream outStream = fileSystem.createFile(path)) {
while (bytesWritten < sFileSize) {
outStream.write(buffer, 0, (int) Math.min(buffer.length, sFileSize - bytesWritten));
bytesWritten += buffer.length;
}
}
runtime.addAndGet(System.nanoTime() - startTime);
}
|
[
"private",
"static",
"void",
"writeFile",
"(",
"CyclicBarrier",
"barrier",
",",
"AtomicLong",
"runtime",
",",
"int",
"count",
",",
"AlluxioConfiguration",
"alluxioConf",
")",
"throws",
"Exception",
"{",
"FileSystem",
"fileSystem",
"=",
"FileSystem",
".",
"Factory",
".",
"create",
"(",
"alluxioConf",
")",
";",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"(",
"int",
")",
"Math",
".",
"min",
"(",
"sFileSize",
",",
"4",
"*",
"Constants",
".",
"MB",
")",
"]",
";",
"Arrays",
".",
"fill",
"(",
"buffer",
",",
"(",
"byte",
")",
"'",
"'",
")",
";",
"AlluxioURI",
"path",
"=",
"filename",
"(",
"count",
")",
";",
"if",
"(",
"fileSystem",
".",
"exists",
"(",
"path",
")",
")",
"{",
"fileSystem",
".",
"delete",
"(",
"path",
")",
";",
"}",
"barrier",
".",
"await",
"(",
")",
";",
"long",
"startTime",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"long",
"bytesWritten",
"=",
"0",
";",
"try",
"(",
"FileOutStream",
"outStream",
"=",
"fileSystem",
".",
"createFile",
"(",
"path",
")",
")",
"{",
"while",
"(",
"bytesWritten",
"<",
"sFileSize",
")",
"{",
"outStream",
".",
"write",
"(",
"buffer",
",",
"0",
",",
"(",
"int",
")",
"Math",
".",
"min",
"(",
"buffer",
".",
"length",
",",
"sFileSize",
"-",
"bytesWritten",
")",
")",
";",
"bytesWritten",
"+=",
"buffer",
".",
"length",
";",
"}",
"}",
"runtime",
".",
"addAndGet",
"(",
"System",
".",
"nanoTime",
"(",
")",
"-",
"startTime",
")",
";",
"}"
] |
Writes a file.
@param count the count to determine the filename
@throws Exception if it fails to write
|
[
"Writes",
"a",
"file",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/examples/src/main/java/alluxio/cli/MiniBenchmark.java#L203-L225
|
18,361
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/block/meta/MasterBlockInfo.java
|
MasterBlockInfo.updateLength
|
public synchronized void updateLength(long length) {
if (mLength == Constants.UNKNOWN_SIZE) {
mLength = length;
} else if (mLength != length) {
LOG.warn("Attempting to update block length ({}) to a different length ({}).", mLength,
length);
}
}
|
java
|
public synchronized void updateLength(long length) {
if (mLength == Constants.UNKNOWN_SIZE) {
mLength = length;
} else if (mLength != length) {
LOG.warn("Attempting to update block length ({}) to a different length ({}).", mLength,
length);
}
}
|
[
"public",
"synchronized",
"void",
"updateLength",
"(",
"long",
"length",
")",
"{",
"if",
"(",
"mLength",
"==",
"Constants",
".",
"UNKNOWN_SIZE",
")",
"{",
"mLength",
"=",
"length",
";",
"}",
"else",
"if",
"(",
"mLength",
"!=",
"length",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Attempting to update block length ({}) to a different length ({}).\"",
",",
"mLength",
",",
"length",
")",
";",
"}",
"}"
] |
Updates the length, if and only if the length was previously unknown.
@param length the updated length
|
[
"Updates",
"the",
"length",
"if",
"and",
"only",
"if",
"the",
"length",
"was",
"previously",
"unknown",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/block/meta/MasterBlockInfo.java#L75-L82
|
18,362
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/block/meta/MasterBlockInfo.java
|
MasterBlockInfo.getBlockLocations
|
public List<MasterBlockLocation> getBlockLocations() {
List<MasterBlockLocation> ret = new ArrayList<>(mWorkerIdToAlias.size());
for (Map.Entry<Long, String> entry : mWorkerIdToAlias.entrySet()) {
ret.add(new MasterBlockLocation(entry.getKey(), entry.getValue()));
}
return ret;
}
|
java
|
public List<MasterBlockLocation> getBlockLocations() {
List<MasterBlockLocation> ret = new ArrayList<>(mWorkerIdToAlias.size());
for (Map.Entry<Long, String> entry : mWorkerIdToAlias.entrySet()) {
ret.add(new MasterBlockLocation(entry.getKey(), entry.getValue()));
}
return ret;
}
|
[
"public",
"List",
"<",
"MasterBlockLocation",
">",
"getBlockLocations",
"(",
")",
"{",
"List",
"<",
"MasterBlockLocation",
">",
"ret",
"=",
"new",
"ArrayList",
"<>",
"(",
"mWorkerIdToAlias",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Long",
",",
"String",
">",
"entry",
":",
"mWorkerIdToAlias",
".",
"entrySet",
"(",
")",
")",
"{",
"ret",
".",
"add",
"(",
"new",
"MasterBlockLocation",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Gets the net addresses for all workers which have the block's data in their tiered storage.
@return the net addresses of the workers
|
[
"Gets",
"the",
"net",
"addresses",
"for",
"all",
"workers",
"which",
"have",
"the",
"block",
"s",
"data",
"in",
"their",
"tiered",
"storage",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/block/meta/MasterBlockInfo.java#L129-L135
|
18,363
|
Alluxio/alluxio
|
underfs/kodo/src/main/java/alluxio/underfs/kodo/KodoOutputStream.java
|
KodoOutputStream.close
|
@Override
public void close() {
if (mClosed.getAndSet(true)) {
return;
}
try {
mLocalOutputStream.close();
mKodoClient.uploadFile(mKey, mFile);
} catch (Exception e) {
e.printStackTrace();
}
mFile.delete();
}
|
java
|
@Override
public void close() {
if (mClosed.getAndSet(true)) {
return;
}
try {
mLocalOutputStream.close();
mKodoClient.uploadFile(mKey, mFile);
} catch (Exception e) {
e.printStackTrace();
}
mFile.delete();
}
|
[
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"mClosed",
".",
"getAndSet",
"(",
"true",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"mLocalOutputStream",
".",
"close",
"(",
")",
";",
"mKodoClient",
".",
"uploadFile",
"(",
"mKey",
",",
"mFile",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"mFile",
".",
"delete",
"(",
")",
";",
"}"
] |
Closes this output stream. When an output stream is closed, the local temporary file is
uploaded to KODO Service. Once the file is uploaded, the temporary file is deleted.
|
[
"Closes",
"this",
"output",
"stream",
".",
"When",
"an",
"output",
"stream",
"is",
"closed",
"the",
"local",
"temporary",
"file",
"is",
"uploaded",
"to",
"KODO",
"Service",
".",
"Once",
"the",
"file",
"is",
"uploaded",
"the",
"temporary",
"file",
"is",
"deleted",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/kodo/src/main/java/alluxio/underfs/kodo/KodoOutputStream.java#L107-L119
|
18,364
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/proxy/AlluxioProxyMonitor.java
|
AlluxioProxyMonitor.main
|
public static void main(String[] args) {
if (args.length != 0) {
LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR,
AlluxioProxyMonitor.class.getCanonicalName());
LOG.warn("ignoring arguments");
}
HealthCheckClient client = new ProxyHealthCheckClient(
NetworkAddressUtils.getBindAddress(NetworkAddressUtils.ServiceType.PROXY_WEB,
new InstancedConfiguration(ConfigurationUtils.defaults())),
() -> new ExponentialBackoffRetry(50, 100, 2));
if (!client.isServing()) {
System.exit(1);
}
System.exit(0);
}
|
java
|
public static void main(String[] args) {
if (args.length != 0) {
LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR,
AlluxioProxyMonitor.class.getCanonicalName());
LOG.warn("ignoring arguments");
}
HealthCheckClient client = new ProxyHealthCheckClient(
NetworkAddressUtils.getBindAddress(NetworkAddressUtils.ServiceType.PROXY_WEB,
new InstancedConfiguration(ConfigurationUtils.defaults())),
() -> new ExponentialBackoffRetry(50, 100, 2));
if (!client.isServing()) {
System.exit(1);
}
System.exit(0);
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"if",
"(",
"args",
".",
"length",
"!=",
"0",
")",
"{",
"LOG",
".",
"info",
"(",
"\"java -cp {} {}\"",
",",
"RuntimeConstants",
".",
"ALLUXIO_JAR",
",",
"AlluxioProxyMonitor",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
";",
"LOG",
".",
"warn",
"(",
"\"ignoring arguments\"",
")",
";",
"}",
"HealthCheckClient",
"client",
"=",
"new",
"ProxyHealthCheckClient",
"(",
"NetworkAddressUtils",
".",
"getBindAddress",
"(",
"NetworkAddressUtils",
".",
"ServiceType",
".",
"PROXY_WEB",
",",
"new",
"InstancedConfiguration",
"(",
"ConfigurationUtils",
".",
"defaults",
"(",
")",
")",
")",
",",
"(",
")",
"->",
"new",
"ExponentialBackoffRetry",
"(",
"50",
",",
"100",
",",
"2",
")",
")",
";",
"if",
"(",
"!",
"client",
".",
"isServing",
"(",
")",
")",
"{",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}"
] |
Starts the Alluxio proxy monitor.
@param args command line arguments, should be empty
|
[
"Starts",
"the",
"Alluxio",
"proxy",
"monitor",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/proxy/AlluxioProxyMonitor.java#L35-L50
|
18,365
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/command/DuCommand.java
|
DuCommand.getSizeInfo
|
private void getSizeInfo(AlluxioURI path, List<URIStatus> statuses,
boolean readable, boolean summarize, boolean addMemory) {
if (summarize) {
long totalSize = 0;
long sizeInAlluxio = 0;
long sizeInMem = 0;
for (URIStatus status : statuses) {
if (!status.isFolder()) {
long size = status.getLength();
totalSize += size;
sizeInMem += size * status.getInMemoryPercentage();
sizeInAlluxio += size * status.getInMemoryPercentage();
}
}
String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize)
: String.valueOf(totalSize);
String inAlluxioMessage = getFormattedValues(readable, sizeInAlluxio / 100, totalSize);
String inMemMessage = addMemory
? getFormattedValues(readable, sizeInMem / 100, totalSize) : "";
printInfo(sizeMessage, inAlluxioMessage, inMemMessage, path.toString());
} else {
for (URIStatus status : statuses) {
if (!status.isFolder()) {
long totalSize = status.getLength();
String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize)
: String.valueOf(totalSize);
String inAlluxioMessage = getFormattedValues(readable,
status.getInAlluxioPercentage() * totalSize / 100, totalSize);
String inMemMessage = addMemory ? getFormattedValues(readable,
status.getInMemoryPercentage() * totalSize / 100, totalSize) : "";
printInfo(sizeMessage, inAlluxioMessage, inMemMessage, status.getPath());
}
}
}
}
|
java
|
private void getSizeInfo(AlluxioURI path, List<URIStatus> statuses,
boolean readable, boolean summarize, boolean addMemory) {
if (summarize) {
long totalSize = 0;
long sizeInAlluxio = 0;
long sizeInMem = 0;
for (URIStatus status : statuses) {
if (!status.isFolder()) {
long size = status.getLength();
totalSize += size;
sizeInMem += size * status.getInMemoryPercentage();
sizeInAlluxio += size * status.getInMemoryPercentage();
}
}
String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize)
: String.valueOf(totalSize);
String inAlluxioMessage = getFormattedValues(readable, sizeInAlluxio / 100, totalSize);
String inMemMessage = addMemory
? getFormattedValues(readable, sizeInMem / 100, totalSize) : "";
printInfo(sizeMessage, inAlluxioMessage, inMemMessage, path.toString());
} else {
for (URIStatus status : statuses) {
if (!status.isFolder()) {
long totalSize = status.getLength();
String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize)
: String.valueOf(totalSize);
String inAlluxioMessage = getFormattedValues(readable,
status.getInAlluxioPercentage() * totalSize / 100, totalSize);
String inMemMessage = addMemory ? getFormattedValues(readable,
status.getInMemoryPercentage() * totalSize / 100, totalSize) : "";
printInfo(sizeMessage, inAlluxioMessage, inMemMessage, status.getPath());
}
}
}
}
|
[
"private",
"void",
"getSizeInfo",
"(",
"AlluxioURI",
"path",
",",
"List",
"<",
"URIStatus",
">",
"statuses",
",",
"boolean",
"readable",
",",
"boolean",
"summarize",
",",
"boolean",
"addMemory",
")",
"{",
"if",
"(",
"summarize",
")",
"{",
"long",
"totalSize",
"=",
"0",
";",
"long",
"sizeInAlluxio",
"=",
"0",
";",
"long",
"sizeInMem",
"=",
"0",
";",
"for",
"(",
"URIStatus",
"status",
":",
"statuses",
")",
"{",
"if",
"(",
"!",
"status",
".",
"isFolder",
"(",
")",
")",
"{",
"long",
"size",
"=",
"status",
".",
"getLength",
"(",
")",
";",
"totalSize",
"+=",
"size",
";",
"sizeInMem",
"+=",
"size",
"*",
"status",
".",
"getInMemoryPercentage",
"(",
")",
";",
"sizeInAlluxio",
"+=",
"size",
"*",
"status",
".",
"getInMemoryPercentage",
"(",
")",
";",
"}",
"}",
"String",
"sizeMessage",
"=",
"readable",
"?",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"totalSize",
")",
":",
"String",
".",
"valueOf",
"(",
"totalSize",
")",
";",
"String",
"inAlluxioMessage",
"=",
"getFormattedValues",
"(",
"readable",
",",
"sizeInAlluxio",
"/",
"100",
",",
"totalSize",
")",
";",
"String",
"inMemMessage",
"=",
"addMemory",
"?",
"getFormattedValues",
"(",
"readable",
",",
"sizeInMem",
"/",
"100",
",",
"totalSize",
")",
":",
"\"\"",
";",
"printInfo",
"(",
"sizeMessage",
",",
"inAlluxioMessage",
",",
"inMemMessage",
",",
"path",
".",
"toString",
"(",
")",
")",
";",
"}",
"else",
"{",
"for",
"(",
"URIStatus",
"status",
":",
"statuses",
")",
"{",
"if",
"(",
"!",
"status",
".",
"isFolder",
"(",
")",
")",
"{",
"long",
"totalSize",
"=",
"status",
".",
"getLength",
"(",
")",
";",
"String",
"sizeMessage",
"=",
"readable",
"?",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"totalSize",
")",
":",
"String",
".",
"valueOf",
"(",
"totalSize",
")",
";",
"String",
"inAlluxioMessage",
"=",
"getFormattedValues",
"(",
"readable",
",",
"status",
".",
"getInAlluxioPercentage",
"(",
")",
"*",
"totalSize",
"/",
"100",
",",
"totalSize",
")",
";",
"String",
"inMemMessage",
"=",
"addMemory",
"?",
"getFormattedValues",
"(",
"readable",
",",
"status",
".",
"getInMemoryPercentage",
"(",
")",
"*",
"totalSize",
"/",
"100",
",",
"totalSize",
")",
":",
"\"\"",
";",
"printInfo",
"(",
"sizeMessage",
",",
"inAlluxioMessage",
",",
"inMemMessage",
",",
"status",
".",
"getPath",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Gets and prints the size information of the input path according to options.
@param path the path to get size info of
@param statuses the statuses of files and folders
@param readable whether to print info of human readable format
@param summarize whether to display the aggregate summary lengths
@param addMemory whether to display the memory size and percentage information
|
[
"Gets",
"and",
"prints",
"the",
"size",
"information",
"of",
"the",
"input",
"path",
"according",
"to",
"options",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/command/DuCommand.java#L111-L145
|
18,366
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/command/DuCommand.java
|
DuCommand.getFormattedValues
|
private String getFormattedValues(boolean readable, long size, long totalSize) {
// If size is 1, total size is 5, and readable is true, it will
// return a string as "1B (20%)"
int percent = totalSize == 0 ? 0 : (int) (size * 100 / totalSize);
String subSizeMessage = readable ? FormatUtils.getSizeFromBytes(size)
: String.valueOf(size);
return String.format(VALUE_AND_PERCENT_FORMAT, subSizeMessage, percent);
}
|
java
|
private String getFormattedValues(boolean readable, long size, long totalSize) {
// If size is 1, total size is 5, and readable is true, it will
// return a string as "1B (20%)"
int percent = totalSize == 0 ? 0 : (int) (size * 100 / totalSize);
String subSizeMessage = readable ? FormatUtils.getSizeFromBytes(size)
: String.valueOf(size);
return String.format(VALUE_AND_PERCENT_FORMAT, subSizeMessage, percent);
}
|
[
"private",
"String",
"getFormattedValues",
"(",
"boolean",
"readable",
",",
"long",
"size",
",",
"long",
"totalSize",
")",
"{",
"// If size is 1, total size is 5, and readable is true, it will",
"// return a string as \"1B (20%)\"",
"int",
"percent",
"=",
"totalSize",
"==",
"0",
"?",
"0",
":",
"(",
"int",
")",
"(",
"size",
"*",
"100",
"/",
"totalSize",
")",
";",
"String",
"subSizeMessage",
"=",
"readable",
"?",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"size",
")",
":",
"String",
".",
"valueOf",
"(",
"size",
")",
";",
"return",
"String",
".",
"format",
"(",
"VALUE_AND_PERCENT_FORMAT",
",",
"subSizeMessage",
",",
"percent",
")",
";",
"}"
] |
Gets the size and its percentage information, if readable option is provided,
get the size in human readable format.
@param readable whether to print info of human readable format
@param size the size to get information from
@param totalSize the total size to calculate percentage information
@return the formatted value and percentage information
|
[
"Gets",
"the",
"size",
"and",
"its",
"percentage",
"information",
"if",
"readable",
"option",
"is",
"provided",
"get",
"the",
"size",
"in",
"human",
"readable",
"format",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/command/DuCommand.java#L156-L163
|
18,367
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/command/DuCommand.java
|
DuCommand.printInfo
|
private void printInfo(String sizeMessage,
String inAlluxioMessage, String inMemMessage, String path) {
System.out.println(inMemMessage.isEmpty()
? String.format(SHORT_INFO_FORMAT, sizeMessage, inAlluxioMessage, path)
: String.format(LONG_INFO_FORMAT, sizeMessage, inAlluxioMessage, inMemMessage, path));
}
|
java
|
private void printInfo(String sizeMessage,
String inAlluxioMessage, String inMemMessage, String path) {
System.out.println(inMemMessage.isEmpty()
? String.format(SHORT_INFO_FORMAT, sizeMessage, inAlluxioMessage, path)
: String.format(LONG_INFO_FORMAT, sizeMessage, inAlluxioMessage, inMemMessage, path));
}
|
[
"private",
"void",
"printInfo",
"(",
"String",
"sizeMessage",
",",
"String",
"inAlluxioMessage",
",",
"String",
"inMemMessage",
",",
"String",
"path",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"inMemMessage",
".",
"isEmpty",
"(",
")",
"?",
"String",
".",
"format",
"(",
"SHORT_INFO_FORMAT",
",",
"sizeMessage",
",",
"inAlluxioMessage",
",",
"path",
")",
":",
"String",
".",
"format",
"(",
"LONG_INFO_FORMAT",
",",
"sizeMessage",
",",
"inAlluxioMessage",
",",
"inMemMessage",
",",
"path",
")",
")",
";",
"}"
] |
Prints the size messages.
@param sizeMessage the total size message to print
@param inAlluxioMessage the in Alluxio size message to print
@param inMemMessage the in memory size message to print
@param path the path to print
|
[
"Prints",
"the",
"size",
"messages",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/command/DuCommand.java#L173-L178
|
18,368
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/LogUtils.java
|
LogUtils.setLogLevel
|
public static LogInfo setLogLevel(String logName, String level) throws IOException {
LogInfo result = new LogInfo();
if (StringUtils.isNotBlank(logName)) {
result.setLogName(logName);
Log log = LogFactory.getLog(logName);
Logger logger = LoggerFactory.getLogger(logName);
if (log instanceof Log4JLogger) {
process(((Log4JLogger) log).getLogger(), level, result);
} else if (log instanceof Jdk14Logger) {
process(((Jdk14Logger) log).getLogger(), level, result);
} else if (logger instanceof Log4jLoggerAdapter) {
try {
Field field = Log4jLoggerAdapter.class.getDeclaredField("logger");
field.setAccessible(true);
org.apache.log4j.Logger log4jLogger = (org.apache.log4j.Logger) field.get(logger);
process(log4jLogger, level, result);
} catch (NoSuchFieldException | IllegalAccessException e) {
result.setMessage(e.getMessage());
}
} else {
result.setMessage("Sorry, " + log.getClass() + " not supported.");
}
} else {
result.setMessage("Please specify a correct logName.");
}
return result;
}
|
java
|
public static LogInfo setLogLevel(String logName, String level) throws IOException {
LogInfo result = new LogInfo();
if (StringUtils.isNotBlank(logName)) {
result.setLogName(logName);
Log log = LogFactory.getLog(logName);
Logger logger = LoggerFactory.getLogger(logName);
if (log instanceof Log4JLogger) {
process(((Log4JLogger) log).getLogger(), level, result);
} else if (log instanceof Jdk14Logger) {
process(((Jdk14Logger) log).getLogger(), level, result);
} else if (logger instanceof Log4jLoggerAdapter) {
try {
Field field = Log4jLoggerAdapter.class.getDeclaredField("logger");
field.setAccessible(true);
org.apache.log4j.Logger log4jLogger = (org.apache.log4j.Logger) field.get(logger);
process(log4jLogger, level, result);
} catch (NoSuchFieldException | IllegalAccessException e) {
result.setMessage(e.getMessage());
}
} else {
result.setMessage("Sorry, " + log.getClass() + " not supported.");
}
} else {
result.setMessage("Please specify a correct logName.");
}
return result;
}
|
[
"public",
"static",
"LogInfo",
"setLogLevel",
"(",
"String",
"logName",
",",
"String",
"level",
")",
"throws",
"IOException",
"{",
"LogInfo",
"result",
"=",
"new",
"LogInfo",
"(",
")",
";",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"logName",
")",
")",
"{",
"result",
".",
"setLogName",
"(",
"logName",
")",
";",
"Log",
"log",
"=",
"LogFactory",
".",
"getLog",
"(",
"logName",
")",
";",
"Logger",
"logger",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"logName",
")",
";",
"if",
"(",
"log",
"instanceof",
"Log4JLogger",
")",
"{",
"process",
"(",
"(",
"(",
"Log4JLogger",
")",
"log",
")",
".",
"getLogger",
"(",
")",
",",
"level",
",",
"result",
")",
";",
"}",
"else",
"if",
"(",
"log",
"instanceof",
"Jdk14Logger",
")",
"{",
"process",
"(",
"(",
"(",
"Jdk14Logger",
")",
"log",
")",
".",
"getLogger",
"(",
")",
",",
"level",
",",
"result",
")",
";",
"}",
"else",
"if",
"(",
"logger",
"instanceof",
"Log4jLoggerAdapter",
")",
"{",
"try",
"{",
"Field",
"field",
"=",
"Log4jLoggerAdapter",
".",
"class",
".",
"getDeclaredField",
"(",
"\"logger\"",
")",
";",
"field",
".",
"setAccessible",
"(",
"true",
")",
";",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
"log4jLogger",
"=",
"(",
"org",
".",
"apache",
".",
"log4j",
".",
"Logger",
")",
"field",
".",
"get",
"(",
"logger",
")",
";",
"process",
"(",
"log4jLogger",
",",
"level",
",",
"result",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"|",
"IllegalAccessException",
"e",
")",
"{",
"result",
".",
"setMessage",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"result",
".",
"setMessage",
"(",
"\"Sorry, \"",
"+",
"log",
".",
"getClass",
"(",
")",
"+",
"\" not supported.\"",
")",
";",
"}",
"}",
"else",
"{",
"result",
".",
"setMessage",
"(",
"\"Please specify a correct logName.\"",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Gets a logger's level with specify name, if the level argument is not null, it will set to
specify level first.
@param logName logger's name
@param level logger's level
@return an entity object about the log info
@throws IOException if an I/O error occurs
|
[
"Gets",
"a",
"logger",
"s",
"level",
"with",
"specify",
"name",
"if",
"the",
"level",
"argument",
"is",
"not",
"null",
"it",
"will",
"set",
"to",
"specify",
"level",
"first",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/LogUtils.java#L47-L73
|
18,369
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/LogUtils.java
|
LogUtils.warnWithException
|
public static void warnWithException(Logger logger, String message, Object ...args) {
if (logger.isDebugEnabled()) {
logger.debug(message, args);
} else {
if (args.length > 0 && args[args.length - 1] instanceof Throwable) {
args[args.length - 1] = ((Throwable) args[args.length - 1]).getMessage();
}
logger.warn(message + ": {}", args);
}
}
|
java
|
public static void warnWithException(Logger logger, String message, Object ...args) {
if (logger.isDebugEnabled()) {
logger.debug(message, args);
} else {
if (args.length > 0 && args[args.length - 1] instanceof Throwable) {
args[args.length - 1] = ((Throwable) args[args.length - 1]).getMessage();
}
logger.warn(message + ": {}", args);
}
}
|
[
"public",
"static",
"void",
"warnWithException",
"(",
"Logger",
"logger",
",",
"String",
"message",
",",
"Object",
"...",
"args",
")",
"{",
"if",
"(",
"logger",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"message",
",",
"args",
")",
";",
"}",
"else",
"{",
"if",
"(",
"args",
".",
"length",
">",
"0",
"&&",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"instanceof",
"Throwable",
")",
"{",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
"=",
"(",
"(",
"Throwable",
")",
"args",
"[",
"args",
".",
"length",
"-",
"1",
"]",
")",
".",
"getMessage",
"(",
")",
";",
"}",
"logger",
".",
"warn",
"(",
"message",
"+",
"\": {}\"",
",",
"args",
")",
";",
"}",
"}"
] |
Log a warning message with full exception if debug logging is enabled,
or just the message otherwise.
@param logger the logger to be used
@param message the message to be logged
@param args the arguments for the message
|
[
"Log",
"a",
"warning",
"message",
"with",
"full",
"exception",
"if",
"debug",
"logging",
"is",
"enabled",
"or",
"just",
"the",
"message",
"otherwise",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/LogUtils.java#L125-L134
|
18,370
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/security/LoginUser.java
|
LoginUser.get
|
public static User get(AlluxioConfiguration conf) throws UnauthenticatedException {
if (sLoginUser == null) {
synchronized (LoginUser.class) {
if (sLoginUser == null) {
sLoginUser = login(conf);
}
}
}
return sLoginUser;
}
|
java
|
public static User get(AlluxioConfiguration conf) throws UnauthenticatedException {
if (sLoginUser == null) {
synchronized (LoginUser.class) {
if (sLoginUser == null) {
sLoginUser = login(conf);
}
}
}
return sLoginUser;
}
|
[
"public",
"static",
"User",
"get",
"(",
"AlluxioConfiguration",
"conf",
")",
"throws",
"UnauthenticatedException",
"{",
"if",
"(",
"sLoginUser",
"==",
"null",
")",
"{",
"synchronized",
"(",
"LoginUser",
".",
"class",
")",
"{",
"if",
"(",
"sLoginUser",
"==",
"null",
")",
"{",
"sLoginUser",
"=",
"login",
"(",
"conf",
")",
";",
"}",
"}",
"}",
"return",
"sLoginUser",
";",
"}"
] |
Gets current singleton login user. This method is called to identify the singleton user who
runs Alluxio client. When Alluxio client gets a user by this method and connects to Alluxio
service, this user represents the client and is maintained in service.
Note that until if the authentication type or login user changes between the first
invocation of this method that it is possible the cached user won't respect the updated
configuration properties.
@param conf Alluxio's current configuration
@return the login user
|
[
"Gets",
"current",
"singleton",
"login",
"user",
".",
"This",
"method",
"is",
"called",
"to",
"identify",
"the",
"singleton",
"user",
"who",
"runs",
"Alluxio",
"client",
".",
"When",
"Alluxio",
"client",
"gets",
"a",
"user",
"by",
"this",
"method",
"and",
"connects",
"to",
"Alluxio",
"service",
"this",
"user",
"represents",
"the",
"client",
"and",
"is",
"maintained",
"in",
"service",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/security/LoginUser.java#L61-L70
|
18,371
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/security/LoginUser.java
|
LoginUser.login
|
private static User login(AlluxioConfiguration conf) throws UnauthenticatedException {
AuthType authType = conf.getEnum(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.class);
checkSecurityEnabled(authType);
Subject subject = new Subject();
try {
// Use the class loader of User.class to construct the LoginContext. LoginContext uses this
// class loader to dynamically instantiate login modules. This enables
// Subject#getPrincipals to use reflection to search for User.class instances.
LoginContext loginContext = createLoginContext(authType, subject, User.class.getClassLoader(),
new LoginModuleConfiguration(), conf);
loginContext.login();
} catch (LoginException e) {
throw new UnauthenticatedException("Failed to login: " + e.getMessage(), e);
}
LOG.debug("login subject: {}", subject);
Set<User> userSet = subject.getPrincipals(User.class);
if (userSet.isEmpty()) {
throw new UnauthenticatedException("Failed to login: No Alluxio User is found.");
}
if (userSet.size() > 1) {
StringBuilder msg = new StringBuilder(
"Failed to login: More than one Alluxio Users are found:");
for (User user : userSet) {
msg.append(" ").append(user.toString());
}
throw new UnauthenticatedException(msg.toString());
}
return userSet.iterator().next();
}
|
java
|
private static User login(AlluxioConfiguration conf) throws UnauthenticatedException {
AuthType authType = conf.getEnum(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.class);
checkSecurityEnabled(authType);
Subject subject = new Subject();
try {
// Use the class loader of User.class to construct the LoginContext. LoginContext uses this
// class loader to dynamically instantiate login modules. This enables
// Subject#getPrincipals to use reflection to search for User.class instances.
LoginContext loginContext = createLoginContext(authType, subject, User.class.getClassLoader(),
new LoginModuleConfiguration(), conf);
loginContext.login();
} catch (LoginException e) {
throw new UnauthenticatedException("Failed to login: " + e.getMessage(), e);
}
LOG.debug("login subject: {}", subject);
Set<User> userSet = subject.getPrincipals(User.class);
if (userSet.isEmpty()) {
throw new UnauthenticatedException("Failed to login: No Alluxio User is found.");
}
if (userSet.size() > 1) {
StringBuilder msg = new StringBuilder(
"Failed to login: More than one Alluxio Users are found:");
for (User user : userSet) {
msg.append(" ").append(user.toString());
}
throw new UnauthenticatedException(msg.toString());
}
return userSet.iterator().next();
}
|
[
"private",
"static",
"User",
"login",
"(",
"AlluxioConfiguration",
"conf",
")",
"throws",
"UnauthenticatedException",
"{",
"AuthType",
"authType",
"=",
"conf",
".",
"getEnum",
"(",
"PropertyKey",
".",
"SECURITY_AUTHENTICATION_TYPE",
",",
"AuthType",
".",
"class",
")",
";",
"checkSecurityEnabled",
"(",
"authType",
")",
";",
"Subject",
"subject",
"=",
"new",
"Subject",
"(",
")",
";",
"try",
"{",
"// Use the class loader of User.class to construct the LoginContext. LoginContext uses this",
"// class loader to dynamically instantiate login modules. This enables",
"// Subject#getPrincipals to use reflection to search for User.class instances.",
"LoginContext",
"loginContext",
"=",
"createLoginContext",
"(",
"authType",
",",
"subject",
",",
"User",
".",
"class",
".",
"getClassLoader",
"(",
")",
",",
"new",
"LoginModuleConfiguration",
"(",
")",
",",
"conf",
")",
";",
"loginContext",
".",
"login",
"(",
")",
";",
"}",
"catch",
"(",
"LoginException",
"e",
")",
"{",
"throw",
"new",
"UnauthenticatedException",
"(",
"\"Failed to login: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"LOG",
".",
"debug",
"(",
"\"login subject: {}\"",
",",
"subject",
")",
";",
"Set",
"<",
"User",
">",
"userSet",
"=",
"subject",
".",
"getPrincipals",
"(",
"User",
".",
"class",
")",
";",
"if",
"(",
"userSet",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"UnauthenticatedException",
"(",
"\"Failed to login: No Alluxio User is found.\"",
")",
";",
"}",
"if",
"(",
"userSet",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"StringBuilder",
"msg",
"=",
"new",
"StringBuilder",
"(",
"\"Failed to login: More than one Alluxio Users are found:\"",
")",
";",
"for",
"(",
"User",
"user",
":",
"userSet",
")",
"{",
"msg",
".",
"append",
"(",
"\" \"",
")",
".",
"append",
"(",
"user",
".",
"toString",
"(",
")",
")",
";",
"}",
"throw",
"new",
"UnauthenticatedException",
"(",
"msg",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"userSet",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"}"
] |
Logs in based on the LoginModules.
@return the login user
|
[
"Logs",
"in",
"based",
"on",
"the",
"LoginModules",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/security/LoginUser.java#L77-L107
|
18,372
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/PrimarySelectorClient.java
|
PrimarySelectorClient.start
|
@Override
public void start(InetSocketAddress address) throws IOException {
mName = address.getHostName() + ":" + address.getPort();
mLeaderSelector.setId(mName);
mLeaderSelector.start();
}
|
java
|
@Override
public void start(InetSocketAddress address) throws IOException {
mName = address.getHostName() + ":" + address.getPort();
mLeaderSelector.setId(mName);
mLeaderSelector.start();
}
|
[
"@",
"Override",
"public",
"void",
"start",
"(",
"InetSocketAddress",
"address",
")",
"throws",
"IOException",
"{",
"mName",
"=",
"address",
".",
"getHostName",
"(",
")",
"+",
"\":\"",
"+",
"address",
".",
"getPort",
"(",
")",
";",
"mLeaderSelector",
".",
"setId",
"(",
"mName",
")",
";",
"mLeaderSelector",
".",
"start",
"(",
")",
";",
"}"
] |
Starts the leader selection. If the leader selector client loses connection to Zookeeper or
gets closed, the calling thread will be interrupted.
|
[
"Starts",
"the",
"leader",
"selection",
".",
"If",
"the",
"leader",
"selector",
"client",
"loses",
"connection",
"to",
"Zookeeper",
"or",
"gets",
"closed",
"the",
"calling",
"thread",
"will",
"be",
"interrupted",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/PrimarySelectorClient.java#L126-L131
|
18,373
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/PrimarySelectorClient.java
|
PrimarySelectorClient.getNewCuratorClient
|
private CuratorFramework getNewCuratorClient() {
CuratorFramework client = CuratorFrameworkFactory.newClient(mZookeeperAddress,
(int) ServerConfiguration.getMs(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT),
(int) ServerConfiguration.getMs(PropertyKey.ZOOKEEPER_CONNECTION_TIMEOUT),
new ExponentialBackoffRetry(Constants.SECOND_MS, 3));
client.start();
// Sometimes, if the master crashes and restarts too quickly (faster than the zookeeper
// timeout), zookeeper thinks the new client is still an old one. In order to ensure a clean
// state, explicitly close the "old" client and recreate a new one.
client.close();
client = CuratorFrameworkFactory.newClient(mZookeeperAddress,
(int) ServerConfiguration.getMs(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT),
(int) ServerConfiguration.getMs(PropertyKey.ZOOKEEPER_CONNECTION_TIMEOUT),
new ExponentialBackoffRetry(Constants.SECOND_MS, 3));
client.start();
return client;
}
|
java
|
private CuratorFramework getNewCuratorClient() {
CuratorFramework client = CuratorFrameworkFactory.newClient(mZookeeperAddress,
(int) ServerConfiguration.getMs(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT),
(int) ServerConfiguration.getMs(PropertyKey.ZOOKEEPER_CONNECTION_TIMEOUT),
new ExponentialBackoffRetry(Constants.SECOND_MS, 3));
client.start();
// Sometimes, if the master crashes and restarts too quickly (faster than the zookeeper
// timeout), zookeeper thinks the new client is still an old one. In order to ensure a clean
// state, explicitly close the "old" client and recreate a new one.
client.close();
client = CuratorFrameworkFactory.newClient(mZookeeperAddress,
(int) ServerConfiguration.getMs(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT),
(int) ServerConfiguration.getMs(PropertyKey.ZOOKEEPER_CONNECTION_TIMEOUT),
new ExponentialBackoffRetry(Constants.SECOND_MS, 3));
client.start();
return client;
}
|
[
"private",
"CuratorFramework",
"getNewCuratorClient",
"(",
")",
"{",
"CuratorFramework",
"client",
"=",
"CuratorFrameworkFactory",
".",
"newClient",
"(",
"mZookeeperAddress",
",",
"(",
"int",
")",
"ServerConfiguration",
".",
"getMs",
"(",
"PropertyKey",
".",
"ZOOKEEPER_SESSION_TIMEOUT",
")",
",",
"(",
"int",
")",
"ServerConfiguration",
".",
"getMs",
"(",
"PropertyKey",
".",
"ZOOKEEPER_CONNECTION_TIMEOUT",
")",
",",
"new",
"ExponentialBackoffRetry",
"(",
"Constants",
".",
"SECOND_MS",
",",
"3",
")",
")",
";",
"client",
".",
"start",
"(",
")",
";",
"// Sometimes, if the master crashes and restarts too quickly (faster than the zookeeper",
"// timeout), zookeeper thinks the new client is still an old one. In order to ensure a clean",
"// state, explicitly close the \"old\" client and recreate a new one.",
"client",
".",
"close",
"(",
")",
";",
"client",
"=",
"CuratorFrameworkFactory",
".",
"newClient",
"(",
"mZookeeperAddress",
",",
"(",
"int",
")",
"ServerConfiguration",
".",
"getMs",
"(",
"PropertyKey",
".",
"ZOOKEEPER_SESSION_TIMEOUT",
")",
",",
"(",
"int",
")",
"ServerConfiguration",
".",
"getMs",
"(",
"PropertyKey",
".",
"ZOOKEEPER_CONNECTION_TIMEOUT",
")",
",",
"new",
"ExponentialBackoffRetry",
"(",
"Constants",
".",
"SECOND_MS",
",",
"3",
")",
")",
";",
"client",
".",
"start",
"(",
")",
";",
"return",
"client",
";",
"}"
] |
Returns a new client for the zookeeper connection. The client is already started before
returning.
@return a new {@link CuratorFramework} client to use for leader selection
|
[
"Returns",
"a",
"new",
"client",
"for",
"the",
"zookeeper",
"connection",
".",
"The",
"client",
"is",
"already",
"started",
"before",
"returning",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/PrimarySelectorClient.java#L176-L193
|
18,374
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/metrics/MetricsConfig.java
|
MetricsConfig.subProperties
|
public static Map<String, Properties> subProperties(Properties prop, String regex) {
Map<String, Properties> subProperties = new HashMap<>();
Pattern pattern = Pattern.compile(regex);
for (Map.Entry<Object, Object> entry : prop.entrySet()) {
Matcher m = pattern.matcher(entry.getKey().toString());
if (m.find()) {
String prefix = m.group(1);
String suffix = m.group(2);
if (!subProperties.containsKey(prefix)) {
subProperties.put(prefix, new Properties());
}
subProperties.get(prefix).put(suffix, entry.getValue());
}
}
return subProperties;
}
|
java
|
public static Map<String, Properties> subProperties(Properties prop, String regex) {
Map<String, Properties> subProperties = new HashMap<>();
Pattern pattern = Pattern.compile(regex);
for (Map.Entry<Object, Object> entry : prop.entrySet()) {
Matcher m = pattern.matcher(entry.getKey().toString());
if (m.find()) {
String prefix = m.group(1);
String suffix = m.group(2);
if (!subProperties.containsKey(prefix)) {
subProperties.put(prefix, new Properties());
}
subProperties.get(prefix).put(suffix, entry.getValue());
}
}
return subProperties;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Properties",
">",
"subProperties",
"(",
"Properties",
"prop",
",",
"String",
"regex",
")",
"{",
"Map",
"<",
"String",
",",
"Properties",
">",
"subProperties",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Pattern",
"pattern",
"=",
"Pattern",
".",
"compile",
"(",
"regex",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Object",
">",
"entry",
":",
"prop",
".",
"entrySet",
"(",
")",
")",
"{",
"Matcher",
"m",
"=",
"pattern",
".",
"matcher",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"m",
".",
"find",
"(",
")",
")",
"{",
"String",
"prefix",
"=",
"m",
".",
"group",
"(",
"1",
")",
";",
"String",
"suffix",
"=",
"m",
".",
"group",
"(",
"2",
")",
";",
"if",
"(",
"!",
"subProperties",
".",
"containsKey",
"(",
"prefix",
")",
")",
"{",
"subProperties",
".",
"put",
"(",
"prefix",
",",
"new",
"Properties",
"(",
")",
")",
";",
"}",
"subProperties",
".",
"get",
"(",
"prefix",
")",
".",
"put",
"(",
"suffix",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"return",
"subProperties",
";",
"}"
] |
Uses regex to parse every original property key to a prefix and a suffix. Creates sub
properties that are grouped by the prefix.
@param prop the original properties
@param regex prefix and suffix pattern
@return a {@code Map} from the prefix to its properties
|
[
"Uses",
"regex",
"to",
"parse",
"every",
"original",
"property",
"key",
"to",
"a",
"prefix",
"and",
"a",
"suffix",
".",
"Creates",
"sub",
"properties",
"that",
"are",
"grouped",
"by",
"the",
"prefix",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/metrics/MetricsConfig.java#L76-L92
|
18,375
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/metrics/MetricsConfig.java
|
MetricsConfig.loadConfigFile
|
private void loadConfigFile(String configFile) {
try (InputStream is = new FileInputStream(configFile)) {
mProperties.load(is);
} catch (Exception e) {
LOG.error("Error loading metrics configuration file.", e);
}
}
|
java
|
private void loadConfigFile(String configFile) {
try (InputStream is = new FileInputStream(configFile)) {
mProperties.load(is);
} catch (Exception e) {
LOG.error("Error loading metrics configuration file.", e);
}
}
|
[
"private",
"void",
"loadConfigFile",
"(",
"String",
"configFile",
")",
"{",
"try",
"(",
"InputStream",
"is",
"=",
"new",
"FileInputStream",
"(",
"configFile",
")",
")",
"{",
"mProperties",
".",
"load",
"(",
"is",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Error loading metrics configuration file.\"",
",",
"e",
")",
";",
"}",
"}"
] |
Loads the metrics configuration file.
@param configFile the metrics config file
|
[
"Loads",
"the",
"metrics",
"configuration",
"file",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/metrics/MetricsConfig.java#L99-L105
|
18,376
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/metrics/MetricsConfig.java
|
MetricsConfig.removeInstancePrefix
|
private void removeInstancePrefix() {
Properties newProperties = new Properties();
for (Map.Entry<Object, Object> entry : mProperties.entrySet()) {
String key = entry.getKey().toString();
if (key.startsWith("*") || key.startsWith("worker") || key.startsWith("master")) {
String newKey = key.substring(key.indexOf('.') + 1);
newProperties.put(newKey, entry.getValue());
} else {
newProperties.put(key, entry.getValue());
}
}
mProperties = newProperties;
}
|
java
|
private void removeInstancePrefix() {
Properties newProperties = new Properties();
for (Map.Entry<Object, Object> entry : mProperties.entrySet()) {
String key = entry.getKey().toString();
if (key.startsWith("*") || key.startsWith("worker") || key.startsWith("master")) {
String newKey = key.substring(key.indexOf('.') + 1);
newProperties.put(newKey, entry.getValue());
} else {
newProperties.put(key, entry.getValue());
}
}
mProperties = newProperties;
}
|
[
"private",
"void",
"removeInstancePrefix",
"(",
")",
"{",
"Properties",
"newProperties",
"=",
"new",
"Properties",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Object",
",",
"Object",
">",
"entry",
":",
"mProperties",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"key",
".",
"startsWith",
"(",
"\"*\"",
")",
"||",
"key",
".",
"startsWith",
"(",
"\"worker\"",
")",
"||",
"key",
".",
"startsWith",
"(",
"\"master\"",
")",
")",
"{",
"String",
"newKey",
"=",
"key",
".",
"substring",
"(",
"key",
".",
"indexOf",
"(",
"'",
"'",
")",
"+",
"1",
")",
";",
"newProperties",
".",
"put",
"(",
"newKey",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"else",
"{",
"newProperties",
".",
"put",
"(",
"key",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"mProperties",
"=",
"newProperties",
";",
"}"
] |
Removes the instance prefix in the properties. This is to make the configuration
parsing logic backward compatible with old configuration format.
|
[
"Removes",
"the",
"instance",
"prefix",
"in",
"the",
"properties",
".",
"This",
"is",
"to",
"make",
"the",
"configuration",
"parsing",
"logic",
"backward",
"compatible",
"with",
"old",
"configuration",
"format",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/metrics/MetricsConfig.java#L111-L124
|
18,377
|
Alluxio/alluxio
|
examples/src/main/java/alluxio/examples/Performance.java
|
Performance.logPerIteration
|
public static void logPerIteration(long startTimeMs, int times, String msg, int workerId) {
long takenTimeMs = System.currentTimeMillis() - startTimeMs;
double result = 1000.0 * sFileBytes / takenTimeMs / 1024 / 1024;
LOG.info(times + msg + workerId + " : " + result + " Mb/sec. Took " + takenTimeMs + " ms. ");
}
|
java
|
public static void logPerIteration(long startTimeMs, int times, String msg, int workerId) {
long takenTimeMs = System.currentTimeMillis() - startTimeMs;
double result = 1000.0 * sFileBytes / takenTimeMs / 1024 / 1024;
LOG.info(times + msg + workerId + " : " + result + " Mb/sec. Took " + takenTimeMs + " ms. ");
}
|
[
"public",
"static",
"void",
"logPerIteration",
"(",
"long",
"startTimeMs",
",",
"int",
"times",
",",
"String",
"msg",
",",
"int",
"workerId",
")",
"{",
"long",
"takenTimeMs",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"startTimeMs",
";",
"double",
"result",
"=",
"1000.0",
"*",
"sFileBytes",
"/",
"takenTimeMs",
"/",
"1024",
"/",
"1024",
";",
"LOG",
".",
"info",
"(",
"times",
"+",
"msg",
"+",
"workerId",
"+",
"\" : \"",
"+",
"result",
"+",
"\" Mb/sec. Took \"",
"+",
"takenTimeMs",
"+",
"\" ms. \"",
")",
";",
"}"
] |
Writes log information.
@param startTimeMs the start time in milliseconds
@param times the number of the iteration
@param msg the message
@param workerId the id of the worker
|
[
"Writes",
"log",
"information",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/examples/src/main/java/alluxio/examples/Performance.java#L75-L79
|
18,378
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/metrics/sink/CsvSink.java
|
CsvSink.getPollDir
|
private String getPollDir() {
String pollDir = mProperties.getProperty(CSV_KEY_DIR);
return pollDir != null ? pollDir : CSV_DEFAULT_DIR;
}
|
java
|
private String getPollDir() {
String pollDir = mProperties.getProperty(CSV_KEY_DIR);
return pollDir != null ? pollDir : CSV_DEFAULT_DIR;
}
|
[
"private",
"String",
"getPollDir",
"(",
")",
"{",
"String",
"pollDir",
"=",
"mProperties",
".",
"getProperty",
"(",
"CSV_KEY_DIR",
")",
";",
"return",
"pollDir",
"!=",
"null",
"?",
"pollDir",
":",
"CSV_DEFAULT_DIR",
";",
"}"
] |
Gets the directory where the CSV files are created.
@return the polling directory set by properties. If it is not set, a default value /tmp/ is
returned.
|
[
"Gets",
"the",
"directory",
"where",
"the",
"CSV",
"files",
"are",
"created",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/metrics/sink/CsvSink.java#L79-L82
|
18,379
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/retry/RetryUtils.java
|
RetryUtils.retry
|
public static void retry(String action, RunnableThrowsIOException f, RetryPolicy policy)
throws IOException {
IOException e = null;
while (policy.attempt()) {
try {
f.run();
return;
} catch (IOException ioe) {
e = ioe;
LOG.warn("Failed to {} (attempt {}): {}", action, policy.getAttemptCount(), e.toString());
}
}
throw e;
}
|
java
|
public static void retry(String action, RunnableThrowsIOException f, RetryPolicy policy)
throws IOException {
IOException e = null;
while (policy.attempt()) {
try {
f.run();
return;
} catch (IOException ioe) {
e = ioe;
LOG.warn("Failed to {} (attempt {}): {}", action, policy.getAttemptCount(), e.toString());
}
}
throw e;
}
|
[
"public",
"static",
"void",
"retry",
"(",
"String",
"action",
",",
"RunnableThrowsIOException",
"f",
",",
"RetryPolicy",
"policy",
")",
"throws",
"IOException",
"{",
"IOException",
"e",
"=",
"null",
";",
"while",
"(",
"policy",
".",
"attempt",
"(",
")",
")",
"{",
"try",
"{",
"f",
".",
"run",
"(",
")",
";",
"return",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"e",
"=",
"ioe",
";",
"LOG",
".",
"warn",
"(",
"\"Failed to {} (attempt {}): {}\"",
",",
"action",
",",
"policy",
".",
"getAttemptCount",
"(",
")",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"throw",
"e",
";",
"}"
] |
Retries the given method until it doesn't throw an IO exception or the retry policy expires. If
the retry policy expires, the last exception generated will be rethrown.
@param action a description of the action that fits the phrase "Failed to ${action}"
@param f the function to retry
@param policy the retry policy to use
|
[
"Retries",
"the",
"given",
"method",
"until",
"it",
"doesn",
"t",
"throw",
"an",
"IO",
"exception",
"or",
"the",
"retry",
"policy",
"expires",
".",
"If",
"the",
"retry",
"policy",
"expires",
"the",
"last",
"exception",
"generated",
"will",
"be",
"rethrown",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/retry/RetryUtils.java#L34-L47
|
18,380
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/retry/RetryUtils.java
|
RetryUtils.defaultClientRetry
|
public static RetryPolicy defaultClientRetry(Duration maxRetryDuration, Duration baseSleepMs,
Duration maxSleepMs) {
return ExponentialTimeBoundedRetry.builder()
.withMaxDuration(maxRetryDuration)
.withInitialSleep(baseSleepMs)
.withMaxSleep(maxSleepMs)
.build();
}
|
java
|
public static RetryPolicy defaultClientRetry(Duration maxRetryDuration, Duration baseSleepMs,
Duration maxSleepMs) {
return ExponentialTimeBoundedRetry.builder()
.withMaxDuration(maxRetryDuration)
.withInitialSleep(baseSleepMs)
.withMaxSleep(maxSleepMs)
.build();
}
|
[
"public",
"static",
"RetryPolicy",
"defaultClientRetry",
"(",
"Duration",
"maxRetryDuration",
",",
"Duration",
"baseSleepMs",
",",
"Duration",
"maxSleepMs",
")",
"{",
"return",
"ExponentialTimeBoundedRetry",
".",
"builder",
"(",
")",
".",
"withMaxDuration",
"(",
"maxRetryDuration",
")",
".",
"withInitialSleep",
"(",
"baseSleepMs",
")",
".",
"withMaxSleep",
"(",
"maxSleepMs",
")",
".",
"build",
"(",
")",
";",
"}"
] |
Gives a ClientRetry based on the given parameters.
@param maxRetryDuration the maximum total duration to retry for
@param baseSleepMs initial sleep time in milliseconds
@param maxSleepMs max sleep time in milliseconds
@return the default client retry
|
[
"Gives",
"a",
"ClientRetry",
"based",
"on",
"the",
"given",
"parameters",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/retry/RetryUtils.java#L57-L64
|
18,381
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/MultiMasterLocalAlluxioCluster.java
|
MultiMasterLocalAlluxioCluster.stopStandby
|
public boolean stopStandby() {
for (int k = 0; k < mNumOfMasters; k++) {
if (!mMasters.get(k).isServing()) {
try {
LOG.info("master {} is a standby. stopping it...", k);
mMasters.get(k).stop();
LOG.info("master {} stopped.", k);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
return false;
}
return true;
}
}
return false;
}
|
java
|
public boolean stopStandby() {
for (int k = 0; k < mNumOfMasters; k++) {
if (!mMasters.get(k).isServing()) {
try {
LOG.info("master {} is a standby. stopping it...", k);
mMasters.get(k).stop();
LOG.info("master {} stopped.", k);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
return false;
}
return true;
}
}
return false;
}
|
[
"public",
"boolean",
"stopStandby",
"(",
")",
"{",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"mNumOfMasters",
";",
"k",
"++",
")",
"{",
"if",
"(",
"!",
"mMasters",
".",
"get",
"(",
"k",
")",
".",
"isServing",
"(",
")",
")",
"{",
"try",
"{",
"LOG",
".",
"info",
"(",
"\"master {} is a standby. stopping it...\"",
",",
"k",
")",
";",
"mMasters",
".",
"get",
"(",
"k",
")",
".",
"stop",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"master {} stopped.\"",
",",
"k",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Iterates over the masters in the order of master creation, stops the first standby master.
@return true if a standby master is successfully stopped, otherwise, false
|
[
"Iterates",
"over",
"the",
"masters",
"in",
"the",
"order",
"of",
"master",
"creation",
"stops",
"the",
"first",
"standby",
"master",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/MultiMasterLocalAlluxioCluster.java#L154-L169
|
18,382
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/MultiMasterLocalAlluxioCluster.java
|
MultiMasterLocalAlluxioCluster.waitForNewMaster
|
public void waitForNewMaster(int timeoutMs) throws TimeoutException, InterruptedException {
CommonUtils.waitFor("the new leader master to start", () -> getLeaderIndex() != -1,
WaitForOptions.defaults().setTimeoutMs(timeoutMs));
}
|
java
|
public void waitForNewMaster(int timeoutMs) throws TimeoutException, InterruptedException {
CommonUtils.waitFor("the new leader master to start", () -> getLeaderIndex() != -1,
WaitForOptions.defaults().setTimeoutMs(timeoutMs));
}
|
[
"public",
"void",
"waitForNewMaster",
"(",
"int",
"timeoutMs",
")",
"throws",
"TimeoutException",
",",
"InterruptedException",
"{",
"CommonUtils",
".",
"waitFor",
"(",
"\"the new leader master to start\"",
",",
"(",
")",
"->",
"getLeaderIndex",
"(",
")",
"!=",
"-",
"1",
",",
"WaitForOptions",
".",
"defaults",
"(",
")",
".",
"setTimeoutMs",
"(",
"timeoutMs",
")",
")",
";",
"}"
] |
Waits for a new master to start until a timeout occurs.
@param timeoutMs the number of milliseconds to wait before giving up and throwing an exception
|
[
"Waits",
"for",
"a",
"new",
"master",
"to",
"start",
"until",
"a",
"timeout",
"occurs",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/MultiMasterLocalAlluxioCluster.java#L198-L201
|
18,383
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/grpc/GrpcUtils.java
|
GrpcUtils.toGetStatusOptions
|
public static GetStatusPOptions toGetStatusOptions(ExistsPOptions existsOptions) {
GetStatusPOptions.Builder getStatusOptionsBuilder = GetStatusPOptions.newBuilder();
if (existsOptions.hasCommonOptions()) {
getStatusOptionsBuilder.setCommonOptions(existsOptions.getCommonOptions());
}
if (existsOptions.hasLoadMetadataType()) {
getStatusOptionsBuilder.setLoadMetadataType(existsOptions.getLoadMetadataType());
}
return getStatusOptionsBuilder.build();
}
|
java
|
public static GetStatusPOptions toGetStatusOptions(ExistsPOptions existsOptions) {
GetStatusPOptions.Builder getStatusOptionsBuilder = GetStatusPOptions.newBuilder();
if (existsOptions.hasCommonOptions()) {
getStatusOptionsBuilder.setCommonOptions(existsOptions.getCommonOptions());
}
if (existsOptions.hasLoadMetadataType()) {
getStatusOptionsBuilder.setLoadMetadataType(existsOptions.getLoadMetadataType());
}
return getStatusOptionsBuilder.build();
}
|
[
"public",
"static",
"GetStatusPOptions",
"toGetStatusOptions",
"(",
"ExistsPOptions",
"existsOptions",
")",
"{",
"GetStatusPOptions",
".",
"Builder",
"getStatusOptionsBuilder",
"=",
"GetStatusPOptions",
".",
"newBuilder",
"(",
")",
";",
"if",
"(",
"existsOptions",
".",
"hasCommonOptions",
"(",
")",
")",
"{",
"getStatusOptionsBuilder",
".",
"setCommonOptions",
"(",
"existsOptions",
".",
"getCommonOptions",
"(",
")",
")",
";",
"}",
"if",
"(",
"existsOptions",
".",
"hasLoadMetadataType",
"(",
")",
")",
"{",
"getStatusOptionsBuilder",
".",
"setLoadMetadataType",
"(",
"existsOptions",
".",
"getLoadMetadataType",
"(",
")",
")",
";",
"}",
"return",
"getStatusOptionsBuilder",
".",
"build",
"(",
")",
";",
"}"
] |
Converts from proto type to options.
@param existsOptions the proto options to convert
@return the converted proto options
|
[
"Converts",
"from",
"proto",
"type",
"to",
"options",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/grpc/GrpcUtils.java#L59-L68
|
18,384
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/grpc/GrpcUtils.java
|
GrpcUtils.toProto
|
public static alluxio.grpc.FileInfo toProto(FileInfo fileInfo) {
List<alluxio.grpc.FileBlockInfo> fileBlockInfos = new ArrayList<>();
for (FileBlockInfo fileBlockInfo : fileInfo.getFileBlockInfos()) {
fileBlockInfos.add(toProto(fileBlockInfo));
}
alluxio.grpc.FileInfo.Builder builder = alluxio.grpc.FileInfo.newBuilder()
.setFileId(fileInfo.getFileId()).setName(fileInfo.getName()).setPath(fileInfo.getPath())
.setUfsPath(fileInfo.getUfsPath()).setLength(fileInfo.getLength())
.setBlockSizeBytes(fileInfo.getBlockSizeBytes())
.setCreationTimeMs(fileInfo.getCreationTimeMs()).setCompleted(fileInfo.isCompleted())
.setFolder(fileInfo.isFolder()).setPinned(fileInfo.isPinned())
.setCacheable(fileInfo.isCacheable()).setPersisted(fileInfo.isPersisted())
.addAllBlockIds(fileInfo.getBlockIds())
.setLastModificationTimeMs(fileInfo.getLastModificationTimeMs()).setTtl(fileInfo.getTtl())
.setOwner(fileInfo.getOwner()).setGroup(fileInfo.getGroup()).setMode(fileInfo.getMode())
.setPersistenceState(fileInfo.getPersistenceState()).setMountPoint(fileInfo.isMountPoint())
.addAllFileBlockInfos(fileBlockInfos)
.setTtlAction(fileInfo.getTtlAction()).setMountId(fileInfo.getMountId())
.setInAlluxioPercentage(fileInfo.getInAlluxioPercentage())
.setInMemoryPercentage(fileInfo.getInMemoryPercentage())
.setUfsFingerprint(fileInfo.getUfsFingerprint())
.setReplicationMax(fileInfo.getReplicationMax())
.setReplicationMin(fileInfo.getReplicationMin());
if (!fileInfo.getAcl().equals(AccessControlList.EMPTY_ACL)) {
builder.setAcl(toProto(fileInfo.getAcl()));
}
if (!fileInfo.getDefaultAcl().equals(DefaultAccessControlList.EMPTY_DEFAULT_ACL)) {
builder.setDefaultAcl(toProto(fileInfo.getDefaultAcl()));
}
return builder.build();
}
|
java
|
public static alluxio.grpc.FileInfo toProto(FileInfo fileInfo) {
List<alluxio.grpc.FileBlockInfo> fileBlockInfos = new ArrayList<>();
for (FileBlockInfo fileBlockInfo : fileInfo.getFileBlockInfos()) {
fileBlockInfos.add(toProto(fileBlockInfo));
}
alluxio.grpc.FileInfo.Builder builder = alluxio.grpc.FileInfo.newBuilder()
.setFileId(fileInfo.getFileId()).setName(fileInfo.getName()).setPath(fileInfo.getPath())
.setUfsPath(fileInfo.getUfsPath()).setLength(fileInfo.getLength())
.setBlockSizeBytes(fileInfo.getBlockSizeBytes())
.setCreationTimeMs(fileInfo.getCreationTimeMs()).setCompleted(fileInfo.isCompleted())
.setFolder(fileInfo.isFolder()).setPinned(fileInfo.isPinned())
.setCacheable(fileInfo.isCacheable()).setPersisted(fileInfo.isPersisted())
.addAllBlockIds(fileInfo.getBlockIds())
.setLastModificationTimeMs(fileInfo.getLastModificationTimeMs()).setTtl(fileInfo.getTtl())
.setOwner(fileInfo.getOwner()).setGroup(fileInfo.getGroup()).setMode(fileInfo.getMode())
.setPersistenceState(fileInfo.getPersistenceState()).setMountPoint(fileInfo.isMountPoint())
.addAllFileBlockInfos(fileBlockInfos)
.setTtlAction(fileInfo.getTtlAction()).setMountId(fileInfo.getMountId())
.setInAlluxioPercentage(fileInfo.getInAlluxioPercentage())
.setInMemoryPercentage(fileInfo.getInMemoryPercentage())
.setUfsFingerprint(fileInfo.getUfsFingerprint())
.setReplicationMax(fileInfo.getReplicationMax())
.setReplicationMin(fileInfo.getReplicationMin());
if (!fileInfo.getAcl().equals(AccessControlList.EMPTY_ACL)) {
builder.setAcl(toProto(fileInfo.getAcl()));
}
if (!fileInfo.getDefaultAcl().equals(DefaultAccessControlList.EMPTY_DEFAULT_ACL)) {
builder.setDefaultAcl(toProto(fileInfo.getDefaultAcl()));
}
return builder.build();
}
|
[
"public",
"static",
"alluxio",
".",
"grpc",
".",
"FileInfo",
"toProto",
"(",
"FileInfo",
"fileInfo",
")",
"{",
"List",
"<",
"alluxio",
".",
"grpc",
".",
"FileBlockInfo",
">",
"fileBlockInfos",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"FileBlockInfo",
"fileBlockInfo",
":",
"fileInfo",
".",
"getFileBlockInfos",
"(",
")",
")",
"{",
"fileBlockInfos",
".",
"add",
"(",
"toProto",
"(",
"fileBlockInfo",
")",
")",
";",
"}",
"alluxio",
".",
"grpc",
".",
"FileInfo",
".",
"Builder",
"builder",
"=",
"alluxio",
".",
"grpc",
".",
"FileInfo",
".",
"newBuilder",
"(",
")",
".",
"setFileId",
"(",
"fileInfo",
".",
"getFileId",
"(",
")",
")",
".",
"setName",
"(",
"fileInfo",
".",
"getName",
"(",
")",
")",
".",
"setPath",
"(",
"fileInfo",
".",
"getPath",
"(",
")",
")",
".",
"setUfsPath",
"(",
"fileInfo",
".",
"getUfsPath",
"(",
")",
")",
".",
"setLength",
"(",
"fileInfo",
".",
"getLength",
"(",
")",
")",
".",
"setBlockSizeBytes",
"(",
"fileInfo",
".",
"getBlockSizeBytes",
"(",
")",
")",
".",
"setCreationTimeMs",
"(",
"fileInfo",
".",
"getCreationTimeMs",
"(",
")",
")",
".",
"setCompleted",
"(",
"fileInfo",
".",
"isCompleted",
"(",
")",
")",
".",
"setFolder",
"(",
"fileInfo",
".",
"isFolder",
"(",
")",
")",
".",
"setPinned",
"(",
"fileInfo",
".",
"isPinned",
"(",
")",
")",
".",
"setCacheable",
"(",
"fileInfo",
".",
"isCacheable",
"(",
")",
")",
".",
"setPersisted",
"(",
"fileInfo",
".",
"isPersisted",
"(",
")",
")",
".",
"addAllBlockIds",
"(",
"fileInfo",
".",
"getBlockIds",
"(",
")",
")",
".",
"setLastModificationTimeMs",
"(",
"fileInfo",
".",
"getLastModificationTimeMs",
"(",
")",
")",
".",
"setTtl",
"(",
"fileInfo",
".",
"getTtl",
"(",
")",
")",
".",
"setOwner",
"(",
"fileInfo",
".",
"getOwner",
"(",
")",
")",
".",
"setGroup",
"(",
"fileInfo",
".",
"getGroup",
"(",
")",
")",
".",
"setMode",
"(",
"fileInfo",
".",
"getMode",
"(",
")",
")",
".",
"setPersistenceState",
"(",
"fileInfo",
".",
"getPersistenceState",
"(",
")",
")",
".",
"setMountPoint",
"(",
"fileInfo",
".",
"isMountPoint",
"(",
")",
")",
".",
"addAllFileBlockInfos",
"(",
"fileBlockInfos",
")",
".",
"setTtlAction",
"(",
"fileInfo",
".",
"getTtlAction",
"(",
")",
")",
".",
"setMountId",
"(",
"fileInfo",
".",
"getMountId",
"(",
")",
")",
".",
"setInAlluxioPercentage",
"(",
"fileInfo",
".",
"getInAlluxioPercentage",
"(",
")",
")",
".",
"setInMemoryPercentage",
"(",
"fileInfo",
".",
"getInMemoryPercentage",
"(",
")",
")",
".",
"setUfsFingerprint",
"(",
"fileInfo",
".",
"getUfsFingerprint",
"(",
")",
")",
".",
"setReplicationMax",
"(",
"fileInfo",
".",
"getReplicationMax",
"(",
")",
")",
".",
"setReplicationMin",
"(",
"fileInfo",
".",
"getReplicationMin",
"(",
")",
")",
";",
"if",
"(",
"!",
"fileInfo",
".",
"getAcl",
"(",
")",
".",
"equals",
"(",
"AccessControlList",
".",
"EMPTY_ACL",
")",
")",
"{",
"builder",
".",
"setAcl",
"(",
"toProto",
"(",
"fileInfo",
".",
"getAcl",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"fileInfo",
".",
"getDefaultAcl",
"(",
")",
".",
"equals",
"(",
"DefaultAccessControlList",
".",
"EMPTY_DEFAULT_ACL",
")",
")",
"{",
"builder",
".",
"setDefaultAcl",
"(",
"toProto",
"(",
"fileInfo",
".",
"getDefaultAcl",
"(",
")",
")",
")",
";",
"}",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}"
] |
Converts a wire type to a proto type.
@param fileInfo the wire representation of a file information
@return proto representation of the file information
|
[
"Converts",
"a",
"wire",
"type",
"to",
"a",
"proto",
"type",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/grpc/GrpcUtils.java#L434-L465
|
18,385
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/command/FileSystemCommandUtils.java
|
FileSystemCommandUtils.setTtl
|
public static void setTtl(FileSystem fs, AlluxioURI path, long ttlMs,
TtlAction ttlAction) throws AlluxioException, IOException {
SetAttributePOptions options = SetAttributePOptions.newBuilder().setRecursive(true)
.setCommonOptions(FileSystemMasterCommonPOptions.newBuilder()
.setTtl(ttlMs).setTtlAction(ttlAction).build())
.build();
fs.setAttribute(path, options);
}
|
java
|
public static void setTtl(FileSystem fs, AlluxioURI path, long ttlMs,
TtlAction ttlAction) throws AlluxioException, IOException {
SetAttributePOptions options = SetAttributePOptions.newBuilder().setRecursive(true)
.setCommonOptions(FileSystemMasterCommonPOptions.newBuilder()
.setTtl(ttlMs).setTtlAction(ttlAction).build())
.build();
fs.setAttribute(path, options);
}
|
[
"public",
"static",
"void",
"setTtl",
"(",
"FileSystem",
"fs",
",",
"AlluxioURI",
"path",
",",
"long",
"ttlMs",
",",
"TtlAction",
"ttlAction",
")",
"throws",
"AlluxioException",
",",
"IOException",
"{",
"SetAttributePOptions",
"options",
"=",
"SetAttributePOptions",
".",
"newBuilder",
"(",
")",
".",
"setRecursive",
"(",
"true",
")",
".",
"setCommonOptions",
"(",
"FileSystemMasterCommonPOptions",
".",
"newBuilder",
"(",
")",
".",
"setTtl",
"(",
"ttlMs",
")",
".",
"setTtlAction",
"(",
"ttlAction",
")",
".",
"build",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"fs",
".",
"setAttribute",
"(",
"path",
",",
"options",
")",
";",
"}"
] |
Sets a new TTL value or unsets an existing TTL value for file at path.
@param fs the file system for Alluxio
@param path the file path
@param ttlMs the TTL (time to live) value to use; it identifies duration (in milliseconds) the
created file should be kept around before it is automatically deleted, irrespective of
whether the file is pinned; {@link Constants#NO_TTL} means to unset the TTL value
@param ttlAction Action to perform on Ttl expiry
|
[
"Sets",
"a",
"new",
"TTL",
"value",
"or",
"unsets",
"an",
"existing",
"TTL",
"value",
"for",
"file",
"at",
"path",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/command/FileSystemCommandUtils.java#L44-L51
|
18,386
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/command/FileSystemCommandUtils.java
|
FileSystemCommandUtils.setPinned
|
public static void setPinned(FileSystem fs, AlluxioURI path, boolean pinned)
throws AlluxioException, IOException {
SetAttributePOptions options = SetAttributePOptions.newBuilder().setPinned(pinned).build();
fs.setAttribute(path, options);
}
|
java
|
public static void setPinned(FileSystem fs, AlluxioURI path, boolean pinned)
throws AlluxioException, IOException {
SetAttributePOptions options = SetAttributePOptions.newBuilder().setPinned(pinned).build();
fs.setAttribute(path, options);
}
|
[
"public",
"static",
"void",
"setPinned",
"(",
"FileSystem",
"fs",
",",
"AlluxioURI",
"path",
",",
"boolean",
"pinned",
")",
"throws",
"AlluxioException",
",",
"IOException",
"{",
"SetAttributePOptions",
"options",
"=",
"SetAttributePOptions",
".",
"newBuilder",
"(",
")",
".",
"setPinned",
"(",
"pinned",
")",
".",
"build",
"(",
")",
";",
"fs",
".",
"setAttribute",
"(",
"path",
",",
"options",
")",
";",
"}"
] |
Sets pin state for the input path.
@param fs The {@link FileSystem} client
@param path The {@link AlluxioURI} path as the input of the command
@param pinned the state to be set
|
[
"Sets",
"pin",
"state",
"for",
"the",
"input",
"path",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/command/FileSystemCommandUtils.java#L60-L64
|
18,387
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/exception/status/AlluxioStatusException.java
|
AlluxioStatusException.fromCheckedException
|
public static AlluxioStatusException fromCheckedException(Throwable throwable) {
try {
throw throwable;
} catch (IOException e) {
return fromIOException(e);
} catch (AlluxioException e) {
return fromAlluxioException(e);
} catch (InterruptedException e) {
return new CancelledException(e);
} catch (RuntimeException e) {
throw new IllegalStateException("Expected a checked exception but got " + e);
} catch (Exception e) {
return new UnknownException(e);
} catch (Throwable t) {
throw new IllegalStateException("Expected a checked exception but got " + t);
}
}
|
java
|
public static AlluxioStatusException fromCheckedException(Throwable throwable) {
try {
throw throwable;
} catch (IOException e) {
return fromIOException(e);
} catch (AlluxioException e) {
return fromAlluxioException(e);
} catch (InterruptedException e) {
return new CancelledException(e);
} catch (RuntimeException e) {
throw new IllegalStateException("Expected a checked exception but got " + e);
} catch (Exception e) {
return new UnknownException(e);
} catch (Throwable t) {
throw new IllegalStateException("Expected a checked exception but got " + t);
}
}
|
[
"public",
"static",
"AlluxioStatusException",
"fromCheckedException",
"(",
"Throwable",
"throwable",
")",
"{",
"try",
"{",
"throw",
"throwable",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"return",
"fromIOException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"AlluxioException",
"e",
")",
"{",
"return",
"fromAlluxioException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"return",
"new",
"CancelledException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Expected a checked exception but got \"",
"+",
"e",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"new",
"UnknownException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Expected a checked exception but got \"",
"+",
"t",
")",
";",
"}",
"}"
] |
Converts checked throwables to Alluxio status exceptions. Unchecked throwables should not be
passed to this method. Use Throwables.propagateIfPossible before passing a Throwable to this
method.
@param throwable a throwable
@return the converted {@link AlluxioStatusException}
|
[
"Converts",
"checked",
"throwables",
"to",
"Alluxio",
"status",
"exceptions",
".",
"Unchecked",
"throwables",
"should",
"not",
"be",
"passed",
"to",
"this",
"method",
".",
"Use",
"Throwables",
".",
"propagateIfPossible",
"before",
"passing",
"a",
"Throwable",
"to",
"this",
"method",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/exception/status/AlluxioStatusException.java#L166-L182
|
18,388
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/exception/status/AlluxioStatusException.java
|
AlluxioStatusException.fromStatusRuntimeException
|
public static AlluxioStatusException fromStatusRuntimeException(StatusRuntimeException e) {
return AlluxioStatusException.from(e.getStatus().withCause(e));
}
|
java
|
public static AlluxioStatusException fromStatusRuntimeException(StatusRuntimeException e) {
return AlluxioStatusException.from(e.getStatus().withCause(e));
}
|
[
"public",
"static",
"AlluxioStatusException",
"fromStatusRuntimeException",
"(",
"StatusRuntimeException",
"e",
")",
"{",
"return",
"AlluxioStatusException",
".",
"from",
"(",
"e",
".",
"getStatus",
"(",
")",
".",
"withCause",
"(",
"e",
")",
")",
";",
"}"
] |
Converts a gRPC StatusRuntimeException to an Alluxio status exception.
@param e a gRPC StatusRuntimeException
@return the converted {@link AlluxioStatusException}
|
[
"Converts",
"a",
"gRPC",
"StatusRuntimeException",
"to",
"an",
"Alluxio",
"status",
"exception",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/exception/status/AlluxioStatusException.java#L208-L210
|
18,389
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/exception/status/AlluxioStatusException.java
|
AlluxioStatusException.fromAlluxioException
|
public static AlluxioStatusException fromAlluxioException(AlluxioException ae) {
try {
throw ae;
} catch (AccessControlException e) {
return new PermissionDeniedException(e);
} catch (BlockAlreadyExistsException | FileAlreadyCompletedException
| FileAlreadyExistsException e) {
return new AlreadyExistsException(e);
} catch (BlockDoesNotExistException | FileDoesNotExistException e) {
return new NotFoundException(e);
} catch (BlockInfoException | InvalidFileSizeException | InvalidPathException e) {
return new InvalidArgumentException(e);
} catch (ConnectionFailedException | FailedToCheckpointException
| UfsBlockAccessTokenUnavailableException e) {
return new UnavailableException(e);
} catch (DependencyDoesNotExistException | DirectoryNotEmptyException
| InvalidWorkerStateException e) {
return new FailedPreconditionException(e);
} catch (WorkerOutOfSpaceException e) {
return new ResourceExhaustedException(e);
} catch (AlluxioException e) {
return new UnknownException(e);
}
}
|
java
|
public static AlluxioStatusException fromAlluxioException(AlluxioException ae) {
try {
throw ae;
} catch (AccessControlException e) {
return new PermissionDeniedException(e);
} catch (BlockAlreadyExistsException | FileAlreadyCompletedException
| FileAlreadyExistsException e) {
return new AlreadyExistsException(e);
} catch (BlockDoesNotExistException | FileDoesNotExistException e) {
return new NotFoundException(e);
} catch (BlockInfoException | InvalidFileSizeException | InvalidPathException e) {
return new InvalidArgumentException(e);
} catch (ConnectionFailedException | FailedToCheckpointException
| UfsBlockAccessTokenUnavailableException e) {
return new UnavailableException(e);
} catch (DependencyDoesNotExistException | DirectoryNotEmptyException
| InvalidWorkerStateException e) {
return new FailedPreconditionException(e);
} catch (WorkerOutOfSpaceException e) {
return new ResourceExhaustedException(e);
} catch (AlluxioException e) {
return new UnknownException(e);
}
}
|
[
"public",
"static",
"AlluxioStatusException",
"fromAlluxioException",
"(",
"AlluxioException",
"ae",
")",
"{",
"try",
"{",
"throw",
"ae",
";",
"}",
"catch",
"(",
"AccessControlException",
"e",
")",
"{",
"return",
"new",
"PermissionDeniedException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"BlockAlreadyExistsException",
"|",
"FileAlreadyCompletedException",
"|",
"FileAlreadyExistsException",
"e",
")",
"{",
"return",
"new",
"AlreadyExistsException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"BlockDoesNotExistException",
"|",
"FileDoesNotExistException",
"e",
")",
"{",
"return",
"new",
"NotFoundException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"BlockInfoException",
"|",
"InvalidFileSizeException",
"|",
"InvalidPathException",
"e",
")",
"{",
"return",
"new",
"InvalidArgumentException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"ConnectionFailedException",
"|",
"FailedToCheckpointException",
"|",
"UfsBlockAccessTokenUnavailableException",
"e",
")",
"{",
"return",
"new",
"UnavailableException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"DependencyDoesNotExistException",
"|",
"DirectoryNotEmptyException",
"|",
"InvalidWorkerStateException",
"e",
")",
"{",
"return",
"new",
"FailedPreconditionException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"WorkerOutOfSpaceException",
"e",
")",
"{",
"return",
"new",
"ResourceExhaustedException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"AlluxioException",
"e",
")",
"{",
"return",
"new",
"UnknownException",
"(",
"e",
")",
";",
"}",
"}"
] |
Converts checked Alluxio exceptions to Alluxio status exceptions.
@param ae the Alluxio exception to convert
@return the converted {@link AlluxioStatusException}
|
[
"Converts",
"checked",
"Alluxio",
"exceptions",
"to",
"Alluxio",
"status",
"exceptions",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/exception/status/AlluxioStatusException.java#L218-L241
|
18,390
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/ProtobufUtils.java
|
ProtobufUtils.fromProtobuf
|
public static TtlAction fromProtobuf(PTtlAction pTtlAction) {
if (pTtlAction == null) {
return TtlAction.DELETE;
}
switch (pTtlAction) {
case DELETE:
return TtlAction.DELETE;
case FREE:
return TtlAction.FREE;
default:
throw new IllegalStateException("Unknown protobuf ttl action: " + pTtlAction);
}
}
|
java
|
public static TtlAction fromProtobuf(PTtlAction pTtlAction) {
if (pTtlAction == null) {
return TtlAction.DELETE;
}
switch (pTtlAction) {
case DELETE:
return TtlAction.DELETE;
case FREE:
return TtlAction.FREE;
default:
throw new IllegalStateException("Unknown protobuf ttl action: " + pTtlAction);
}
}
|
[
"public",
"static",
"TtlAction",
"fromProtobuf",
"(",
"PTtlAction",
"pTtlAction",
")",
"{",
"if",
"(",
"pTtlAction",
"==",
"null",
")",
"{",
"return",
"TtlAction",
".",
"DELETE",
";",
"}",
"switch",
"(",
"pTtlAction",
")",
"{",
"case",
"DELETE",
":",
"return",
"TtlAction",
".",
"DELETE",
";",
"case",
"FREE",
":",
"return",
"TtlAction",
".",
"FREE",
";",
"default",
":",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unknown protobuf ttl action: \"",
"+",
"pTtlAction",
")",
";",
"}",
"}"
] |
Converts Protobuf type to Wire type.
@param pTtlAction {@link PTtlAction}
@return {@link TtlAction} equivalent
|
[
"Converts",
"Protobuf",
"type",
"to",
"Wire",
"type",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/ProtobufUtils.java#L33-L45
|
18,391
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/ProtobufUtils.java
|
ProtobufUtils.toProtobuf
|
public static PTtlAction toProtobuf(TtlAction ttlAction) {
if (ttlAction == null) {
return PTtlAction.DELETE;
}
switch (ttlAction) {
case DELETE:
return PTtlAction.DELETE;
case FREE:
return PTtlAction.FREE;
default:
throw new IllegalStateException("Unknown ttl action: " + ttlAction);
}
}
|
java
|
public static PTtlAction toProtobuf(TtlAction ttlAction) {
if (ttlAction == null) {
return PTtlAction.DELETE;
}
switch (ttlAction) {
case DELETE:
return PTtlAction.DELETE;
case FREE:
return PTtlAction.FREE;
default:
throw new IllegalStateException("Unknown ttl action: " + ttlAction);
}
}
|
[
"public",
"static",
"PTtlAction",
"toProtobuf",
"(",
"TtlAction",
"ttlAction",
")",
"{",
"if",
"(",
"ttlAction",
"==",
"null",
")",
"{",
"return",
"PTtlAction",
".",
"DELETE",
";",
"}",
"switch",
"(",
"ttlAction",
")",
"{",
"case",
"DELETE",
":",
"return",
"PTtlAction",
".",
"DELETE",
";",
"case",
"FREE",
":",
"return",
"PTtlAction",
".",
"FREE",
";",
"default",
":",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unknown ttl action: \"",
"+",
"ttlAction",
")",
";",
"}",
"}"
] |
Converts Wire type to Protobuf type.
@param ttlAction {@link PTtlAction}
@return {@link TtlAction} equivalent
|
[
"Converts",
"Wire",
"type",
"to",
"Protobuf",
"type",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/ProtobufUtils.java#L53-L65
|
18,392
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/cli/validation/HadoopConfigurationFileParser.java
|
HadoopConfigurationFileParser.parseXmlConfiguration
|
public Map<String, String> parseXmlConfiguration(final String path) {
File xmlFile;
xmlFile = new File(path);
if (!xmlFile.exists()) {
System.err.format("File %s does not exist.", path);
return null;
}
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder;
try {
docBuilder = docBuilderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
System.err.format("Failed to create instance of DocumentBuilder for file: %s. %s. %n",
path, e.getMessage());
return null;
}
Document doc;
try {
doc = docBuilder.parse(xmlFile);
} catch (IOException e) {
System.err.format("An I/O error occured reading file %s. %s.%n", path, e.getMessage());
return null;
} catch (SAXException e) {
System.err.format("A parsing error occured parsing file %s. %s.%n", path, e.getMessage());
return null;
}
// Optional, but recommended.
// Refer to http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
doc.getDocumentElement().normalize();
Map<String, String> ret = new HashMap<>();
NodeList propNodeList = doc.getElementsByTagName("property");
for (int i = 0; i < propNodeList.getLength(); i++) {
Node propNode = propNodeList.item(i);
if (propNode.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) propNode;
ret.put(element.getElementsByTagName("name").item(0).getTextContent(),
element.getElementsByTagName("value").item(0).getTextContent());
}
}
return ret;
}
|
java
|
public Map<String, String> parseXmlConfiguration(final String path) {
File xmlFile;
xmlFile = new File(path);
if (!xmlFile.exists()) {
System.err.format("File %s does not exist.", path);
return null;
}
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder;
try {
docBuilder = docBuilderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
System.err.format("Failed to create instance of DocumentBuilder for file: %s. %s. %n",
path, e.getMessage());
return null;
}
Document doc;
try {
doc = docBuilder.parse(xmlFile);
} catch (IOException e) {
System.err.format("An I/O error occured reading file %s. %s.%n", path, e.getMessage());
return null;
} catch (SAXException e) {
System.err.format("A parsing error occured parsing file %s. %s.%n", path, e.getMessage());
return null;
}
// Optional, but recommended.
// Refer to http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work
doc.getDocumentElement().normalize();
Map<String, String> ret = new HashMap<>();
NodeList propNodeList = doc.getElementsByTagName("property");
for (int i = 0; i < propNodeList.getLength(); i++) {
Node propNode = propNodeList.item(i);
if (propNode.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) propNode;
ret.put(element.getElementsByTagName("name").item(0).getTextContent(),
element.getElementsByTagName("value").item(0).getTextContent());
}
}
return ret;
}
|
[
"public",
"Map",
"<",
"String",
",",
"String",
">",
"parseXmlConfiguration",
"(",
"final",
"String",
"path",
")",
"{",
"File",
"xmlFile",
";",
"xmlFile",
"=",
"new",
"File",
"(",
"path",
")",
";",
"if",
"(",
"!",
"xmlFile",
".",
"exists",
"(",
")",
")",
"{",
"System",
".",
"err",
".",
"format",
"(",
"\"File %s does not exist.\"",
",",
"path",
")",
";",
"return",
"null",
";",
"}",
"DocumentBuilderFactory",
"docBuilderFactory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"DocumentBuilder",
"docBuilder",
";",
"try",
"{",
"docBuilder",
"=",
"docBuilderFactory",
".",
"newDocumentBuilder",
"(",
")",
";",
"}",
"catch",
"(",
"ParserConfigurationException",
"e",
")",
"{",
"System",
".",
"err",
".",
"format",
"(",
"\"Failed to create instance of DocumentBuilder for file: %s. %s. %n\"",
",",
"path",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"Document",
"doc",
";",
"try",
"{",
"doc",
"=",
"docBuilder",
".",
"parse",
"(",
"xmlFile",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"System",
".",
"err",
".",
"format",
"(",
"\"An I/O error occured reading file %s. %s.%n\"",
",",
"path",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"catch",
"(",
"SAXException",
"e",
")",
"{",
"System",
".",
"err",
".",
"format",
"(",
"\"A parsing error occured parsing file %s. %s.%n\"",
",",
"path",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"// Optional, but recommended.",
"// Refer to http://stackoverflow.com/questions/13786607/normalization-in-dom-parsing-with-java-how-does-it-work",
"doc",
".",
"getDocumentElement",
"(",
")",
".",
"normalize",
"(",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"ret",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"NodeList",
"propNodeList",
"=",
"doc",
".",
"getElementsByTagName",
"(",
"\"property\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"propNodeList",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"propNode",
"=",
"propNodeList",
".",
"item",
"(",
"i",
")",
";",
"if",
"(",
"propNode",
".",
"getNodeType",
"(",
")",
"==",
"Node",
".",
"ELEMENT_NODE",
")",
"{",
"Element",
"element",
"=",
"(",
"Element",
")",
"propNode",
";",
"ret",
".",
"put",
"(",
"element",
".",
"getElementsByTagName",
"(",
"\"name\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
",",
"element",
".",
"getElementsByTagName",
"(",
"\"value\"",
")",
".",
"item",
"(",
"0",
")",
".",
"getTextContent",
"(",
")",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] |
Parse an xml configuration file into a map.
Referred to https://www.mkyong.com/java/how-to-read-xml-file-in-java-dom-parser/
@param path path to the xml file
@return Map from property names to values
|
[
"Parse",
"an",
"xml",
"configuration",
"file",
"into",
"a",
"map",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/cli/validation/HadoopConfigurationFileParser.java#L47-L87
|
18,393
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/AlluxioWorker.java
|
AlluxioWorker.main
|
public static void main(String[] args) {
if (args.length != 0) {
LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR,
AlluxioWorker.class.getCanonicalName());
System.exit(-1);
}
if (!ConfigurationUtils.masterHostConfigured(ServerConfiguration.global())) {
ProcessUtils.fatalError(LOG,
ConfigurationUtils.getMasterHostNotConfiguredMessage("Alluxio worker"));
}
CommonUtils.PROCESS_TYPE.set(CommonUtils.ProcessType.WORKER);
MasterInquireClient masterInquireClient =
MasterInquireClient.Factory.create(ServerConfiguration.global());
try {
RetryUtils.retry("load cluster default configuration with master", () -> {
InetSocketAddress masterAddress = masterInquireClient.getPrimaryRpcAddress();
ServerConfiguration.loadClusterDefaults(masterAddress);
}, RetryUtils.defaultWorkerMasterClientRetry(
ServerConfiguration.getDuration(PropertyKey.WORKER_MASTER_CONNECT_RETRY_TIMEOUT)));
} catch (IOException e) {
ProcessUtils.fatalError(LOG,
"Failed to load cluster default configuration for worker: %s", e.getMessage());
}
WorkerProcess process = WorkerProcess.Factory.create();
ProcessUtils.run(process);
}
|
java
|
public static void main(String[] args) {
if (args.length != 0) {
LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR,
AlluxioWorker.class.getCanonicalName());
System.exit(-1);
}
if (!ConfigurationUtils.masterHostConfigured(ServerConfiguration.global())) {
ProcessUtils.fatalError(LOG,
ConfigurationUtils.getMasterHostNotConfiguredMessage("Alluxio worker"));
}
CommonUtils.PROCESS_TYPE.set(CommonUtils.ProcessType.WORKER);
MasterInquireClient masterInquireClient =
MasterInquireClient.Factory.create(ServerConfiguration.global());
try {
RetryUtils.retry("load cluster default configuration with master", () -> {
InetSocketAddress masterAddress = masterInquireClient.getPrimaryRpcAddress();
ServerConfiguration.loadClusterDefaults(masterAddress);
}, RetryUtils.defaultWorkerMasterClientRetry(
ServerConfiguration.getDuration(PropertyKey.WORKER_MASTER_CONNECT_RETRY_TIMEOUT)));
} catch (IOException e) {
ProcessUtils.fatalError(LOG,
"Failed to load cluster default configuration for worker: %s", e.getMessage());
}
WorkerProcess process = WorkerProcess.Factory.create();
ProcessUtils.run(process);
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"if",
"(",
"args",
".",
"length",
"!=",
"0",
")",
"{",
"LOG",
".",
"info",
"(",
"\"java -cp {} {}\"",
",",
"RuntimeConstants",
".",
"ALLUXIO_JAR",
",",
"AlluxioWorker",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
";",
"System",
".",
"exit",
"(",
"-",
"1",
")",
";",
"}",
"if",
"(",
"!",
"ConfigurationUtils",
".",
"masterHostConfigured",
"(",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
")",
"{",
"ProcessUtils",
".",
"fatalError",
"(",
"LOG",
",",
"ConfigurationUtils",
".",
"getMasterHostNotConfiguredMessage",
"(",
"\"Alluxio worker\"",
")",
")",
";",
"}",
"CommonUtils",
".",
"PROCESS_TYPE",
".",
"set",
"(",
"CommonUtils",
".",
"ProcessType",
".",
"WORKER",
")",
";",
"MasterInquireClient",
"masterInquireClient",
"=",
"MasterInquireClient",
".",
"Factory",
".",
"create",
"(",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
";",
"try",
"{",
"RetryUtils",
".",
"retry",
"(",
"\"load cluster default configuration with master\"",
",",
"(",
")",
"->",
"{",
"InetSocketAddress",
"masterAddress",
"=",
"masterInquireClient",
".",
"getPrimaryRpcAddress",
"(",
")",
";",
"ServerConfiguration",
".",
"loadClusterDefaults",
"(",
"masterAddress",
")",
";",
"}",
",",
"RetryUtils",
".",
"defaultWorkerMasterClientRetry",
"(",
"ServerConfiguration",
".",
"getDuration",
"(",
"PropertyKey",
".",
"WORKER_MASTER_CONNECT_RETRY_TIMEOUT",
")",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"ProcessUtils",
".",
"fatalError",
"(",
"LOG",
",",
"\"Failed to load cluster default configuration for worker: %s\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"WorkerProcess",
"process",
"=",
"WorkerProcess",
".",
"Factory",
".",
"create",
"(",
")",
";",
"ProcessUtils",
".",
"run",
"(",
"process",
")",
";",
"}"
] |
Starts the Alluxio worker.
@param args command line arguments, should be empty
|
[
"Starts",
"the",
"Alluxio",
"worker",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/AlluxioWorker.java#L43-L70
|
18,394
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/grpc/GrpcManagedChannelPool.java
|
GrpcManagedChannelPool.shutdownManagedChannel
|
private void shutdownManagedChannel(ChannelKey channelKey, long shutdownTimeoutMs) {
ManagedChannel managedChannel = mChannels.get(channelKey).get();
managedChannel.shutdown();
try {
managedChannel.awaitTermination(shutdownTimeoutMs, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
// Allow thread to exit.
} finally {
managedChannel.shutdownNow();
}
Verify.verify(managedChannel.isShutdown());
LOG.debug("Shut down managed channel. ChannelKey: {}", channelKey);
}
|
java
|
private void shutdownManagedChannel(ChannelKey channelKey, long shutdownTimeoutMs) {
ManagedChannel managedChannel = mChannels.get(channelKey).get();
managedChannel.shutdown();
try {
managedChannel.awaitTermination(shutdownTimeoutMs, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
// Allow thread to exit.
} finally {
managedChannel.shutdownNow();
}
Verify.verify(managedChannel.isShutdown());
LOG.debug("Shut down managed channel. ChannelKey: {}", channelKey);
}
|
[
"private",
"void",
"shutdownManagedChannel",
"(",
"ChannelKey",
"channelKey",
",",
"long",
"shutdownTimeoutMs",
")",
"{",
"ManagedChannel",
"managedChannel",
"=",
"mChannels",
".",
"get",
"(",
"channelKey",
")",
".",
"get",
"(",
")",
";",
"managedChannel",
".",
"shutdown",
"(",
")",
";",
"try",
"{",
"managedChannel",
".",
"awaitTermination",
"(",
"shutdownTimeoutMs",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"// Allow thread to exit.",
"}",
"finally",
"{",
"managedChannel",
".",
"shutdownNow",
"(",
")",
";",
"}",
"Verify",
".",
"verify",
"(",
"managedChannel",
".",
"isShutdown",
"(",
")",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Shut down managed channel. ChannelKey: {}\"",
",",
"channelKey",
")",
";",
"}"
] |
Shuts down the managed channel for given key.
(Should be called with {@code mLock} acquired.)
@param channelKey channel key
@param shutdownTimeoutMs shutdown timeout in miliseconds
|
[
"Shuts",
"down",
"the",
"managed",
"channel",
"for",
"given",
"key",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/grpc/GrpcManagedChannelPool.java#L96-L109
|
18,395
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/resource/DynamicResourcePool.java
|
DynamicResourcePool.close
|
@Override
public void close() throws IOException {
try {
mLock.lock();
if (mAvailableResources.size() != mResources.size()) {
LOG.warn("{} resources are not released when closing the resource pool.",
mResources.size() - mAvailableResources.size());
}
for (ResourceInternal<T> resourceInternal : mAvailableResources) {
closeResource(resourceInternal.mResource);
}
mAvailableResources.clear();
} finally {
mLock.unlock();
}
mGcFuture.cancel(true);
}
|
java
|
@Override
public void close() throws IOException {
try {
mLock.lock();
if (mAvailableResources.size() != mResources.size()) {
LOG.warn("{} resources are not released when closing the resource pool.",
mResources.size() - mAvailableResources.size());
}
for (ResourceInternal<T> resourceInternal : mAvailableResources) {
closeResource(resourceInternal.mResource);
}
mAvailableResources.clear();
} finally {
mLock.unlock();
}
mGcFuture.cancel(true);
}
|
[
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"try",
"{",
"mLock",
".",
"lock",
"(",
")",
";",
"if",
"(",
"mAvailableResources",
".",
"size",
"(",
")",
"!=",
"mResources",
".",
"size",
"(",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"{} resources are not released when closing the resource pool.\"",
",",
"mResources",
".",
"size",
"(",
")",
"-",
"mAvailableResources",
".",
"size",
"(",
")",
")",
";",
"}",
"for",
"(",
"ResourceInternal",
"<",
"T",
">",
"resourceInternal",
":",
"mAvailableResources",
")",
"{",
"closeResource",
"(",
"resourceInternal",
".",
"mResource",
")",
";",
"}",
"mAvailableResources",
".",
"clear",
"(",
")",
";",
"}",
"finally",
"{",
"mLock",
".",
"unlock",
"(",
")",
";",
"}",
"mGcFuture",
".",
"cancel",
"(",
"true",
")",
";",
"}"
] |
Closes the pool and clears all the resources. The resource pool should not be used after this.
|
[
"Closes",
"the",
"pool",
"and",
"clears",
"all",
"the",
"resources",
".",
"The",
"resource",
"pool",
"should",
"not",
"be",
"used",
"after",
"this",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/resource/DynamicResourcePool.java#L389-L405
|
18,396
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/resource/DynamicResourcePool.java
|
DynamicResourcePool.add
|
private boolean add(ResourceInternal<T> resource) {
try {
mLock.lock();
if (mResources.size() >= mMaxCapacity) {
return false;
} else {
mResources.put(resource.mResource, resource);
return true;
}
} finally {
mLock.unlock();
}
}
|
java
|
private boolean add(ResourceInternal<T> resource) {
try {
mLock.lock();
if (mResources.size() >= mMaxCapacity) {
return false;
} else {
mResources.put(resource.mResource, resource);
return true;
}
} finally {
mLock.unlock();
}
}
|
[
"private",
"boolean",
"add",
"(",
"ResourceInternal",
"<",
"T",
">",
"resource",
")",
"{",
"try",
"{",
"mLock",
".",
"lock",
"(",
")",
";",
"if",
"(",
"mResources",
".",
"size",
"(",
")",
">=",
"mMaxCapacity",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"mResources",
".",
"put",
"(",
"resource",
".",
"mResource",
",",
"resource",
")",
";",
"return",
"true",
";",
"}",
"}",
"finally",
"{",
"mLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Adds a newly created resource to the pool. The resource is not available when it is added.
@param resource
@return true if the resource is successfully added
|
[
"Adds",
"a",
"newly",
"created",
"resource",
"to",
"the",
"pool",
".",
"The",
"resource",
"is",
"not",
"available",
"when",
"it",
"is",
"added",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/resource/DynamicResourcePool.java#L425-L437
|
18,397
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/resource/DynamicResourcePool.java
|
DynamicResourcePool.remove
|
private void remove(T resource) {
try {
mLock.lock();
mResources.remove(resource);
} finally {
mLock.unlock();
}
}
|
java
|
private void remove(T resource) {
try {
mLock.lock();
mResources.remove(resource);
} finally {
mLock.unlock();
}
}
|
[
"private",
"void",
"remove",
"(",
"T",
"resource",
")",
"{",
"try",
"{",
"mLock",
".",
"lock",
"(",
")",
";",
"mResources",
".",
"remove",
"(",
"resource",
")",
";",
"}",
"finally",
"{",
"mLock",
".",
"unlock",
"(",
")",
";",
"}",
"}"
] |
Removes an existing resource from the pool.
@param resource
|
[
"Removes",
"an",
"existing",
"resource",
"from",
"the",
"pool",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/resource/DynamicResourcePool.java#L444-L451
|
18,398
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/resource/DynamicResourcePool.java
|
DynamicResourcePool.checkHealthyAndRetry
|
private T checkHealthyAndRetry(T resource, long endTimeMs) throws TimeoutException, IOException {
if (isHealthy(resource)) {
return resource;
} else {
LOG.info("Clearing unhealthy resource {}.", resource);
remove(resource);
closeResource(resource);
return acquire(endTimeMs - mClock.millis(), TimeUnit.MILLISECONDS);
}
}
|
java
|
private T checkHealthyAndRetry(T resource, long endTimeMs) throws TimeoutException, IOException {
if (isHealthy(resource)) {
return resource;
} else {
LOG.info("Clearing unhealthy resource {}.", resource);
remove(resource);
closeResource(resource);
return acquire(endTimeMs - mClock.millis(), TimeUnit.MILLISECONDS);
}
}
|
[
"private",
"T",
"checkHealthyAndRetry",
"(",
"T",
"resource",
",",
"long",
"endTimeMs",
")",
"throws",
"TimeoutException",
",",
"IOException",
"{",
"if",
"(",
"isHealthy",
"(",
"resource",
")",
")",
"{",
"return",
"resource",
";",
"}",
"else",
"{",
"LOG",
".",
"info",
"(",
"\"Clearing unhealthy resource {}.\"",
",",
"resource",
")",
";",
"remove",
"(",
"resource",
")",
";",
"closeResource",
"(",
"resource",
")",
";",
"return",
"acquire",
"(",
"endTimeMs",
"-",
"mClock",
".",
"millis",
"(",
")",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"}"
] |
Checks whether the resource is healthy. If not retry. When this called, the resource
is not in mAvailableResources.
@param resource the resource to check
@param endTimeMs the end time to wait till
@return the resource
@throws TimeoutException if it times out to wait for a resource
|
[
"Checks",
"whether",
"the",
"resource",
"is",
"healthy",
".",
"If",
"not",
"retry",
".",
"When",
"this",
"called",
"the",
"resource",
"is",
"not",
"in",
"mAvailableResources",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/resource/DynamicResourcePool.java#L474-L483
|
18,399
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ShellUtils.java
|
ShellUtils.getSetPermissionCommand
|
public static String[] getSetPermissionCommand(String perm, String filePath) {
return new String[] {SET_PERMISSION_COMMAND, perm, filePath};
}
|
java
|
public static String[] getSetPermissionCommand(String perm, String filePath) {
return new String[] {SET_PERMISSION_COMMAND, perm, filePath};
}
|
[
"public",
"static",
"String",
"[",
"]",
"getSetPermissionCommand",
"(",
"String",
"perm",
",",
"String",
"filePath",
")",
"{",
"return",
"new",
"String",
"[",
"]",
"{",
"SET_PERMISSION_COMMAND",
",",
"perm",
",",
"filePath",
"}",
";",
"}"
] |
Returns a Unix command to set permission.
@param perm the permission of file
@param filePath the file path
@return the Unix command to set permission
|
[
"Returns",
"a",
"Unix",
"command",
"to",
"set",
"permission",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ShellUtils.java#L68-L70
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.