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,900
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/metastore/rocks/RocksStore.java
|
RocksStore.restoreFromCheckpoint
|
public synchronized void restoreFromCheckpoint(CheckpointInputStream input) throws IOException {
LOG.info("Restoring rocksdb from checkpoint");
long startNano = System.nanoTime();
Preconditions.checkState(input.getType() == CheckpointType.ROCKS,
"Unexpected checkpoint type in RocksStore: " + input.getType());
stopDb();
FileUtils.deletePathRecursively(mDbPath);
TarUtils.readTarGz(Paths.get(mDbPath), input);
try {
createDb();
} catch (RocksDBException e) {
throw new IOException(e);
}
LOG.info("Restored rocksdb checkpoint in {}ms",
(System.nanoTime() - startNano) / Constants.MS_NANO);
}
|
java
|
public synchronized void restoreFromCheckpoint(CheckpointInputStream input) throws IOException {
LOG.info("Restoring rocksdb from checkpoint");
long startNano = System.nanoTime();
Preconditions.checkState(input.getType() == CheckpointType.ROCKS,
"Unexpected checkpoint type in RocksStore: " + input.getType());
stopDb();
FileUtils.deletePathRecursively(mDbPath);
TarUtils.readTarGz(Paths.get(mDbPath), input);
try {
createDb();
} catch (RocksDBException e) {
throw new IOException(e);
}
LOG.info("Restored rocksdb checkpoint in {}ms",
(System.nanoTime() - startNano) / Constants.MS_NANO);
}
|
[
"public",
"synchronized",
"void",
"restoreFromCheckpoint",
"(",
"CheckpointInputStream",
"input",
")",
"throws",
"IOException",
"{",
"LOG",
".",
"info",
"(",
"\"Restoring rocksdb from checkpoint\"",
")",
";",
"long",
"startNano",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"input",
".",
"getType",
"(",
")",
"==",
"CheckpointType",
".",
"ROCKS",
",",
"\"Unexpected checkpoint type in RocksStore: \"",
"+",
"input",
".",
"getType",
"(",
")",
")",
";",
"stopDb",
"(",
")",
";",
"FileUtils",
".",
"deletePathRecursively",
"(",
"mDbPath",
")",
";",
"TarUtils",
".",
"readTarGz",
"(",
"Paths",
".",
"get",
"(",
"mDbPath",
")",
",",
"input",
")",
";",
"try",
"{",
"createDb",
"(",
")",
";",
"}",
"catch",
"(",
"RocksDBException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
")",
";",
"}",
"LOG",
".",
"info",
"(",
"\"Restored rocksdb checkpoint in {}ms\"",
",",
"(",
"System",
".",
"nanoTime",
"(",
")",
"-",
"startNano",
")",
"/",
"Constants",
".",
"MS_NANO",
")",
";",
"}"
] |
Restores the database from a checkpoint.
@param input the checkpoint stream to restore from
|
[
"Restores",
"the",
"database",
"from",
"a",
"checkpoint",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/metastore/rocks/RocksStore.java#L184-L199
|
18,901
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/conf/path/TrieNode.java
|
TrieNode.insert
|
public TrieNode insert(String path) {
TrieNode current = this;
for (String component : path.split("/")) {
if (!current.mChildren.containsKey(component)) {
current.mChildren.put(component, new TrieNode());
}
current = current.mChildren.get(component);
}
current.mIsTerminal = true;
return current;
}
|
java
|
public TrieNode insert(String path) {
TrieNode current = this;
for (String component : path.split("/")) {
if (!current.mChildren.containsKey(component)) {
current.mChildren.put(component, new TrieNode());
}
current = current.mChildren.get(component);
}
current.mIsTerminal = true;
return current;
}
|
[
"public",
"TrieNode",
"insert",
"(",
"String",
"path",
")",
"{",
"TrieNode",
"current",
"=",
"this",
";",
"for",
"(",
"String",
"component",
":",
"path",
".",
"split",
"(",
"\"/\"",
")",
")",
"{",
"if",
"(",
"!",
"current",
".",
"mChildren",
".",
"containsKey",
"(",
"component",
")",
")",
"{",
"current",
".",
"mChildren",
".",
"put",
"(",
"component",
",",
"new",
"TrieNode",
"(",
")",
")",
";",
"}",
"current",
"=",
"current",
".",
"mChildren",
".",
"get",
"(",
"component",
")",
";",
"}",
"current",
".",
"mIsTerminal",
"=",
"true",
";",
"return",
"current",
";",
"}"
] |
Inserts a path into the trie.
Each path component forms a node in the trie,
root path "/" will correspond to the root of the trie.
@param path a path with components separated by "/"
@return the last inserted trie node or the last traversed trie node if no node is inserted
|
[
"Inserts",
"a",
"path",
"into",
"the",
"trie",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/conf/path/TrieNode.java#L38-L48
|
18,902
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/conf/path/TrieNode.java
|
TrieNode.search
|
public List<TrieNode> search(String path) {
List<TrieNode> terminal = new ArrayList<>();
TrieNode current = this;
if (current.mIsTerminal) {
terminal.add(current);
}
for (String component : path.split("/")) {
if (current.mChildren.containsKey(component)) {
current = current.mChildren.get(component);
if (current.mIsTerminal) {
terminal.add(current);
}
} else {
break;
}
}
return terminal;
}
|
java
|
public List<TrieNode> search(String path) {
List<TrieNode> terminal = new ArrayList<>();
TrieNode current = this;
if (current.mIsTerminal) {
terminal.add(current);
}
for (String component : path.split("/")) {
if (current.mChildren.containsKey(component)) {
current = current.mChildren.get(component);
if (current.mIsTerminal) {
terminal.add(current);
}
} else {
break;
}
}
return terminal;
}
|
[
"public",
"List",
"<",
"TrieNode",
">",
"search",
"(",
"String",
"path",
")",
"{",
"List",
"<",
"TrieNode",
">",
"terminal",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"TrieNode",
"current",
"=",
"this",
";",
"if",
"(",
"current",
".",
"mIsTerminal",
")",
"{",
"terminal",
".",
"add",
"(",
"current",
")",
";",
"}",
"for",
"(",
"String",
"component",
":",
"path",
".",
"split",
"(",
"\"/\"",
")",
")",
"{",
"if",
"(",
"current",
".",
"mChildren",
".",
"containsKey",
"(",
"component",
")",
")",
"{",
"current",
"=",
"current",
".",
"mChildren",
".",
"get",
"(",
"component",
")",
";",
"if",
"(",
"current",
".",
"mIsTerminal",
")",
"{",
"terminal",
".",
"add",
"(",
"current",
")",
";",
"}",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"return",
"terminal",
";",
"}"
] |
Traverses the trie along the path components until the traversal cannot proceed any more.
@param path the target path
@return the terminal nodes sorted by the time they are visited
|
[
"Traverses",
"the",
"trie",
"along",
"the",
"path",
"components",
"until",
"the",
"traversal",
"cannot",
"proceed",
"any",
"more",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/conf/path/TrieNode.java#L56-L73
|
18,903
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/cli/CommandUtils.java
|
CommandUtils.checkNumOfArgsEquals
|
public static void checkNumOfArgsEquals(Command cmd, CommandLine cl, int n) throws
InvalidArgumentException {
if (cl.getArgs().length != n) {
throw new InvalidArgumentException(ExceptionMessage.INVALID_ARGS_NUM
.getMessage(cmd.getCommandName(), n, cl.getArgs().length));
}
}
|
java
|
public static void checkNumOfArgsEquals(Command cmd, CommandLine cl, int n) throws
InvalidArgumentException {
if (cl.getArgs().length != n) {
throw new InvalidArgumentException(ExceptionMessage.INVALID_ARGS_NUM
.getMessage(cmd.getCommandName(), n, cl.getArgs().length));
}
}
|
[
"public",
"static",
"void",
"checkNumOfArgsEquals",
"(",
"Command",
"cmd",
",",
"CommandLine",
"cl",
",",
"int",
"n",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"cl",
".",
"getArgs",
"(",
")",
".",
"length",
"!=",
"n",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"ExceptionMessage",
".",
"INVALID_ARGS_NUM",
".",
"getMessage",
"(",
"cmd",
".",
"getCommandName",
"(",
")",
",",
"n",
",",
"cl",
".",
"getArgs",
"(",
")",
".",
"length",
")",
")",
";",
"}",
"}"
] |
Checks the number of non-option arguments equals n for command.
@param cmd command instance
@param cl parsed commandline arguments
@param n an integer
@throws InvalidArgumentException if the number does not equal n
|
[
"Checks",
"the",
"number",
"of",
"non",
"-",
"option",
"arguments",
"equals",
"n",
"for",
"command",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/cli/CommandUtils.java#L68-L74
|
18,904
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/cli/CommandUtils.java
|
CommandUtils.checkNumOfArgsNoLessThan
|
public static void checkNumOfArgsNoLessThan(Command cmd, CommandLine cl, int n) throws
InvalidArgumentException {
if (cl.getArgs().length < n) {
throw new InvalidArgumentException(ExceptionMessage.INVALID_ARGS_NUM_INSUFFICIENT
.getMessage(cmd.getCommandName(), n, cl.getArgs().length));
}
}
|
java
|
public static void checkNumOfArgsNoLessThan(Command cmd, CommandLine cl, int n) throws
InvalidArgumentException {
if (cl.getArgs().length < n) {
throw new InvalidArgumentException(ExceptionMessage.INVALID_ARGS_NUM_INSUFFICIENT
.getMessage(cmd.getCommandName(), n, cl.getArgs().length));
}
}
|
[
"public",
"static",
"void",
"checkNumOfArgsNoLessThan",
"(",
"Command",
"cmd",
",",
"CommandLine",
"cl",
",",
"int",
"n",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"cl",
".",
"getArgs",
"(",
")",
".",
"length",
"<",
"n",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"ExceptionMessage",
".",
"INVALID_ARGS_NUM_INSUFFICIENT",
".",
"getMessage",
"(",
"cmd",
".",
"getCommandName",
"(",
")",
",",
"n",
",",
"cl",
".",
"getArgs",
"(",
")",
".",
"length",
")",
")",
";",
"}",
"}"
] |
Checks the number of non-option arguments is no less than n for command.
@param cmd command instance
@param cl parsed commandline arguments
@param n an integer
@throws InvalidArgumentException if the number is smaller than n
|
[
"Checks",
"the",
"number",
"of",
"non",
"-",
"option",
"arguments",
"is",
"no",
"less",
"than",
"n",
"for",
"command",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/cli/CommandUtils.java#L84-L90
|
18,905
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/cli/CommandUtils.java
|
CommandUtils.checkNumOfArgsNoMoreThan
|
public static void checkNumOfArgsNoMoreThan(Command cmd, CommandLine cl, int n) throws
InvalidArgumentException {
if (cl.getArgs().length > n) {
throw new InvalidArgumentException(ExceptionMessage.INVALID_ARGS_NUM_TOO_MANY
.getMessage(cmd.getCommandName(), n, cl.getArgs().length));
}
}
|
java
|
public static void checkNumOfArgsNoMoreThan(Command cmd, CommandLine cl, int n) throws
InvalidArgumentException {
if (cl.getArgs().length > n) {
throw new InvalidArgumentException(ExceptionMessage.INVALID_ARGS_NUM_TOO_MANY
.getMessage(cmd.getCommandName(), n, cl.getArgs().length));
}
}
|
[
"public",
"static",
"void",
"checkNumOfArgsNoMoreThan",
"(",
"Command",
"cmd",
",",
"CommandLine",
"cl",
",",
"int",
"n",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"cl",
".",
"getArgs",
"(",
")",
".",
"length",
">",
"n",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"ExceptionMessage",
".",
"INVALID_ARGS_NUM_TOO_MANY",
".",
"getMessage",
"(",
"cmd",
".",
"getCommandName",
"(",
")",
",",
"n",
",",
"cl",
".",
"getArgs",
"(",
")",
".",
"length",
")",
")",
";",
"}",
"}"
] |
Checks the number of non-option arguments is no more than n for command.
@param cmd command instance
@param cl parsed commandline arguments
@param n an integer
@throws InvalidArgumentException if the number is greater than n
|
[
"Checks",
"the",
"number",
"of",
"non",
"-",
"option",
"arguments",
"is",
"no",
"more",
"than",
"n",
"for",
"command",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/cli/CommandUtils.java#L100-L106
|
18,906
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java
|
CapacityCommand.run
|
public int run(CommandLine cl) throws IOException {
if (cl.hasOption(ReportCommand.HELP_OPTION_NAME)) {
System.out.println(getUsage());
return 0;
}
GetWorkerReportOptions options = getOptions(cl);
generateCapacityReport(options);
return 0;
}
|
java
|
public int run(CommandLine cl) throws IOException {
if (cl.hasOption(ReportCommand.HELP_OPTION_NAME)) {
System.out.println(getUsage());
return 0;
}
GetWorkerReportOptions options = getOptions(cl);
generateCapacityReport(options);
return 0;
}
|
[
"public",
"int",
"run",
"(",
"CommandLine",
"cl",
")",
"throws",
"IOException",
"{",
"if",
"(",
"cl",
".",
"hasOption",
"(",
"ReportCommand",
".",
"HELP_OPTION_NAME",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"getUsage",
"(",
")",
")",
";",
"return",
"0",
";",
"}",
"GetWorkerReportOptions",
"options",
"=",
"getOptions",
"(",
"cl",
")",
";",
"generateCapacityReport",
"(",
"options",
")",
";",
"return",
"0",
";",
"}"
] |
Runs report capacity command.
@param cl CommandLine to get client options
@return 0 on success, 1 otherwise
|
[
"Runs",
"report",
"capacity",
"command",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java#L73-L82
|
18,907
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java
|
CapacityCommand.generateCapacityReport
|
public void generateCapacityReport(GetWorkerReportOptions options) throws IOException {
List<WorkerInfo> workerInfoList = mBlockMasterClient.getWorkerReport(options);
if (workerInfoList.size() == 0) {
print("No workers found.");
return;
}
Collections.sort(workerInfoList, new WorkerInfo.LastContactSecComparator());
collectWorkerInfo(workerInfoList);
printAggregatedInfo(options);
printWorkerInfo(workerInfoList);
}
|
java
|
public void generateCapacityReport(GetWorkerReportOptions options) throws IOException {
List<WorkerInfo> workerInfoList = mBlockMasterClient.getWorkerReport(options);
if (workerInfoList.size() == 0) {
print("No workers found.");
return;
}
Collections.sort(workerInfoList, new WorkerInfo.LastContactSecComparator());
collectWorkerInfo(workerInfoList);
printAggregatedInfo(options);
printWorkerInfo(workerInfoList);
}
|
[
"public",
"void",
"generateCapacityReport",
"(",
"GetWorkerReportOptions",
"options",
")",
"throws",
"IOException",
"{",
"List",
"<",
"WorkerInfo",
">",
"workerInfoList",
"=",
"mBlockMasterClient",
".",
"getWorkerReport",
"(",
"options",
")",
";",
"if",
"(",
"workerInfoList",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"print",
"(",
"\"No workers found.\"",
")",
";",
"return",
";",
"}",
"Collections",
".",
"sort",
"(",
"workerInfoList",
",",
"new",
"WorkerInfo",
".",
"LastContactSecComparator",
"(",
")",
")",
";",
"collectWorkerInfo",
"(",
"workerInfoList",
")",
";",
"printAggregatedInfo",
"(",
"options",
")",
";",
"printWorkerInfo",
"(",
"workerInfoList",
")",
";",
"}"
] |
Generates capacity report.
@param options GetWorkerReportOptions to get worker report
|
[
"Generates",
"capacity",
"report",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java#L89-L100
|
18,908
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java
|
CapacityCommand.collectWorkerInfo
|
private void collectWorkerInfo(List<WorkerInfo> workerInfoList) {
initVariables();
for (WorkerInfo workerInfo : workerInfoList) {
long usedBytes = workerInfo.getUsedBytes();
long capacityBytes = workerInfo.getCapacityBytes();
mSumCapacityBytes += capacityBytes;
mSumUsedBytes += usedBytes;
String workerName = workerInfo.getAddress().getHost();
Map<String, Long> totalBytesOnTiers = workerInfo.getCapacityBytesOnTiers();
for (Map.Entry<String, Long> totalBytesTier : totalBytesOnTiers.entrySet()) {
String tier = totalBytesTier.getKey();
long value = totalBytesTier.getValue();
mSumCapacityBytesOnTierMap.put(tier,
value + mSumCapacityBytesOnTierMap.getOrDefault(tier, 0L));
Map<String, String> map = mCapacityTierInfoMap.getOrDefault(tier, new HashMap<>());
map.put(workerName, FormatUtils.getSizeFromBytes(value));
mCapacityTierInfoMap.put(tier, map);
}
Map<String, Long> usedBytesOnTiers = workerInfo.getUsedBytesOnTiers();
for (Map.Entry<String, Long> usedBytesTier: usedBytesOnTiers.entrySet()) {
String tier = usedBytesTier.getKey();
long value = usedBytesTier.getValue();
mSumUsedBytesOnTierMap.put(tier,
value + mSumUsedBytesOnTierMap.getOrDefault(tier, 0L));
Map<String, String> map = mUsedTierInfoMap.getOrDefault(tier, new HashMap<>());
map.put(workerName, FormatUtils.getSizeFromBytes(value));
mUsedTierInfoMap.put(tier, map);
}
}
}
|
java
|
private void collectWorkerInfo(List<WorkerInfo> workerInfoList) {
initVariables();
for (WorkerInfo workerInfo : workerInfoList) {
long usedBytes = workerInfo.getUsedBytes();
long capacityBytes = workerInfo.getCapacityBytes();
mSumCapacityBytes += capacityBytes;
mSumUsedBytes += usedBytes;
String workerName = workerInfo.getAddress().getHost();
Map<String, Long> totalBytesOnTiers = workerInfo.getCapacityBytesOnTiers();
for (Map.Entry<String, Long> totalBytesTier : totalBytesOnTiers.entrySet()) {
String tier = totalBytesTier.getKey();
long value = totalBytesTier.getValue();
mSumCapacityBytesOnTierMap.put(tier,
value + mSumCapacityBytesOnTierMap.getOrDefault(tier, 0L));
Map<String, String> map = mCapacityTierInfoMap.getOrDefault(tier, new HashMap<>());
map.put(workerName, FormatUtils.getSizeFromBytes(value));
mCapacityTierInfoMap.put(tier, map);
}
Map<String, Long> usedBytesOnTiers = workerInfo.getUsedBytesOnTiers();
for (Map.Entry<String, Long> usedBytesTier: usedBytesOnTiers.entrySet()) {
String tier = usedBytesTier.getKey();
long value = usedBytesTier.getValue();
mSumUsedBytesOnTierMap.put(tier,
value + mSumUsedBytesOnTierMap.getOrDefault(tier, 0L));
Map<String, String> map = mUsedTierInfoMap.getOrDefault(tier, new HashMap<>());
map.put(workerName, FormatUtils.getSizeFromBytes(value));
mUsedTierInfoMap.put(tier, map);
}
}
}
|
[
"private",
"void",
"collectWorkerInfo",
"(",
"List",
"<",
"WorkerInfo",
">",
"workerInfoList",
")",
"{",
"initVariables",
"(",
")",
";",
"for",
"(",
"WorkerInfo",
"workerInfo",
":",
"workerInfoList",
")",
"{",
"long",
"usedBytes",
"=",
"workerInfo",
".",
"getUsedBytes",
"(",
")",
";",
"long",
"capacityBytes",
"=",
"workerInfo",
".",
"getCapacityBytes",
"(",
")",
";",
"mSumCapacityBytes",
"+=",
"capacityBytes",
";",
"mSumUsedBytes",
"+=",
"usedBytes",
";",
"String",
"workerName",
"=",
"workerInfo",
".",
"getAddress",
"(",
")",
".",
"getHost",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Long",
">",
"totalBytesOnTiers",
"=",
"workerInfo",
".",
"getCapacityBytesOnTiers",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Long",
">",
"totalBytesTier",
":",
"totalBytesOnTiers",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"tier",
"=",
"totalBytesTier",
".",
"getKey",
"(",
")",
";",
"long",
"value",
"=",
"totalBytesTier",
".",
"getValue",
"(",
")",
";",
"mSumCapacityBytesOnTierMap",
".",
"put",
"(",
"tier",
",",
"value",
"+",
"mSumCapacityBytesOnTierMap",
".",
"getOrDefault",
"(",
"tier",
",",
"0L",
")",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"map",
"=",
"mCapacityTierInfoMap",
".",
"getOrDefault",
"(",
"tier",
",",
"new",
"HashMap",
"<>",
"(",
")",
")",
";",
"map",
".",
"put",
"(",
"workerName",
",",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"value",
")",
")",
";",
"mCapacityTierInfoMap",
".",
"put",
"(",
"tier",
",",
"map",
")",
";",
"}",
"Map",
"<",
"String",
",",
"Long",
">",
"usedBytesOnTiers",
"=",
"workerInfo",
".",
"getUsedBytesOnTiers",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Long",
">",
"usedBytesTier",
":",
"usedBytesOnTiers",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"tier",
"=",
"usedBytesTier",
".",
"getKey",
"(",
")",
";",
"long",
"value",
"=",
"usedBytesTier",
".",
"getValue",
"(",
")",
";",
"mSumUsedBytesOnTierMap",
".",
"put",
"(",
"tier",
",",
"value",
"+",
"mSumUsedBytesOnTierMap",
".",
"getOrDefault",
"(",
"tier",
",",
"0L",
")",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"map",
"=",
"mUsedTierInfoMap",
".",
"getOrDefault",
"(",
"tier",
",",
"new",
"HashMap",
"<>",
"(",
")",
")",
";",
"map",
".",
"put",
"(",
"workerName",
",",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"value",
")",
")",
";",
"mUsedTierInfoMap",
".",
"put",
"(",
"tier",
",",
"map",
")",
";",
"}",
"}",
"}"
] |
Collects worker capacity information.
@param workerInfoList the worker info list to collect info from
|
[
"Collects",
"worker",
"capacity",
"information",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java#L107-L141
|
18,909
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java
|
CapacityCommand.printAggregatedInfo
|
private void printAggregatedInfo(GetWorkerReportOptions options) {
mIndentationLevel = 0;
print(String.format("Capacity information for %s workers: ",
options.getWorkerRange().toString().toLowerCase()));
mIndentationLevel++;
print("Total Capacity: " + FormatUtils.getSizeFromBytes(mSumCapacityBytes));
mIndentationLevel++;
for (Map.Entry<String, Long> totalBytesTier : mSumCapacityBytesOnTierMap.entrySet()) {
long value = totalBytesTier.getValue();
print("Tier: " + totalBytesTier.getKey()
+ " Size: " + FormatUtils.getSizeFromBytes(value));
}
mIndentationLevel--;
print("Used Capacity: "
+ FormatUtils.getSizeFromBytes(mSumUsedBytes));
mIndentationLevel++;
for (Map.Entry<String, Long> usedBytesTier : mSumUsedBytesOnTierMap.entrySet()) {
long value = usedBytesTier.getValue();
print("Tier: " + usedBytesTier.getKey()
+ " Size: " + FormatUtils.getSizeFromBytes(value));
}
mIndentationLevel--;
if (mSumCapacityBytes != 0) {
int usedPercentage = (int) (100L * mSumUsedBytes / mSumCapacityBytes);
print(String.format("Used Percentage: " + "%s%%", usedPercentage));
print(String.format("Free Percentage: " + "%s%%", 100 - usedPercentage));
}
}
|
java
|
private void printAggregatedInfo(GetWorkerReportOptions options) {
mIndentationLevel = 0;
print(String.format("Capacity information for %s workers: ",
options.getWorkerRange().toString().toLowerCase()));
mIndentationLevel++;
print("Total Capacity: " + FormatUtils.getSizeFromBytes(mSumCapacityBytes));
mIndentationLevel++;
for (Map.Entry<String, Long> totalBytesTier : mSumCapacityBytesOnTierMap.entrySet()) {
long value = totalBytesTier.getValue();
print("Tier: " + totalBytesTier.getKey()
+ " Size: " + FormatUtils.getSizeFromBytes(value));
}
mIndentationLevel--;
print("Used Capacity: "
+ FormatUtils.getSizeFromBytes(mSumUsedBytes));
mIndentationLevel++;
for (Map.Entry<String, Long> usedBytesTier : mSumUsedBytesOnTierMap.entrySet()) {
long value = usedBytesTier.getValue();
print("Tier: " + usedBytesTier.getKey()
+ " Size: " + FormatUtils.getSizeFromBytes(value));
}
mIndentationLevel--;
if (mSumCapacityBytes != 0) {
int usedPercentage = (int) (100L * mSumUsedBytes / mSumCapacityBytes);
print(String.format("Used Percentage: " + "%s%%", usedPercentage));
print(String.format("Free Percentage: " + "%s%%", 100 - usedPercentage));
}
}
|
[
"private",
"void",
"printAggregatedInfo",
"(",
"GetWorkerReportOptions",
"options",
")",
"{",
"mIndentationLevel",
"=",
"0",
";",
"print",
"(",
"String",
".",
"format",
"(",
"\"Capacity information for %s workers: \"",
",",
"options",
".",
"getWorkerRange",
"(",
")",
".",
"toString",
"(",
")",
".",
"toLowerCase",
"(",
")",
")",
")",
";",
"mIndentationLevel",
"++",
";",
"print",
"(",
"\"Total Capacity: \"",
"+",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"mSumCapacityBytes",
")",
")",
";",
"mIndentationLevel",
"++",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Long",
">",
"totalBytesTier",
":",
"mSumCapacityBytesOnTierMap",
".",
"entrySet",
"(",
")",
")",
"{",
"long",
"value",
"=",
"totalBytesTier",
".",
"getValue",
"(",
")",
";",
"print",
"(",
"\"Tier: \"",
"+",
"totalBytesTier",
".",
"getKey",
"(",
")",
"+",
"\" Size: \"",
"+",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"value",
")",
")",
";",
"}",
"mIndentationLevel",
"--",
";",
"print",
"(",
"\"Used Capacity: \"",
"+",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"mSumUsedBytes",
")",
")",
";",
"mIndentationLevel",
"++",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Long",
">",
"usedBytesTier",
":",
"mSumUsedBytesOnTierMap",
".",
"entrySet",
"(",
")",
")",
"{",
"long",
"value",
"=",
"usedBytesTier",
".",
"getValue",
"(",
")",
";",
"print",
"(",
"\"Tier: \"",
"+",
"usedBytesTier",
".",
"getKey",
"(",
")",
"+",
"\" Size: \"",
"+",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"value",
")",
")",
";",
"}",
"mIndentationLevel",
"--",
";",
"if",
"(",
"mSumCapacityBytes",
"!=",
"0",
")",
"{",
"int",
"usedPercentage",
"=",
"(",
"int",
")",
"(",
"100L",
"*",
"mSumUsedBytes",
"/",
"mSumCapacityBytes",
")",
";",
"print",
"(",
"String",
".",
"format",
"(",
"\"Used Percentage: \"",
"+",
"\"%s%%\"",
",",
"usedPercentage",
")",
")",
";",
"print",
"(",
"String",
".",
"format",
"(",
"\"Free Percentage: \"",
"+",
"\"%s%%\"",
",",
"100",
"-",
"usedPercentage",
")",
")",
";",
"}",
"}"
] |
Prints aggregated worker capacity information.
@param options GetWorkerReportOptions to check if input is invalid
|
[
"Prints",
"aggregated",
"worker",
"capacity",
"information",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java#L148-L178
|
18,910
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java
|
CapacityCommand.printWorkerInfo
|
private void printWorkerInfo(List<WorkerInfo> workerInfoList) {
mIndentationLevel = 0;
if (mCapacityTierInfoMap.size() == 0) {
return;
} else if (mCapacityTierInfoMap.size() == 1) {
// Do not print Total value when only one tier exists
printShortWorkerInfo(workerInfoList);
return;
}
Set<String> tiers = mCapacityTierInfoMap.keySet();
String tiersInfo = String.format(Strings.repeat("%-14s", tiers.size()), tiers.toArray());
String longInfoFormat = getInfoFormat(workerInfoList, false);
print(String.format("%n" + longInfoFormat,
"Worker Name", "Last Heartbeat", "Storage", "Total", tiersInfo));
for (WorkerInfo info : workerInfoList) {
String workerName = info.getAddress().getHost();
long usedBytes = info.getUsedBytes();
long capacityBytes = info.getCapacityBytes();
String usedPercentageInfo = "";
if (capacityBytes != 0) {
int usedPercentage = (int) (100L * usedBytes / capacityBytes);
usedPercentageInfo = String.format(" (%s%%)", usedPercentage);
}
String capacityTierInfo = getWorkerFormattedTierValues(mCapacityTierInfoMap, workerName);
String usedTierInfo = getWorkerFormattedTierValues(mUsedTierInfoMap, workerName);
print(String.format(longInfoFormat, workerName, info.getLastContactSec(), "capacity",
FormatUtils.getSizeFromBytes(capacityBytes), capacityTierInfo));
print(String.format(longInfoFormat, "", "", "used",
FormatUtils.getSizeFromBytes(usedBytes) + usedPercentageInfo, usedTierInfo));
}
}
|
java
|
private void printWorkerInfo(List<WorkerInfo> workerInfoList) {
mIndentationLevel = 0;
if (mCapacityTierInfoMap.size() == 0) {
return;
} else if (mCapacityTierInfoMap.size() == 1) {
// Do not print Total value when only one tier exists
printShortWorkerInfo(workerInfoList);
return;
}
Set<String> tiers = mCapacityTierInfoMap.keySet();
String tiersInfo = String.format(Strings.repeat("%-14s", tiers.size()), tiers.toArray());
String longInfoFormat = getInfoFormat(workerInfoList, false);
print(String.format("%n" + longInfoFormat,
"Worker Name", "Last Heartbeat", "Storage", "Total", tiersInfo));
for (WorkerInfo info : workerInfoList) {
String workerName = info.getAddress().getHost();
long usedBytes = info.getUsedBytes();
long capacityBytes = info.getCapacityBytes();
String usedPercentageInfo = "";
if (capacityBytes != 0) {
int usedPercentage = (int) (100L * usedBytes / capacityBytes);
usedPercentageInfo = String.format(" (%s%%)", usedPercentage);
}
String capacityTierInfo = getWorkerFormattedTierValues(mCapacityTierInfoMap, workerName);
String usedTierInfo = getWorkerFormattedTierValues(mUsedTierInfoMap, workerName);
print(String.format(longInfoFormat, workerName, info.getLastContactSec(), "capacity",
FormatUtils.getSizeFromBytes(capacityBytes), capacityTierInfo));
print(String.format(longInfoFormat, "", "", "used",
FormatUtils.getSizeFromBytes(usedBytes) + usedPercentageInfo, usedTierInfo));
}
}
|
[
"private",
"void",
"printWorkerInfo",
"(",
"List",
"<",
"WorkerInfo",
">",
"workerInfoList",
")",
"{",
"mIndentationLevel",
"=",
"0",
";",
"if",
"(",
"mCapacityTierInfoMap",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"else",
"if",
"(",
"mCapacityTierInfoMap",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"// Do not print Total value when only one tier exists",
"printShortWorkerInfo",
"(",
"workerInfoList",
")",
";",
"return",
";",
"}",
"Set",
"<",
"String",
">",
"tiers",
"=",
"mCapacityTierInfoMap",
".",
"keySet",
"(",
")",
";",
"String",
"tiersInfo",
"=",
"String",
".",
"format",
"(",
"Strings",
".",
"repeat",
"(",
"\"%-14s\"",
",",
"tiers",
".",
"size",
"(",
")",
")",
",",
"tiers",
".",
"toArray",
"(",
")",
")",
";",
"String",
"longInfoFormat",
"=",
"getInfoFormat",
"(",
"workerInfoList",
",",
"false",
")",
";",
"print",
"(",
"String",
".",
"format",
"(",
"\"%n\"",
"+",
"longInfoFormat",
",",
"\"Worker Name\"",
",",
"\"Last Heartbeat\"",
",",
"\"Storage\"",
",",
"\"Total\"",
",",
"tiersInfo",
")",
")",
";",
"for",
"(",
"WorkerInfo",
"info",
":",
"workerInfoList",
")",
"{",
"String",
"workerName",
"=",
"info",
".",
"getAddress",
"(",
")",
".",
"getHost",
"(",
")",
";",
"long",
"usedBytes",
"=",
"info",
".",
"getUsedBytes",
"(",
")",
";",
"long",
"capacityBytes",
"=",
"info",
".",
"getCapacityBytes",
"(",
")",
";",
"String",
"usedPercentageInfo",
"=",
"\"\"",
";",
"if",
"(",
"capacityBytes",
"!=",
"0",
")",
"{",
"int",
"usedPercentage",
"=",
"(",
"int",
")",
"(",
"100L",
"*",
"usedBytes",
"/",
"capacityBytes",
")",
";",
"usedPercentageInfo",
"=",
"String",
".",
"format",
"(",
"\" (%s%%)\"",
",",
"usedPercentage",
")",
";",
"}",
"String",
"capacityTierInfo",
"=",
"getWorkerFormattedTierValues",
"(",
"mCapacityTierInfoMap",
",",
"workerName",
")",
";",
"String",
"usedTierInfo",
"=",
"getWorkerFormattedTierValues",
"(",
"mUsedTierInfoMap",
",",
"workerName",
")",
";",
"print",
"(",
"String",
".",
"format",
"(",
"longInfoFormat",
",",
"workerName",
",",
"info",
".",
"getLastContactSec",
"(",
")",
",",
"\"capacity\"",
",",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"capacityBytes",
")",
",",
"capacityTierInfo",
")",
")",
";",
"print",
"(",
"String",
".",
"format",
"(",
"longInfoFormat",
",",
"\"\"",
",",
"\"\"",
",",
"\"used\"",
",",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"usedBytes",
")",
"+",
"usedPercentageInfo",
",",
"usedTierInfo",
")",
")",
";",
"}",
"}"
] |
Prints worker capacity information.
@param workerInfoList the worker info list to get info from
|
[
"Prints",
"worker",
"capacity",
"information",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java#L185-L220
|
18,911
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java
|
CapacityCommand.printShortWorkerInfo
|
private void printShortWorkerInfo(List<WorkerInfo> workerInfoList) {
String tier = mCapacityTierInfoMap.firstKey();
String shortInfoFormat = getInfoFormat(workerInfoList, true);
print(String.format("%n" + shortInfoFormat,
"Worker Name", "Last Heartbeat", "Storage", tier));
for (WorkerInfo info : workerInfoList) {
long capacityBytes = info.getCapacityBytes();
long usedBytes = info.getUsedBytes();
String usedPercentageInfo = "";
if (capacityBytes != 0) {
int usedPercentage = (int) (100L * usedBytes / capacityBytes);
usedPercentageInfo = String.format(" (%s%%)", usedPercentage);
}
print(String.format(shortInfoFormat, info.getAddress().getHost(),
info.getLastContactSec(), "capacity", FormatUtils.getSizeFromBytes(capacityBytes)));
print(String.format(shortInfoFormat, "", "", "used",
FormatUtils.getSizeFromBytes(usedBytes) + usedPercentageInfo));
}
}
|
java
|
private void printShortWorkerInfo(List<WorkerInfo> workerInfoList) {
String tier = mCapacityTierInfoMap.firstKey();
String shortInfoFormat = getInfoFormat(workerInfoList, true);
print(String.format("%n" + shortInfoFormat,
"Worker Name", "Last Heartbeat", "Storage", tier));
for (WorkerInfo info : workerInfoList) {
long capacityBytes = info.getCapacityBytes();
long usedBytes = info.getUsedBytes();
String usedPercentageInfo = "";
if (capacityBytes != 0) {
int usedPercentage = (int) (100L * usedBytes / capacityBytes);
usedPercentageInfo = String.format(" (%s%%)", usedPercentage);
}
print(String.format(shortInfoFormat, info.getAddress().getHost(),
info.getLastContactSec(), "capacity", FormatUtils.getSizeFromBytes(capacityBytes)));
print(String.format(shortInfoFormat, "", "", "used",
FormatUtils.getSizeFromBytes(usedBytes) + usedPercentageInfo));
}
}
|
[
"private",
"void",
"printShortWorkerInfo",
"(",
"List",
"<",
"WorkerInfo",
">",
"workerInfoList",
")",
"{",
"String",
"tier",
"=",
"mCapacityTierInfoMap",
".",
"firstKey",
"(",
")",
";",
"String",
"shortInfoFormat",
"=",
"getInfoFormat",
"(",
"workerInfoList",
",",
"true",
")",
";",
"print",
"(",
"String",
".",
"format",
"(",
"\"%n\"",
"+",
"shortInfoFormat",
",",
"\"Worker Name\"",
",",
"\"Last Heartbeat\"",
",",
"\"Storage\"",
",",
"tier",
")",
")",
";",
"for",
"(",
"WorkerInfo",
"info",
":",
"workerInfoList",
")",
"{",
"long",
"capacityBytes",
"=",
"info",
".",
"getCapacityBytes",
"(",
")",
";",
"long",
"usedBytes",
"=",
"info",
".",
"getUsedBytes",
"(",
")",
";",
"String",
"usedPercentageInfo",
"=",
"\"\"",
";",
"if",
"(",
"capacityBytes",
"!=",
"0",
")",
"{",
"int",
"usedPercentage",
"=",
"(",
"int",
")",
"(",
"100L",
"*",
"usedBytes",
"/",
"capacityBytes",
")",
";",
"usedPercentageInfo",
"=",
"String",
".",
"format",
"(",
"\" (%s%%)\"",
",",
"usedPercentage",
")",
";",
"}",
"print",
"(",
"String",
".",
"format",
"(",
"shortInfoFormat",
",",
"info",
".",
"getAddress",
"(",
")",
".",
"getHost",
"(",
")",
",",
"info",
".",
"getLastContactSec",
"(",
")",
",",
"\"capacity\"",
",",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"capacityBytes",
")",
")",
")",
";",
"print",
"(",
"String",
".",
"format",
"(",
"shortInfoFormat",
",",
"\"\"",
",",
"\"\"",
",",
"\"used\"",
",",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"usedBytes",
")",
"+",
"usedPercentageInfo",
")",
")",
";",
"}",
"}"
] |
Prints worker information when only one tier exists.
@param workerInfoList the worker info list to get info from
|
[
"Prints",
"worker",
"information",
"when",
"only",
"one",
"tier",
"exists",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java#L227-L247
|
18,912
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java
|
CapacityCommand.getInfoFormat
|
private String getInfoFormat(List<WorkerInfo> workerInfoList, boolean isShort) {
int maxWorkerNameLength = workerInfoList.stream().map(w -> w.getAddress().getHost().length())
.max(Comparator.comparing(Integer::intValue)).get();
int firstIndent = 16;
if (firstIndent <= maxWorkerNameLength) {
// extend first indent according to the longest worker name by default 5
firstIndent = maxWorkerNameLength + 5;
}
if (isShort) {
return "%-" + firstIndent + "s %-16s %-13s %s";
}
return "%-" + firstIndent + "s %-16s %-13s %-16s %s";
}
|
java
|
private String getInfoFormat(List<WorkerInfo> workerInfoList, boolean isShort) {
int maxWorkerNameLength = workerInfoList.stream().map(w -> w.getAddress().getHost().length())
.max(Comparator.comparing(Integer::intValue)).get();
int firstIndent = 16;
if (firstIndent <= maxWorkerNameLength) {
// extend first indent according to the longest worker name by default 5
firstIndent = maxWorkerNameLength + 5;
}
if (isShort) {
return "%-" + firstIndent + "s %-16s %-13s %s";
}
return "%-" + firstIndent + "s %-16s %-13s %-16s %s";
}
|
[
"private",
"String",
"getInfoFormat",
"(",
"List",
"<",
"WorkerInfo",
">",
"workerInfoList",
",",
"boolean",
"isShort",
")",
"{",
"int",
"maxWorkerNameLength",
"=",
"workerInfoList",
".",
"stream",
"(",
")",
".",
"map",
"(",
"w",
"->",
"w",
".",
"getAddress",
"(",
")",
".",
"getHost",
"(",
")",
".",
"length",
"(",
")",
")",
".",
"max",
"(",
"Comparator",
".",
"comparing",
"(",
"Integer",
"::",
"intValue",
")",
")",
".",
"get",
"(",
")",
";",
"int",
"firstIndent",
"=",
"16",
";",
"if",
"(",
"firstIndent",
"<=",
"maxWorkerNameLength",
")",
"{",
"// extend first indent according to the longest worker name by default 5",
"firstIndent",
"=",
"maxWorkerNameLength",
"+",
"5",
";",
"}",
"if",
"(",
"isShort",
")",
"{",
"return",
"\"%-\"",
"+",
"firstIndent",
"+",
"\"s %-16s %-13s %s\"",
";",
"}",
"return",
"\"%-\"",
"+",
"firstIndent",
"+",
"\"s %-16s %-13s %-16s %s\"",
";",
"}"
] |
Gets the info format according to the longest worker name.
@param workerInfoList the worker info list to get info from
@param isShort whether exists only one tier
@return the info format for printing long/short worker info
|
[
"Gets",
"the",
"info",
"format",
"according",
"to",
"the",
"longest",
"worker",
"name",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java#L255-L267
|
18,913
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java
|
CapacityCommand.getOptions
|
private GetWorkerReportOptions getOptions(CommandLine cl) throws IOException {
if (cl.getOptions().length > 1) {
System.out.println(getUsage());
throw new InvalidArgumentException("Too many arguments passed in.");
}
GetWorkerReportOptions workerOptions = GetWorkerReportOptions.defaults();
Set<WorkerInfoField> fieldRange = new HashSet<>(Arrays.asList(WorkerInfoField.ADDRESS,
WorkerInfoField.WORKER_CAPACITY_BYTES, WorkerInfoField.WORKER_CAPACITY_BYTES_ON_TIERS,
WorkerInfoField.LAST_CONTACT_SEC, WorkerInfoField.WORKER_USED_BYTES,
WorkerInfoField.WORKER_USED_BYTES_ON_TIERS));
workerOptions.setFieldRange(fieldRange);
if (cl.hasOption(ReportCommand.LIVE_OPTION_NAME)) {
workerOptions.setWorkerRange(WorkerRange.LIVE);
} else if (cl.hasOption(ReportCommand.LOST_OPTION_NAME)) {
workerOptions.setWorkerRange(WorkerRange.LOST);
} else if (cl.hasOption(ReportCommand.SPECIFIED_OPTION_NAME)) {
workerOptions.setWorkerRange(WorkerRange.SPECIFIED);
String addressString = cl.getOptionValue(ReportCommand.SPECIFIED_OPTION_NAME);
String[] addressArray = addressString.split(",");
// Addresses in GetWorkerReportOptions is only used when WorkerRange is SPECIFIED
workerOptions.setAddresses(new HashSet<>(Arrays.asList(addressArray)));
}
return workerOptions;
}
|
java
|
private GetWorkerReportOptions getOptions(CommandLine cl) throws IOException {
if (cl.getOptions().length > 1) {
System.out.println(getUsage());
throw new InvalidArgumentException("Too many arguments passed in.");
}
GetWorkerReportOptions workerOptions = GetWorkerReportOptions.defaults();
Set<WorkerInfoField> fieldRange = new HashSet<>(Arrays.asList(WorkerInfoField.ADDRESS,
WorkerInfoField.WORKER_CAPACITY_BYTES, WorkerInfoField.WORKER_CAPACITY_BYTES_ON_TIERS,
WorkerInfoField.LAST_CONTACT_SEC, WorkerInfoField.WORKER_USED_BYTES,
WorkerInfoField.WORKER_USED_BYTES_ON_TIERS));
workerOptions.setFieldRange(fieldRange);
if (cl.hasOption(ReportCommand.LIVE_OPTION_NAME)) {
workerOptions.setWorkerRange(WorkerRange.LIVE);
} else if (cl.hasOption(ReportCommand.LOST_OPTION_NAME)) {
workerOptions.setWorkerRange(WorkerRange.LOST);
} else if (cl.hasOption(ReportCommand.SPECIFIED_OPTION_NAME)) {
workerOptions.setWorkerRange(WorkerRange.SPECIFIED);
String addressString = cl.getOptionValue(ReportCommand.SPECIFIED_OPTION_NAME);
String[] addressArray = addressString.split(",");
// Addresses in GetWorkerReportOptions is only used when WorkerRange is SPECIFIED
workerOptions.setAddresses(new HashSet<>(Arrays.asList(addressArray)));
}
return workerOptions;
}
|
[
"private",
"GetWorkerReportOptions",
"getOptions",
"(",
"CommandLine",
"cl",
")",
"throws",
"IOException",
"{",
"if",
"(",
"cl",
".",
"getOptions",
"(",
")",
".",
"length",
">",
"1",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"getUsage",
"(",
")",
")",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Too many arguments passed in.\"",
")",
";",
"}",
"GetWorkerReportOptions",
"workerOptions",
"=",
"GetWorkerReportOptions",
".",
"defaults",
"(",
")",
";",
"Set",
"<",
"WorkerInfoField",
">",
"fieldRange",
"=",
"new",
"HashSet",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"WorkerInfoField",
".",
"ADDRESS",
",",
"WorkerInfoField",
".",
"WORKER_CAPACITY_BYTES",
",",
"WorkerInfoField",
".",
"WORKER_CAPACITY_BYTES_ON_TIERS",
",",
"WorkerInfoField",
".",
"LAST_CONTACT_SEC",
",",
"WorkerInfoField",
".",
"WORKER_USED_BYTES",
",",
"WorkerInfoField",
".",
"WORKER_USED_BYTES_ON_TIERS",
")",
")",
";",
"workerOptions",
".",
"setFieldRange",
"(",
"fieldRange",
")",
";",
"if",
"(",
"cl",
".",
"hasOption",
"(",
"ReportCommand",
".",
"LIVE_OPTION_NAME",
")",
")",
"{",
"workerOptions",
".",
"setWorkerRange",
"(",
"WorkerRange",
".",
"LIVE",
")",
";",
"}",
"else",
"if",
"(",
"cl",
".",
"hasOption",
"(",
"ReportCommand",
".",
"LOST_OPTION_NAME",
")",
")",
"{",
"workerOptions",
".",
"setWorkerRange",
"(",
"WorkerRange",
".",
"LOST",
")",
";",
"}",
"else",
"if",
"(",
"cl",
".",
"hasOption",
"(",
"ReportCommand",
".",
"SPECIFIED_OPTION_NAME",
")",
")",
"{",
"workerOptions",
".",
"setWorkerRange",
"(",
"WorkerRange",
".",
"SPECIFIED",
")",
";",
"String",
"addressString",
"=",
"cl",
".",
"getOptionValue",
"(",
"ReportCommand",
".",
"SPECIFIED_OPTION_NAME",
")",
";",
"String",
"[",
"]",
"addressArray",
"=",
"addressString",
".",
"split",
"(",
"\",\"",
")",
";",
"// Addresses in GetWorkerReportOptions is only used when WorkerRange is SPECIFIED",
"workerOptions",
".",
"setAddresses",
"(",
"new",
"HashSet",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"addressArray",
")",
")",
")",
";",
"}",
"return",
"workerOptions",
";",
"}"
] |
Gets the worker info options.
@param cl CommandLine that contains the client options
@return GetWorkerReportOptions to get worker information
|
[
"Gets",
"the",
"worker",
"info",
"options",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java#L275-L300
|
18,914
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java
|
CapacityCommand.getWorkerFormattedTierValues
|
private static String getWorkerFormattedTierValues(Map<String, Map<String, String>> map,
String workerName) {
return map.values().stream().map((tierMap)
-> (String.format("%-14s", tierMap.getOrDefault(workerName, "-"))))
.collect(Collectors.joining(""));
}
|
java
|
private static String getWorkerFormattedTierValues(Map<String, Map<String, String>> map,
String workerName) {
return map.values().stream().map((tierMap)
-> (String.format("%-14s", tierMap.getOrDefault(workerName, "-"))))
.collect(Collectors.joining(""));
}
|
[
"private",
"static",
"String",
"getWorkerFormattedTierValues",
"(",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"map",
",",
"String",
"workerName",
")",
"{",
"return",
"map",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"(",
"tierMap",
")",
"-",
">",
"(",
"String",
".",
"format",
"(",
"\"%-14s\"",
",",
"tierMap",
".",
"getOrDefault",
"(",
"workerName",
",",
"\"-\"",
")",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\"\"",
")",
")",
";",
"}"
] |
Gets the formatted tier values of a worker.
@param map the map to get worker tier values from
@param workerName name of the worker
@return the formatted tier values of the input worker name
|
[
"Gets",
"the",
"formatted",
"tier",
"values",
"of",
"a",
"worker",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java#L309-L314
|
18,915
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java
|
CapacityCommand.initVariables
|
private void initVariables() {
mSumCapacityBytes = 0;
mSumUsedBytes = 0;
mSumCapacityBytesOnTierMap = new TreeMap<>(FileSystemAdminShellUtils::compareTierNames);
mSumUsedBytesOnTierMap = new TreeMap<>(FileSystemAdminShellUtils::compareTierNames);
// TierInfoMap is of form Map<Tier_Name, Map<Worker_Name, Worker_Tier_Value>>
mCapacityTierInfoMap = new TreeMap<>(FileSystemAdminShellUtils::compareTierNames);
mUsedTierInfoMap = new TreeMap<>(FileSystemAdminShellUtils::compareTierNames);
}
|
java
|
private void initVariables() {
mSumCapacityBytes = 0;
mSumUsedBytes = 0;
mSumCapacityBytesOnTierMap = new TreeMap<>(FileSystemAdminShellUtils::compareTierNames);
mSumUsedBytesOnTierMap = new TreeMap<>(FileSystemAdminShellUtils::compareTierNames);
// TierInfoMap is of form Map<Tier_Name, Map<Worker_Name, Worker_Tier_Value>>
mCapacityTierInfoMap = new TreeMap<>(FileSystemAdminShellUtils::compareTierNames);
mUsedTierInfoMap = new TreeMap<>(FileSystemAdminShellUtils::compareTierNames);
}
|
[
"private",
"void",
"initVariables",
"(",
")",
"{",
"mSumCapacityBytes",
"=",
"0",
";",
"mSumUsedBytes",
"=",
"0",
";",
"mSumCapacityBytesOnTierMap",
"=",
"new",
"TreeMap",
"<>",
"(",
"FileSystemAdminShellUtils",
"::",
"compareTierNames",
")",
";",
"mSumUsedBytesOnTierMap",
"=",
"new",
"TreeMap",
"<>",
"(",
"FileSystemAdminShellUtils",
"::",
"compareTierNames",
")",
";",
"// TierInfoMap is of form Map<Tier_Name, Map<Worker_Name, Worker_Tier_Value>>",
"mCapacityTierInfoMap",
"=",
"new",
"TreeMap",
"<>",
"(",
"FileSystemAdminShellUtils",
"::",
"compareTierNames",
")",
";",
"mUsedTierInfoMap",
"=",
"new",
"TreeMap",
"<>",
"(",
"FileSystemAdminShellUtils",
"::",
"compareTierNames",
")",
";",
"}"
] |
Initializes member variables used to collect worker info.
|
[
"Initializes",
"member",
"variables",
"used",
"to",
"collect",
"worker",
"info",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java#L319-L328
|
18,916
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java
|
CapacityCommand.print
|
private void print(String text) {
String indent = Strings.repeat(" ", mIndentationLevel * INDENT_SIZE);
mPrintStream.println(indent + text);
}
|
java
|
private void print(String text) {
String indent = Strings.repeat(" ", mIndentationLevel * INDENT_SIZE);
mPrintStream.println(indent + text);
}
|
[
"private",
"void",
"print",
"(",
"String",
"text",
")",
"{",
"String",
"indent",
"=",
"Strings",
".",
"repeat",
"(",
"\" \"",
",",
"mIndentationLevel",
"*",
"INDENT_SIZE",
")",
";",
"mPrintStream",
".",
"println",
"(",
"indent",
"+",
"text",
")",
";",
"}"
] |
Prints indented information.
@param text information to print
|
[
"Prints",
"indented",
"information",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/CapacityCommand.java#L335-L338
|
18,917
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/conf/PropertyKey.java
|
PropertyKey.register
|
@VisibleForTesting
public static boolean register(PropertyKey key) {
String name = key.getName();
String[] aliases = key.getAliases();
if (DEFAULT_KEYS_MAP.containsKey(name)) {
if (DEFAULT_KEYS_MAP.get(name).isBuiltIn() || !key.isBuiltIn()) {
return false;
}
}
DEFAULT_KEYS_MAP.put(name, key);
if (aliases != null) {
for (String alias : aliases) {
DEFAULT_ALIAS_MAP.put(alias, key);
}
}
return true;
}
|
java
|
@VisibleForTesting
public static boolean register(PropertyKey key) {
String name = key.getName();
String[] aliases = key.getAliases();
if (DEFAULT_KEYS_MAP.containsKey(name)) {
if (DEFAULT_KEYS_MAP.get(name).isBuiltIn() || !key.isBuiltIn()) {
return false;
}
}
DEFAULT_KEYS_MAP.put(name, key);
if (aliases != null) {
for (String alias : aliases) {
DEFAULT_ALIAS_MAP.put(alias, key);
}
}
return true;
}
|
[
"@",
"VisibleForTesting",
"public",
"static",
"boolean",
"register",
"(",
"PropertyKey",
"key",
")",
"{",
"String",
"name",
"=",
"key",
".",
"getName",
"(",
")",
";",
"String",
"[",
"]",
"aliases",
"=",
"key",
".",
"getAliases",
"(",
")",
";",
"if",
"(",
"DEFAULT_KEYS_MAP",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"if",
"(",
"DEFAULT_KEYS_MAP",
".",
"get",
"(",
"name",
")",
".",
"isBuiltIn",
"(",
")",
"||",
"!",
"key",
".",
"isBuiltIn",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"DEFAULT_KEYS_MAP",
".",
"put",
"(",
"name",
",",
"key",
")",
";",
"if",
"(",
"aliases",
"!=",
"null",
")",
"{",
"for",
"(",
"String",
"alias",
":",
"aliases",
")",
"{",
"DEFAULT_ALIAS_MAP",
".",
"put",
"(",
"alias",
",",
"key",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Registers the given key to the global key map.
@param key th property
@return whether the property key is successfully registered
|
[
"Registers",
"the",
"given",
"key",
"to",
"the",
"global",
"key",
"map",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/conf/PropertyKey.java#L4635-L4651
|
18,918
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/conf/PropertyKey.java
|
PropertyKey.unregister
|
@VisibleForTesting
public static void unregister(PropertyKey key) {
String name = key.getName();
DEFAULT_KEYS_MAP.remove(name);
DEFAULT_ALIAS_MAP.remove(name);
}
|
java
|
@VisibleForTesting
public static void unregister(PropertyKey key) {
String name = key.getName();
DEFAULT_KEYS_MAP.remove(name);
DEFAULT_ALIAS_MAP.remove(name);
}
|
[
"@",
"VisibleForTesting",
"public",
"static",
"void",
"unregister",
"(",
"PropertyKey",
"key",
")",
"{",
"String",
"name",
"=",
"key",
".",
"getName",
"(",
")",
";",
"DEFAULT_KEYS_MAP",
".",
"remove",
"(",
"name",
")",
";",
"DEFAULT_ALIAS_MAP",
".",
"remove",
"(",
"name",
")",
";",
"}"
] |
Unregisters the given key from the global key map.
@param key the property to unregister
|
[
"Unregisters",
"the",
"given",
"key",
"from",
"the",
"global",
"key",
"map",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/conf/PropertyKey.java#L4658-L4663
|
18,919
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/stream/BlockOutStream.java
|
BlockOutStream.createReplicatedBlockOutStream
|
public static BlockOutStream createReplicatedBlockOutStream(FileSystemContext context,
long blockId, long blockSize, java.util.List<WorkerNetAddress> workerNetAddresses,
OutStreamOptions options) throws IOException {
List<DataWriter> dataWriters = new ArrayList<>();
for (WorkerNetAddress address: workerNetAddresses) {
DataWriter dataWriter =
DataWriter.Factory.create(context, blockId, blockSize, address, options);
dataWriters.add(dataWriter);
}
return new BlockOutStream(dataWriters, blockSize, workerNetAddresses);
}
|
java
|
public static BlockOutStream createReplicatedBlockOutStream(FileSystemContext context,
long blockId, long blockSize, java.util.List<WorkerNetAddress> workerNetAddresses,
OutStreamOptions options) throws IOException {
List<DataWriter> dataWriters = new ArrayList<>();
for (WorkerNetAddress address: workerNetAddresses) {
DataWriter dataWriter =
DataWriter.Factory.create(context, blockId, blockSize, address, options);
dataWriters.add(dataWriter);
}
return new BlockOutStream(dataWriters, blockSize, workerNetAddresses);
}
|
[
"public",
"static",
"BlockOutStream",
"createReplicatedBlockOutStream",
"(",
"FileSystemContext",
"context",
",",
"long",
"blockId",
",",
"long",
"blockSize",
",",
"java",
".",
"util",
".",
"List",
"<",
"WorkerNetAddress",
">",
"workerNetAddresses",
",",
"OutStreamOptions",
"options",
")",
"throws",
"IOException",
"{",
"List",
"<",
"DataWriter",
">",
"dataWriters",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"WorkerNetAddress",
"address",
":",
"workerNetAddresses",
")",
"{",
"DataWriter",
"dataWriter",
"=",
"DataWriter",
".",
"Factory",
".",
"create",
"(",
"context",
",",
"blockId",
",",
"blockSize",
",",
"address",
",",
"options",
")",
";",
"dataWriters",
".",
"add",
"(",
"dataWriter",
")",
";",
"}",
"return",
"new",
"BlockOutStream",
"(",
"dataWriters",
",",
"blockSize",
",",
"workerNetAddresses",
")",
";",
"}"
] |
Creates a new remote block output stream.
@param context the file system context
@param blockId the block id
@param blockSize the block size
@param workerNetAddresses the worker network addresses
@param options the options
@return the {@link BlockOutStream} instance created
|
[
"Creates",
"a",
"new",
"remote",
"block",
"output",
"stream",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/stream/BlockOutStream.java#L108-L118
|
18,920
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/stream/BlockOutStream.java
|
BlockOutStream.write
|
public void write(io.netty.buffer.ByteBuf buf) throws IOException {
write(buf, 0, buf.readableBytes());
}
|
java
|
public void write(io.netty.buffer.ByteBuf buf) throws IOException {
write(buf, 0, buf.readableBytes());
}
|
[
"public",
"void",
"write",
"(",
"io",
".",
"netty",
".",
"buffer",
".",
"ByteBuf",
"buf",
")",
"throws",
"IOException",
"{",
"write",
"(",
"buf",
",",
"0",
",",
"buf",
".",
"readableBytes",
"(",
")",
")",
";",
"}"
] |
Writes the data in the specified byte buf to this output stream.
@param buf the buffer
@throws IOException
|
[
"Writes",
"the",
"data",
"in",
"the",
"specified",
"byte",
"buf",
"to",
"this",
"output",
"stream",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/stream/BlockOutStream.java#L173-L175
|
18,921
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/stream/BlockOutStream.java
|
BlockOutStream.write
|
public void write(io.netty.buffer.ByteBuf buf, int off, int len) throws IOException {
if (len == 0) {
return;
}
while (len > 0) {
updateCurrentChunk(false);
int toWrite = Math.min(len, mCurrentChunk.writableBytes());
mCurrentChunk.writeBytes(buf, off, toWrite);
off += toWrite;
len -= toWrite;
}
updateCurrentChunk(false);
}
|
java
|
public void write(io.netty.buffer.ByteBuf buf, int off, int len) throws IOException {
if (len == 0) {
return;
}
while (len > 0) {
updateCurrentChunk(false);
int toWrite = Math.min(len, mCurrentChunk.writableBytes());
mCurrentChunk.writeBytes(buf, off, toWrite);
off += toWrite;
len -= toWrite;
}
updateCurrentChunk(false);
}
|
[
"public",
"void",
"write",
"(",
"io",
".",
"netty",
".",
"buffer",
".",
"ByteBuf",
"buf",
",",
"int",
"off",
",",
"int",
"len",
")",
"throws",
"IOException",
"{",
"if",
"(",
"len",
"==",
"0",
")",
"{",
"return",
";",
"}",
"while",
"(",
"len",
">",
"0",
")",
"{",
"updateCurrentChunk",
"(",
"false",
")",
";",
"int",
"toWrite",
"=",
"Math",
".",
"min",
"(",
"len",
",",
"mCurrentChunk",
".",
"writableBytes",
"(",
")",
")",
";",
"mCurrentChunk",
".",
"writeBytes",
"(",
"buf",
",",
"off",
",",
"toWrite",
")",
";",
"off",
"+=",
"toWrite",
";",
"len",
"-=",
"toWrite",
";",
"}",
"updateCurrentChunk",
"(",
"false",
")",
";",
"}"
] |
Writes len bytes from the specified byte buf starting at offset off to this output stream.
@param buf the buffer
@param off the offset
@param len the length
|
[
"Writes",
"len",
"bytes",
"from",
"the",
"specified",
"byte",
"buf",
"starting",
"at",
"offset",
"off",
"to",
"this",
"output",
"stream",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/stream/BlockOutStream.java#L184-L197
|
18,922
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/stream/BlockOutStream.java
|
BlockOutStream.updateCurrentChunk
|
private void updateCurrentChunk(boolean lastChunk) throws IOException {
// Early return for the most common case.
if (mCurrentChunk != null && mCurrentChunk.writableBytes() > 0 && !lastChunk) {
return;
}
if (mCurrentChunk == null) {
if (!lastChunk) {
mCurrentChunk = allocateBuffer();
}
return;
}
if (mCurrentChunk.writableBytes() == 0 || lastChunk) {
try {
if (mCurrentChunk.readableBytes() > 0) {
for (DataWriter dataWriter : mDataWriters) {
mCurrentChunk.retain();
dataWriter.writeChunk(mCurrentChunk.duplicate());
}
} else {
Preconditions.checkState(lastChunk);
}
} finally {
// If the packet has bytes to read, we increment its refcount explicitly for every packet
// writer. So we need to release here. If the packet has no bytes to read, then it has
// to be the last packet. It needs to be released as well.
mCurrentChunk.release();
mCurrentChunk = null;
}
}
if (!lastChunk) {
mCurrentChunk = allocateBuffer();
}
}
|
java
|
private void updateCurrentChunk(boolean lastChunk) throws IOException {
// Early return for the most common case.
if (mCurrentChunk != null && mCurrentChunk.writableBytes() > 0 && !lastChunk) {
return;
}
if (mCurrentChunk == null) {
if (!lastChunk) {
mCurrentChunk = allocateBuffer();
}
return;
}
if (mCurrentChunk.writableBytes() == 0 || lastChunk) {
try {
if (mCurrentChunk.readableBytes() > 0) {
for (DataWriter dataWriter : mDataWriters) {
mCurrentChunk.retain();
dataWriter.writeChunk(mCurrentChunk.duplicate());
}
} else {
Preconditions.checkState(lastChunk);
}
} finally {
// If the packet has bytes to read, we increment its refcount explicitly for every packet
// writer. So we need to release here. If the packet has no bytes to read, then it has
// to be the last packet. It needs to be released as well.
mCurrentChunk.release();
mCurrentChunk = null;
}
}
if (!lastChunk) {
mCurrentChunk = allocateBuffer();
}
}
|
[
"private",
"void",
"updateCurrentChunk",
"(",
"boolean",
"lastChunk",
")",
"throws",
"IOException",
"{",
"// Early return for the most common case.",
"if",
"(",
"mCurrentChunk",
"!=",
"null",
"&&",
"mCurrentChunk",
".",
"writableBytes",
"(",
")",
">",
"0",
"&&",
"!",
"lastChunk",
")",
"{",
"return",
";",
"}",
"if",
"(",
"mCurrentChunk",
"==",
"null",
")",
"{",
"if",
"(",
"!",
"lastChunk",
")",
"{",
"mCurrentChunk",
"=",
"allocateBuffer",
"(",
")",
";",
"}",
"return",
";",
"}",
"if",
"(",
"mCurrentChunk",
".",
"writableBytes",
"(",
")",
"==",
"0",
"||",
"lastChunk",
")",
"{",
"try",
"{",
"if",
"(",
"mCurrentChunk",
".",
"readableBytes",
"(",
")",
">",
"0",
")",
"{",
"for",
"(",
"DataWriter",
"dataWriter",
":",
"mDataWriters",
")",
"{",
"mCurrentChunk",
".",
"retain",
"(",
")",
";",
"dataWriter",
".",
"writeChunk",
"(",
"mCurrentChunk",
".",
"duplicate",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"Preconditions",
".",
"checkState",
"(",
"lastChunk",
")",
";",
"}",
"}",
"finally",
"{",
"// If the packet has bytes to read, we increment its refcount explicitly for every packet",
"// writer. So we need to release here. If the packet has no bytes to read, then it has",
"// to be the last packet. It needs to be released as well.",
"mCurrentChunk",
".",
"release",
"(",
")",
";",
"mCurrentChunk",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"!",
"lastChunk",
")",
"{",
"mCurrentChunk",
"=",
"allocateBuffer",
"(",
")",
";",
"}",
"}"
] |
Updates the current chunk.
@param lastChunk if the current packet is the last packet
|
[
"Updates",
"the",
"current",
"chunk",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/stream/BlockOutStream.java#L261-L295
|
18,923
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/MutableInode.java
|
MutableInode.removeAcl
|
public T removeAcl(List<AclEntry> entries) {
for (AclEntry entry : entries) {
if (entry.isDefault()) {
AccessControlList defaultAcl = getDefaultACL();
defaultAcl.removeEntry(entry);
} else {
mAcl.removeEntry(entry);
}
}
updateMask(entries);
return getThis();
}
|
java
|
public T removeAcl(List<AclEntry> entries) {
for (AclEntry entry : entries) {
if (entry.isDefault()) {
AccessControlList defaultAcl = getDefaultACL();
defaultAcl.removeEntry(entry);
} else {
mAcl.removeEntry(entry);
}
}
updateMask(entries);
return getThis();
}
|
[
"public",
"T",
"removeAcl",
"(",
"List",
"<",
"AclEntry",
">",
"entries",
")",
"{",
"for",
"(",
"AclEntry",
"entry",
":",
"entries",
")",
"{",
"if",
"(",
"entry",
".",
"isDefault",
"(",
")",
")",
"{",
"AccessControlList",
"defaultAcl",
"=",
"getDefaultACL",
"(",
")",
";",
"defaultAcl",
".",
"removeEntry",
"(",
"entry",
")",
";",
"}",
"else",
"{",
"mAcl",
".",
"removeEntry",
"(",
"entry",
")",
";",
"}",
"}",
"updateMask",
"(",
"entries",
")",
";",
"return",
"getThis",
"(",
")",
";",
"}"
] |
Removes ACL entries.
@param entries the ACL entries to remove
@return the updated object
|
[
"Removes",
"ACL",
"entries",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/MutableInode.java#L181-L192
|
18,924
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/MutableInode.java
|
MutableInode.replaceAcl
|
public T replaceAcl(List<AclEntry> entries) {
boolean clearACL = false;
for (AclEntry entry : entries) {
/**
* if we are only setting default ACLs, we do not need to clear access ACL entries
* observed same behavior on linux
*/
if (!entry.isDefault()) {
clearACL = true;
}
}
if (clearACL) {
mAcl.clearEntries();
}
return setAcl(entries);
}
|
java
|
public T replaceAcl(List<AclEntry> entries) {
boolean clearACL = false;
for (AclEntry entry : entries) {
/**
* if we are only setting default ACLs, we do not need to clear access ACL entries
* observed same behavior on linux
*/
if (!entry.isDefault()) {
clearACL = true;
}
}
if (clearACL) {
mAcl.clearEntries();
}
return setAcl(entries);
}
|
[
"public",
"T",
"replaceAcl",
"(",
"List",
"<",
"AclEntry",
">",
"entries",
")",
"{",
"boolean",
"clearACL",
"=",
"false",
";",
"for",
"(",
"AclEntry",
"entry",
":",
"entries",
")",
"{",
"/**\n * if we are only setting default ACLs, we do not need to clear access ACL entries\n * observed same behavior on linux\n */",
"if",
"(",
"!",
"entry",
".",
"isDefault",
"(",
")",
")",
"{",
"clearACL",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"clearACL",
")",
"{",
"mAcl",
".",
"clearEntries",
"(",
")",
";",
"}",
"return",
"setAcl",
"(",
"entries",
")",
";",
"}"
] |
Replaces all existing ACL entries with a new list of entries.
@param entries the new list of ACL entries
@return the updated object
|
[
"Replaces",
"all",
"existing",
"ACL",
"entries",
"with",
"a",
"new",
"list",
"of",
"entries",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/MutableInode.java#L200-L215
|
18,925
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/MutableInode.java
|
MutableInode.updateMask
|
public T updateMask(List<AclEntry> entries) {
boolean needToUpdateACL = false;
boolean needToUpdateDefaultACL = false;
for (AclEntry entry : entries) {
if (entry.getType().equals(AclEntryType.NAMED_USER)
|| entry.getType().equals(AclEntryType.NAMED_GROUP)
|| entry.getType().equals(AclEntryType.OWNING_GROUP)) {
if (entry.isDefault()) {
needToUpdateDefaultACL = true;
} else {
needToUpdateACL = true;
}
}
if (entry.getType().equals(AclEntryType.MASK)) {
// If mask is explicitly set or removed then we don't need to update the mask
return getThis();
}
}
if (needToUpdateACL) {
mAcl.updateMask();
}
if (needToUpdateDefaultACL) {
getDefaultACL().updateMask();
}
return getThis();
}
|
java
|
public T updateMask(List<AclEntry> entries) {
boolean needToUpdateACL = false;
boolean needToUpdateDefaultACL = false;
for (AclEntry entry : entries) {
if (entry.getType().equals(AclEntryType.NAMED_USER)
|| entry.getType().equals(AclEntryType.NAMED_GROUP)
|| entry.getType().equals(AclEntryType.OWNING_GROUP)) {
if (entry.isDefault()) {
needToUpdateDefaultACL = true;
} else {
needToUpdateACL = true;
}
}
if (entry.getType().equals(AclEntryType.MASK)) {
// If mask is explicitly set or removed then we don't need to update the mask
return getThis();
}
}
if (needToUpdateACL) {
mAcl.updateMask();
}
if (needToUpdateDefaultACL) {
getDefaultACL().updateMask();
}
return getThis();
}
|
[
"public",
"T",
"updateMask",
"(",
"List",
"<",
"AclEntry",
">",
"entries",
")",
"{",
"boolean",
"needToUpdateACL",
"=",
"false",
";",
"boolean",
"needToUpdateDefaultACL",
"=",
"false",
";",
"for",
"(",
"AclEntry",
"entry",
":",
"entries",
")",
"{",
"if",
"(",
"entry",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"AclEntryType",
".",
"NAMED_USER",
")",
"||",
"entry",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"AclEntryType",
".",
"NAMED_GROUP",
")",
"||",
"entry",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"AclEntryType",
".",
"OWNING_GROUP",
")",
")",
"{",
"if",
"(",
"entry",
".",
"isDefault",
"(",
")",
")",
"{",
"needToUpdateDefaultACL",
"=",
"true",
";",
"}",
"else",
"{",
"needToUpdateACL",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"entry",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"AclEntryType",
".",
"MASK",
")",
")",
"{",
"// If mask is explicitly set or removed then we don't need to update the mask",
"return",
"getThis",
"(",
")",
";",
"}",
"}",
"if",
"(",
"needToUpdateACL",
")",
"{",
"mAcl",
".",
"updateMask",
"(",
")",
";",
"}",
"if",
"(",
"needToUpdateDefaultACL",
")",
"{",
"getDefaultACL",
"(",
")",
".",
"updateMask",
"(",
")",
";",
"}",
"return",
"getThis",
"(",
")",
";",
"}"
] |
Update Mask for the Inode.
This method should be called after updates to ACL and defaultACL.
@param entries the list of ACL entries
@return the updated object
|
[
"Update",
"Mask",
"for",
"the",
"Inode",
".",
"This",
"method",
"should",
"be",
"called",
"after",
"updates",
"to",
"ACL",
"and",
"defaultACL",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/MutableInode.java#L224-L251
|
18,926
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/MutableInode.java
|
MutableInode.setAcl
|
public T setAcl(List<AclEntry> entries) {
if (entries == null || entries.isEmpty()) {
return getThis();
}
for (AclEntry entry : entries) {
if (entry.isDefault()) {
getDefaultACL().setEntry(entry);
} else {
mAcl.setEntry(entry);
}
}
updateMask(entries);
return getThis();
}
|
java
|
public T setAcl(List<AclEntry> entries) {
if (entries == null || entries.isEmpty()) {
return getThis();
}
for (AclEntry entry : entries) {
if (entry.isDefault()) {
getDefaultACL().setEntry(entry);
} else {
mAcl.setEntry(entry);
}
}
updateMask(entries);
return getThis();
}
|
[
"public",
"T",
"setAcl",
"(",
"List",
"<",
"AclEntry",
">",
"entries",
")",
"{",
"if",
"(",
"entries",
"==",
"null",
"||",
"entries",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"getThis",
"(",
")",
";",
"}",
"for",
"(",
"AclEntry",
"entry",
":",
"entries",
")",
"{",
"if",
"(",
"entry",
".",
"isDefault",
"(",
")",
")",
"{",
"getDefaultACL",
"(",
")",
".",
"setEntry",
"(",
"entry",
")",
";",
"}",
"else",
"{",
"mAcl",
".",
"setEntry",
"(",
"entry",
")",
";",
"}",
"}",
"updateMask",
"(",
"entries",
")",
";",
"return",
"getThis",
"(",
")",
";",
"}"
] |
Sets ACL entries into the internal ACL.
The entries will overwrite any existing correspondent entries in the internal ACL.
@param entries the ACL entries
@return the updated object
|
[
"Sets",
"ACL",
"entries",
"into",
"the",
"internal",
"ACL",
".",
"The",
"entries",
"will",
"overwrite",
"any",
"existing",
"correspondent",
"entries",
"in",
"the",
"internal",
"ACL",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/MutableInode.java#L399-L412
|
18,927
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/MutableInode.java
|
MutableInode.updateFromEntry
|
public void updateFromEntry(UpdateInodeEntry entry) {
if (entry.hasAcl()) {
setInternalAcl(ProtoUtils.fromProto(entry.getAcl()));
}
if (entry.hasCreationTimeMs()) {
setCreationTimeMs(entry.getCreationTimeMs());
}
if (entry.hasGroup()) {
setGroup(entry.getGroup());
}
if (entry.hasLastModificationTimeMs()) {
setLastModificationTimeMs(entry.getLastModificationTimeMs(),
entry.getOverwriteModificationTime());
}
if (entry.hasMode()) {
setMode((short) entry.getMode());
}
if (entry.hasName()) {
setName(entry.getName());
}
if (entry.hasOwner()) {
setOwner(entry.getOwner());
}
if (entry.hasParentId()) {
setParentId(entry.getParentId());
}
if (entry.hasPersistenceState()) {
setPersistenceState(PersistenceState.valueOf(entry.getPersistenceState()));
}
if (entry.hasPinned()) {
setPinned(entry.getPinned());
}
if (entry.hasTtl()) {
setTtl(entry.getTtl());
}
if (entry.hasTtlAction()) {
setTtlAction(ProtobufUtils.fromProtobuf(entry.getTtlAction()));
}
if (entry.hasUfsFingerprint()) {
setUfsFingerprint(entry.getUfsFingerprint());
}
}
|
java
|
public void updateFromEntry(UpdateInodeEntry entry) {
if (entry.hasAcl()) {
setInternalAcl(ProtoUtils.fromProto(entry.getAcl()));
}
if (entry.hasCreationTimeMs()) {
setCreationTimeMs(entry.getCreationTimeMs());
}
if (entry.hasGroup()) {
setGroup(entry.getGroup());
}
if (entry.hasLastModificationTimeMs()) {
setLastModificationTimeMs(entry.getLastModificationTimeMs(),
entry.getOverwriteModificationTime());
}
if (entry.hasMode()) {
setMode((short) entry.getMode());
}
if (entry.hasName()) {
setName(entry.getName());
}
if (entry.hasOwner()) {
setOwner(entry.getOwner());
}
if (entry.hasParentId()) {
setParentId(entry.getParentId());
}
if (entry.hasPersistenceState()) {
setPersistenceState(PersistenceState.valueOf(entry.getPersistenceState()));
}
if (entry.hasPinned()) {
setPinned(entry.getPinned());
}
if (entry.hasTtl()) {
setTtl(entry.getTtl());
}
if (entry.hasTtlAction()) {
setTtlAction(ProtobufUtils.fromProtobuf(entry.getTtlAction()));
}
if (entry.hasUfsFingerprint()) {
setUfsFingerprint(entry.getUfsFingerprint());
}
}
|
[
"public",
"void",
"updateFromEntry",
"(",
"UpdateInodeEntry",
"entry",
")",
"{",
"if",
"(",
"entry",
".",
"hasAcl",
"(",
")",
")",
"{",
"setInternalAcl",
"(",
"ProtoUtils",
".",
"fromProto",
"(",
"entry",
".",
"getAcl",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasCreationTimeMs",
"(",
")",
")",
"{",
"setCreationTimeMs",
"(",
"entry",
".",
"getCreationTimeMs",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasGroup",
"(",
")",
")",
"{",
"setGroup",
"(",
"entry",
".",
"getGroup",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasLastModificationTimeMs",
"(",
")",
")",
"{",
"setLastModificationTimeMs",
"(",
"entry",
".",
"getLastModificationTimeMs",
"(",
")",
",",
"entry",
".",
"getOverwriteModificationTime",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasMode",
"(",
")",
")",
"{",
"setMode",
"(",
"(",
"short",
")",
"entry",
".",
"getMode",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasName",
"(",
")",
")",
"{",
"setName",
"(",
"entry",
".",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasOwner",
"(",
")",
")",
"{",
"setOwner",
"(",
"entry",
".",
"getOwner",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasParentId",
"(",
")",
")",
"{",
"setParentId",
"(",
"entry",
".",
"getParentId",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasPersistenceState",
"(",
")",
")",
"{",
"setPersistenceState",
"(",
"PersistenceState",
".",
"valueOf",
"(",
"entry",
".",
"getPersistenceState",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasPinned",
"(",
")",
")",
"{",
"setPinned",
"(",
"entry",
".",
"getPinned",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasTtl",
"(",
")",
")",
"{",
"setTtl",
"(",
"entry",
".",
"getTtl",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasTtlAction",
"(",
")",
")",
"{",
"setTtlAction",
"(",
"ProtobufUtils",
".",
"fromProtobuf",
"(",
"entry",
".",
"getTtlAction",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasUfsFingerprint",
"(",
")",
")",
"{",
"setUfsFingerprint",
"(",
"entry",
".",
"getUfsFingerprint",
"(",
")",
")",
";",
"}",
"}"
] |
Updates this inode's state from the given entry.
@param entry the entry
|
[
"Updates",
"this",
"inode",
"s",
"state",
"from",
"the",
"given",
"entry",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/MutableInode.java#L487-L528
|
18,928
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/cli/Format.java
|
Format.formatWorkerDataFolder
|
private static void formatWorkerDataFolder(String folder) throws IOException {
Path path = Paths.get(folder);
FileUtils.deletePathRecursively(folder);
Files.createDirectory(path);
// For short-circuit read/write to work, others needs to be able to access this directory.
// Therefore, default is 777 but if the user specifies the permissions, respect those instead.
String permissions = ServerConfiguration.get(PropertyKey.WORKER_DATA_FOLDER_PERMISSIONS);
Set<PosixFilePermission> perms = PosixFilePermissions.fromString(permissions);
Files.setPosixFilePermissions(path, perms);
FileUtils.setLocalDirStickyBit(path.toAbsolutePath().toString());
}
|
java
|
private static void formatWorkerDataFolder(String folder) throws IOException {
Path path = Paths.get(folder);
FileUtils.deletePathRecursively(folder);
Files.createDirectory(path);
// For short-circuit read/write to work, others needs to be able to access this directory.
// Therefore, default is 777 but if the user specifies the permissions, respect those instead.
String permissions = ServerConfiguration.get(PropertyKey.WORKER_DATA_FOLDER_PERMISSIONS);
Set<PosixFilePermission> perms = PosixFilePermissions.fromString(permissions);
Files.setPosixFilePermissions(path, perms);
FileUtils.setLocalDirStickyBit(path.toAbsolutePath().toString());
}
|
[
"private",
"static",
"void",
"formatWorkerDataFolder",
"(",
"String",
"folder",
")",
"throws",
"IOException",
"{",
"Path",
"path",
"=",
"Paths",
".",
"get",
"(",
"folder",
")",
";",
"FileUtils",
".",
"deletePathRecursively",
"(",
"folder",
")",
";",
"Files",
".",
"createDirectory",
"(",
"path",
")",
";",
"// For short-circuit read/write to work, others needs to be able to access this directory.",
"// Therefore, default is 777 but if the user specifies the permissions, respect those instead.",
"String",
"permissions",
"=",
"ServerConfiguration",
".",
"get",
"(",
"PropertyKey",
".",
"WORKER_DATA_FOLDER_PERMISSIONS",
")",
";",
"Set",
"<",
"PosixFilePermission",
">",
"perms",
"=",
"PosixFilePermissions",
".",
"fromString",
"(",
"permissions",
")",
";",
"Files",
".",
"setPosixFilePermissions",
"(",
"path",
",",
"perms",
")",
";",
"FileUtils",
".",
"setLocalDirStickyBit",
"(",
"path",
".",
"toAbsolutePath",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}"
] |
Formats the worker data folder.
@param folder folder path
|
[
"Formats",
"the",
"worker",
"data",
"folder",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/cli/Format.java#L63-L73
|
18,929
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/FileSystemAdminShellUtils.java
|
FileSystemAdminShellUtils.compareTierNames
|
public static int compareTierNames(String a, String b) {
int aValue = getTierRankValue(a);
int bValue = getTierRankValue(b);
if (aValue == bValue) {
return a.compareTo(b);
}
return aValue - bValue;
}
|
java
|
public static int compareTierNames(String a, String b) {
int aValue = getTierRankValue(a);
int bValue = getTierRankValue(b);
if (aValue == bValue) {
return a.compareTo(b);
}
return aValue - bValue;
}
|
[
"public",
"static",
"int",
"compareTierNames",
"(",
"String",
"a",
",",
"String",
"b",
")",
"{",
"int",
"aValue",
"=",
"getTierRankValue",
"(",
"a",
")",
";",
"int",
"bValue",
"=",
"getTierRankValue",
"(",
"b",
")",
";",
"if",
"(",
"aValue",
"==",
"bValue",
")",
"{",
"return",
"a",
".",
"compareTo",
"(",
"b",
")",
";",
"}",
"return",
"aValue",
"-",
"bValue",
";",
"}"
] |
Compares two tier names according to their rank values.
@param a one tier name
@param b another tier name
@return compared result
|
[
"Compares",
"two",
"tier",
"names",
"according",
"to",
"their",
"rank",
"values",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/FileSystemAdminShellUtils.java#L43-L50
|
18,930
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/FileSystemAdminShellUtils.java
|
FileSystemAdminShellUtils.checkMasterClientService
|
public static void checkMasterClientService(AlluxioConfiguration alluxioConf) throws IOException {
try (CloseableResource<FileSystemMasterClient> client =
FileSystemContext.create(ClientContext.create(alluxioConf))
.acquireMasterClientResource()) {
InetSocketAddress address = client.get().getAddress();
List<InetSocketAddress> addresses = Arrays.asList(address);
MasterInquireClient inquireClient = new PollingMasterInquireClient(addresses, () ->
new ExponentialBackoffRetry(50, 100, 2), alluxioConf);
inquireClient.getPrimaryRpcAddress();
} catch (UnavailableException e) {
throw new IOException("Cannot connect to Alluxio leader master.");
}
}
|
java
|
public static void checkMasterClientService(AlluxioConfiguration alluxioConf) throws IOException {
try (CloseableResource<FileSystemMasterClient> client =
FileSystemContext.create(ClientContext.create(alluxioConf))
.acquireMasterClientResource()) {
InetSocketAddress address = client.get().getAddress();
List<InetSocketAddress> addresses = Arrays.asList(address);
MasterInquireClient inquireClient = new PollingMasterInquireClient(addresses, () ->
new ExponentialBackoffRetry(50, 100, 2), alluxioConf);
inquireClient.getPrimaryRpcAddress();
} catch (UnavailableException e) {
throw new IOException("Cannot connect to Alluxio leader master.");
}
}
|
[
"public",
"static",
"void",
"checkMasterClientService",
"(",
"AlluxioConfiguration",
"alluxioConf",
")",
"throws",
"IOException",
"{",
"try",
"(",
"CloseableResource",
"<",
"FileSystemMasterClient",
">",
"client",
"=",
"FileSystemContext",
".",
"create",
"(",
"ClientContext",
".",
"create",
"(",
"alluxioConf",
")",
")",
".",
"acquireMasterClientResource",
"(",
")",
")",
"{",
"InetSocketAddress",
"address",
"=",
"client",
".",
"get",
"(",
")",
".",
"getAddress",
"(",
")",
";",
"List",
"<",
"InetSocketAddress",
">",
"addresses",
"=",
"Arrays",
".",
"asList",
"(",
"address",
")",
";",
"MasterInquireClient",
"inquireClient",
"=",
"new",
"PollingMasterInquireClient",
"(",
"addresses",
",",
"(",
")",
"->",
"new",
"ExponentialBackoffRetry",
"(",
"50",
",",
"100",
",",
"2",
")",
",",
"alluxioConf",
")",
";",
"inquireClient",
".",
"getPrimaryRpcAddress",
"(",
")",
";",
"}",
"catch",
"(",
"UnavailableException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Cannot connect to Alluxio leader master.\"",
")",
";",
"}",
"}"
] |
Checks if the master client service is available.
Throws an exception if fails to determine that the master client service is running.
@param alluxioConf Alluxio configuration
|
[
"Checks",
"if",
"the",
"master",
"client",
"service",
"is",
"available",
".",
"Throws",
"an",
"exception",
"if",
"fails",
"to",
"determine",
"that",
"the",
"master",
"client",
"service",
"is",
"running",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/FileSystemAdminShellUtils.java#L58-L71
|
18,931
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/FileSystemAdminShellUtils.java
|
FileSystemAdminShellUtils.getTierRankValue
|
private static int getTierRankValue(String input) {
// MEM, SSD, and HDD are the most commonly used Alluxio tier alias,
// so we want them to show before other tier names
// MEM, SSD, and HDD are sorted according to the speed of access
List<String> tierOrder = Arrays.asList("MEM", "SSD", "HDD");
int rank = tierOrder.indexOf(input);
if (rank == -1) {
return Integer.MAX_VALUE;
}
return rank;
}
|
java
|
private static int getTierRankValue(String input) {
// MEM, SSD, and HDD are the most commonly used Alluxio tier alias,
// so we want them to show before other tier names
// MEM, SSD, and HDD are sorted according to the speed of access
List<String> tierOrder = Arrays.asList("MEM", "SSD", "HDD");
int rank = tierOrder.indexOf(input);
if (rank == -1) {
return Integer.MAX_VALUE;
}
return rank;
}
|
[
"private",
"static",
"int",
"getTierRankValue",
"(",
"String",
"input",
")",
"{",
"// MEM, SSD, and HDD are the most commonly used Alluxio tier alias,",
"// so we want them to show before other tier names",
"// MEM, SSD, and HDD are sorted according to the speed of access",
"List",
"<",
"String",
">",
"tierOrder",
"=",
"Arrays",
".",
"asList",
"(",
"\"MEM\"",
",",
"\"SSD\"",
",",
"\"HDD\"",
")",
";",
"int",
"rank",
"=",
"tierOrder",
".",
"indexOf",
"(",
"input",
")",
";",
"if",
"(",
"rank",
"==",
"-",
"1",
")",
"{",
"return",
"Integer",
".",
"MAX_VALUE",
";",
"}",
"return",
"rank",
";",
"}"
] |
Assigns a rank value to the input string.
@param input the input to turn to rank value
@return a rank value used to sort tiers
|
[
"Assigns",
"a",
"rank",
"value",
"to",
"the",
"input",
"string",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/FileSystemAdminShellUtils.java#L79-L89
|
18,932
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/stream/BlockInStream.java
|
BlockInStream.readChunk
|
private void readChunk() throws IOException {
if (mDataReader == null) {
mDataReader = mDataReaderFactory.create(mPos, mLength - mPos);
}
if (mCurrentChunk != null && mCurrentChunk.readableBytes() == 0) {
mCurrentChunk.release();
mCurrentChunk = null;
}
if (mCurrentChunk == null) {
mCurrentChunk = mDataReader.readChunk();
}
}
|
java
|
private void readChunk() throws IOException {
if (mDataReader == null) {
mDataReader = mDataReaderFactory.create(mPos, mLength - mPos);
}
if (mCurrentChunk != null && mCurrentChunk.readableBytes() == 0) {
mCurrentChunk.release();
mCurrentChunk = null;
}
if (mCurrentChunk == null) {
mCurrentChunk = mDataReader.readChunk();
}
}
|
[
"private",
"void",
"readChunk",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mDataReader",
"==",
"null",
")",
"{",
"mDataReader",
"=",
"mDataReaderFactory",
".",
"create",
"(",
"mPos",
",",
"mLength",
"-",
"mPos",
")",
";",
"}",
"if",
"(",
"mCurrentChunk",
"!=",
"null",
"&&",
"mCurrentChunk",
".",
"readableBytes",
"(",
")",
"==",
"0",
")",
"{",
"mCurrentChunk",
".",
"release",
"(",
")",
";",
"mCurrentChunk",
"=",
"null",
";",
"}",
"if",
"(",
"mCurrentChunk",
"==",
"null",
")",
"{",
"mCurrentChunk",
"=",
"mDataReader",
".",
"readChunk",
"(",
")",
";",
"}",
"}"
] |
Reads a new chunk from the channel if all of the current chunk is read.
|
[
"Reads",
"a",
"new",
"chunk",
"from",
"the",
"channel",
"if",
"all",
"of",
"the",
"current",
"chunk",
"is",
"read",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/stream/BlockInStream.java#L366-L378
|
18,933
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/stream/BlockInStream.java
|
BlockInStream.closeDataReader
|
private void closeDataReader() throws IOException {
if (mCurrentChunk != null) {
mCurrentChunk.release();
mCurrentChunk = null;
}
if (mDataReader != null) {
mDataReader.close();
}
mDataReader = null;
}
|
java
|
private void closeDataReader() throws IOException {
if (mCurrentChunk != null) {
mCurrentChunk.release();
mCurrentChunk = null;
}
if (mDataReader != null) {
mDataReader.close();
}
mDataReader = null;
}
|
[
"private",
"void",
"closeDataReader",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mCurrentChunk",
"!=",
"null",
")",
"{",
"mCurrentChunk",
".",
"release",
"(",
")",
";",
"mCurrentChunk",
"=",
"null",
";",
"}",
"if",
"(",
"mDataReader",
"!=",
"null",
")",
"{",
"mDataReader",
".",
"close",
"(",
")",
";",
"}",
"mDataReader",
"=",
"null",
";",
"}"
] |
Close the current data reader.
|
[
"Close",
"the",
"current",
"data",
"reader",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/stream/BlockInStream.java#L383-L392
|
18,934
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/contexts/CreatePathContext.java
|
CreatePathContext.setAcl
|
public K setAcl(List<AclEntry> acl) {
mAcl = ImmutableList.copyOf(acl);
return getThis();
}
|
java
|
public K setAcl(List<AclEntry> acl) {
mAcl = ImmutableList.copyOf(acl);
return getThis();
}
|
[
"public",
"K",
"setAcl",
"(",
"List",
"<",
"AclEntry",
">",
"acl",
")",
"{",
"mAcl",
"=",
"ImmutableList",
".",
"copyOf",
"(",
"acl",
")",
";",
"return",
"getThis",
"(",
")",
";",
"}"
] |
Sets an immutable copy of acl as the internal access control list.
@param acl the ACL entries
@return the updated context
|
[
"Sets",
"an",
"immutable",
"copy",
"of",
"acl",
"as",
"the",
"internal",
"access",
"control",
"list",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/contexts/CreatePathContext.java#L174-L177
|
18,935
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMasterClient.java
|
BlockMasterClient.commitBlock
|
public void commitBlock(final long workerId, final long usedBytesOnTier,
final String tierAlias, final long blockId, final long length) throws IOException {
retryRPC((RpcCallable<Void>) () -> {
CommitBlockPRequest request =
CommitBlockPRequest.newBuilder().setWorkerId(workerId).setUsedBytesOnTier(usedBytesOnTier)
.setTierAlias(tierAlias).setBlockId(blockId).setLength(length).build();
mClient.commitBlock(request);
return null;
});
}
|
java
|
public void commitBlock(final long workerId, final long usedBytesOnTier,
final String tierAlias, final long blockId, final long length) throws IOException {
retryRPC((RpcCallable<Void>) () -> {
CommitBlockPRequest request =
CommitBlockPRequest.newBuilder().setWorkerId(workerId).setUsedBytesOnTier(usedBytesOnTier)
.setTierAlias(tierAlias).setBlockId(blockId).setLength(length).build();
mClient.commitBlock(request);
return null;
});
}
|
[
"public",
"void",
"commitBlock",
"(",
"final",
"long",
"workerId",
",",
"final",
"long",
"usedBytesOnTier",
",",
"final",
"String",
"tierAlias",
",",
"final",
"long",
"blockId",
",",
"final",
"long",
"length",
")",
"throws",
"IOException",
"{",
"retryRPC",
"(",
"(",
"RpcCallable",
"<",
"Void",
">",
")",
"(",
")",
"->",
"{",
"CommitBlockPRequest",
"request",
"=",
"CommitBlockPRequest",
".",
"newBuilder",
"(",
")",
".",
"setWorkerId",
"(",
"workerId",
")",
".",
"setUsedBytesOnTier",
"(",
"usedBytesOnTier",
")",
".",
"setTierAlias",
"(",
"tierAlias",
")",
".",
"setBlockId",
"(",
"blockId",
")",
".",
"setLength",
"(",
"length",
")",
".",
"build",
"(",
")",
";",
"mClient",
".",
"commitBlock",
"(",
"request",
")",
";",
"return",
"null",
";",
"}",
")",
";",
"}"
] |
Commits a block on a worker.
@param workerId the worker id committing the block
@param usedBytesOnTier the amount of used bytes on the tier the block is committing to
@param tierAlias the alias of the tier the block is being committed to
@param blockId the block id being committed
@param length the length of the block being committed
|
[
"Commits",
"a",
"block",
"on",
"a",
"worker",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMasterClient.java#L87-L96
|
18,936
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMasterClient.java
|
BlockMasterClient.commitBlockInUfs
|
public void commitBlockInUfs(final long blockId, final long length)
throws IOException {
retryRPC((RpcCallable<Void>) () -> {
CommitBlockInUfsPRequest request =
CommitBlockInUfsPRequest.newBuilder().setBlockId(blockId).setLength(length).build();
mClient.commitBlockInUfs(request);
return null;
});
}
|
java
|
public void commitBlockInUfs(final long blockId, final long length)
throws IOException {
retryRPC((RpcCallable<Void>) () -> {
CommitBlockInUfsPRequest request =
CommitBlockInUfsPRequest.newBuilder().setBlockId(blockId).setLength(length).build();
mClient.commitBlockInUfs(request);
return null;
});
}
|
[
"public",
"void",
"commitBlockInUfs",
"(",
"final",
"long",
"blockId",
",",
"final",
"long",
"length",
")",
"throws",
"IOException",
"{",
"retryRPC",
"(",
"(",
"RpcCallable",
"<",
"Void",
">",
")",
"(",
")",
"->",
"{",
"CommitBlockInUfsPRequest",
"request",
"=",
"CommitBlockInUfsPRequest",
".",
"newBuilder",
"(",
")",
".",
"setBlockId",
"(",
"blockId",
")",
".",
"setLength",
"(",
"length",
")",
".",
"build",
"(",
")",
";",
"mClient",
".",
"commitBlockInUfs",
"(",
"request",
")",
";",
"return",
"null",
";",
"}",
")",
";",
"}"
] |
Commits a block in Ufs.
@param blockId the block id being committed
@param length the length of the block being committed
|
[
"Commits",
"a",
"block",
"in",
"Ufs",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMasterClient.java#L104-L112
|
18,937
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMasterClient.java
|
BlockMasterClient.getId
|
public long getId(final WorkerNetAddress address) throws IOException {
return retryRPC((RpcCallable<Long>) () -> {
GetWorkerIdPRequest request =
GetWorkerIdPRequest.newBuilder().setWorkerNetAddress(GrpcUtils.toProto(address)).build();
return mClient.getWorkerId(request).getWorkerId();
});
}
|
java
|
public long getId(final WorkerNetAddress address) throws IOException {
return retryRPC((RpcCallable<Long>) () -> {
GetWorkerIdPRequest request =
GetWorkerIdPRequest.newBuilder().setWorkerNetAddress(GrpcUtils.toProto(address)).build();
return mClient.getWorkerId(request).getWorkerId();
});
}
|
[
"public",
"long",
"getId",
"(",
"final",
"WorkerNetAddress",
"address",
")",
"throws",
"IOException",
"{",
"return",
"retryRPC",
"(",
"(",
"RpcCallable",
"<",
"Long",
">",
")",
"(",
")",
"->",
"{",
"GetWorkerIdPRequest",
"request",
"=",
"GetWorkerIdPRequest",
".",
"newBuilder",
"(",
")",
".",
"setWorkerNetAddress",
"(",
"GrpcUtils",
".",
"toProto",
"(",
"address",
")",
")",
".",
"build",
"(",
")",
";",
"return",
"mClient",
".",
"getWorkerId",
"(",
"request",
")",
".",
"getWorkerId",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Returns a worker id for a workers net address.
@param address the net address to get a worker id for
@return a worker id
|
[
"Returns",
"a",
"worker",
"id",
"for",
"a",
"workers",
"net",
"address",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMasterClient.java#L120-L126
|
18,938
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/DefaultBlockWorker.java
|
DefaultBlockWorker.stop
|
@Override
public void stop() {
// Steps to shutdown:
// 1. Gracefully shut down the runnables running in the executors.
// 2. Shutdown the executors.
// 3. Shutdown the clients. This needs to happen after the executors is shutdown because
// runnables running in the executors might be using the clients.
mSessionCleaner.stop();
// The executor shutdown needs to be done in a loop with retry because the interrupt
// signal can sometimes be ignored.
try {
CommonUtils.waitFor("block worker executor shutdown", () -> {
getExecutorService().shutdownNow();
try {
return getExecutorService().awaitTermination(100, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
});
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
} catch (TimeoutException e) {
throw new RuntimeException(e);
}
mBlockMasterClientPool.release(mBlockMasterClient);
try {
mBlockMasterClientPool.close();
} catch (IOException e) {
LOG.warn("Failed to close the block master client pool with error {}.", e.getMessage());
}
mFileSystemMasterClient.close();
}
|
java
|
@Override
public void stop() {
// Steps to shutdown:
// 1. Gracefully shut down the runnables running in the executors.
// 2. Shutdown the executors.
// 3. Shutdown the clients. This needs to happen after the executors is shutdown because
// runnables running in the executors might be using the clients.
mSessionCleaner.stop();
// The executor shutdown needs to be done in a loop with retry because the interrupt
// signal can sometimes be ignored.
try {
CommonUtils.waitFor("block worker executor shutdown", () -> {
getExecutorService().shutdownNow();
try {
return getExecutorService().awaitTermination(100, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
});
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
} catch (TimeoutException e) {
throw new RuntimeException(e);
}
mBlockMasterClientPool.release(mBlockMasterClient);
try {
mBlockMasterClientPool.close();
} catch (IOException e) {
LOG.warn("Failed to close the block master client pool with error {}.", e.getMessage());
}
mFileSystemMasterClient.close();
}
|
[
"@",
"Override",
"public",
"void",
"stop",
"(",
")",
"{",
"// Steps to shutdown:",
"// 1. Gracefully shut down the runnables running in the executors.",
"// 2. Shutdown the executors.",
"// 3. Shutdown the clients. This needs to happen after the executors is shutdown because",
"// runnables running in the executors might be using the clients.",
"mSessionCleaner",
".",
"stop",
"(",
")",
";",
"// The executor shutdown needs to be done in a loop with retry because the interrupt",
"// signal can sometimes be ignored.",
"try",
"{",
"CommonUtils",
".",
"waitFor",
"(",
"\"block worker executor shutdown\"",
",",
"(",
")",
"->",
"{",
"getExecutorService",
"(",
")",
".",
"shutdownNow",
"(",
")",
";",
"try",
"{",
"return",
"getExecutorService",
"(",
")",
".",
"awaitTermination",
"(",
"100",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"TimeoutException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"mBlockMasterClientPool",
".",
"release",
"(",
"mBlockMasterClient",
")",
";",
"try",
"{",
"mBlockMasterClientPool",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to close the block master client pool with error {}.\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"mFileSystemMasterClient",
".",
"close",
"(",
")",
";",
"}"
] |
Stops the block worker. This method should only be called to terminate the worker.
|
[
"Stops",
"the",
"block",
"worker",
".",
"This",
"method",
"should",
"only",
"be",
"called",
"to",
"terminate",
"the",
"worker",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/DefaultBlockWorker.java#L257-L290
|
18,939
|
Alluxio/alluxio
|
underfs/gcs/src/main/java/alluxio/underfs/gcs/GCSInputStream.java
|
GCSInputStream.skip
|
@Override
public long skip(long n) throws IOException {
if (mInputStream.available() >= n) {
return mInputStream.skip(n);
}
// The number of bytes to skip is possibly large, open a new stream from GCS.
mInputStream.close();
mPos += n;
try {
mObject = mClient.getObject(mBucketName, mKey, null /* ignore ModifiedSince */,
null /* ignore UnmodifiedSince */, null /* ignore MatchTags */,
null /* ignore NoneMatchTags */, mPos /* byteRangeStart */,
null /* ignore byteRangeEnd */);
mInputStream = new BufferedInputStream(mObject.getDataInputStream());
} catch (ServiceException e) {
throw new IOException(e);
}
return n;
}
|
java
|
@Override
public long skip(long n) throws IOException {
if (mInputStream.available() >= n) {
return mInputStream.skip(n);
}
// The number of bytes to skip is possibly large, open a new stream from GCS.
mInputStream.close();
mPos += n;
try {
mObject = mClient.getObject(mBucketName, mKey, null /* ignore ModifiedSince */,
null /* ignore UnmodifiedSince */, null /* ignore MatchTags */,
null /* ignore NoneMatchTags */, mPos /* byteRangeStart */,
null /* ignore byteRangeEnd */);
mInputStream = new BufferedInputStream(mObject.getDataInputStream());
} catch (ServiceException e) {
throw new IOException(e);
}
return n;
}
|
[
"@",
"Override",
"public",
"long",
"skip",
"(",
"long",
"n",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mInputStream",
".",
"available",
"(",
")",
">=",
"n",
")",
"{",
"return",
"mInputStream",
".",
"skip",
"(",
"n",
")",
";",
"}",
"// The number of bytes to skip is possibly large, open a new stream from GCS.",
"mInputStream",
".",
"close",
"(",
")",
";",
"mPos",
"+=",
"n",
";",
"try",
"{",
"mObject",
"=",
"mClient",
".",
"getObject",
"(",
"mBucketName",
",",
"mKey",
",",
"null",
"/* ignore ModifiedSince */",
",",
"null",
"/* ignore UnmodifiedSince */",
",",
"null",
"/* ignore MatchTags */",
",",
"null",
"/* ignore NoneMatchTags */",
",",
"mPos",
"/* byteRangeStart */",
",",
"null",
"/* ignore byteRangeEnd */",
")",
";",
"mInputStream",
"=",
"new",
"BufferedInputStream",
"(",
"mObject",
".",
"getDataInputStream",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ServiceException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
")",
";",
"}",
"return",
"n",
";",
"}"
] |
This method leverages the ability to open a stream from GCS from a given offset. When the
underlying stream has fewer bytes buffered than the skip request, the stream is closed, and
a new stream is opened starting at the requested offset.
@param n number of bytes to skip
@return the number of bytes skipped
|
[
"This",
"method",
"leverages",
"the",
"ability",
"to",
"open",
"a",
"stream",
"from",
"GCS",
"from",
"a",
"given",
"offset",
".",
"When",
"the",
"underlying",
"stream",
"has",
"fewer",
"bytes",
"buffered",
"than",
"the",
"skip",
"request",
"the",
"stream",
"is",
"closed",
"and",
"a",
"new",
"stream",
"is",
"opened",
"starting",
"at",
"the",
"requested",
"offset",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/gcs/src/main/java/alluxio/underfs/gcs/GCSInputStream.java#L148-L166
|
18,940
|
Alluxio/alluxio
|
underfs/gcs/src/main/java/alluxio/underfs/gcs/GCSUtils.java
|
GCSUtils.translateBucketAcl
|
public static short translateBucketAcl(GSAccessControlList acl, String userId) {
short mode = (short) 0;
for (GrantAndPermission gp : acl.getGrantAndPermissions()) {
Permission perm = gp.getPermission();
GranteeInterface grantee = gp.getGrantee();
if (perm.equals(Permission.PERMISSION_READ)) {
if (isUserIdInGrantee(grantee, userId)) {
// If the bucket is readable by the user, add r and x to the owner mode.
mode |= (short) 0500;
}
} else if (perm.equals(Permission.PERMISSION_WRITE)) {
if (isUserIdInGrantee(grantee, userId)) {
// If the bucket is writable by the user, +w to the owner mode.
mode |= (short) 0200;
}
} else if (perm.equals(Permission.PERMISSION_FULL_CONTROL)) {
if (isUserIdInGrantee(grantee, userId)) {
// If the user has full control to the bucket, +rwx to the owner mode.
mode |= (short) 0700;
}
}
}
return mode;
}
|
java
|
public static short translateBucketAcl(GSAccessControlList acl, String userId) {
short mode = (short) 0;
for (GrantAndPermission gp : acl.getGrantAndPermissions()) {
Permission perm = gp.getPermission();
GranteeInterface grantee = gp.getGrantee();
if (perm.equals(Permission.PERMISSION_READ)) {
if (isUserIdInGrantee(grantee, userId)) {
// If the bucket is readable by the user, add r and x to the owner mode.
mode |= (short) 0500;
}
} else if (perm.equals(Permission.PERMISSION_WRITE)) {
if (isUserIdInGrantee(grantee, userId)) {
// If the bucket is writable by the user, +w to the owner mode.
mode |= (short) 0200;
}
} else if (perm.equals(Permission.PERMISSION_FULL_CONTROL)) {
if (isUserIdInGrantee(grantee, userId)) {
// If the user has full control to the bucket, +rwx to the owner mode.
mode |= (short) 0700;
}
}
}
return mode;
}
|
[
"public",
"static",
"short",
"translateBucketAcl",
"(",
"GSAccessControlList",
"acl",
",",
"String",
"userId",
")",
"{",
"short",
"mode",
"=",
"(",
"short",
")",
"0",
";",
"for",
"(",
"GrantAndPermission",
"gp",
":",
"acl",
".",
"getGrantAndPermissions",
"(",
")",
")",
"{",
"Permission",
"perm",
"=",
"gp",
".",
"getPermission",
"(",
")",
";",
"GranteeInterface",
"grantee",
"=",
"gp",
".",
"getGrantee",
"(",
")",
";",
"if",
"(",
"perm",
".",
"equals",
"(",
"Permission",
".",
"PERMISSION_READ",
")",
")",
"{",
"if",
"(",
"isUserIdInGrantee",
"(",
"grantee",
",",
"userId",
")",
")",
"{",
"// If the bucket is readable by the user, add r and x to the owner mode.",
"mode",
"|=",
"(",
"short",
")",
"0500",
";",
"}",
"}",
"else",
"if",
"(",
"perm",
".",
"equals",
"(",
"Permission",
".",
"PERMISSION_WRITE",
")",
")",
"{",
"if",
"(",
"isUserIdInGrantee",
"(",
"grantee",
",",
"userId",
")",
")",
"{",
"// If the bucket is writable by the user, +w to the owner mode.",
"mode",
"|=",
"(",
"short",
")",
"0200",
";",
"}",
"}",
"else",
"if",
"(",
"perm",
".",
"equals",
"(",
"Permission",
".",
"PERMISSION_FULL_CONTROL",
")",
")",
"{",
"if",
"(",
"isUserIdInGrantee",
"(",
"grantee",
",",
"userId",
")",
")",
"{",
"// If the user has full control to the bucket, +rwx to the owner mode.",
"mode",
"|=",
"(",
"short",
")",
"0700",
";",
"}",
"}",
"}",
"return",
"mode",
";",
"}"
] |
Translates GCS bucket owner ACL to Alluxio owner mode.
@param acl the acl of GCS bucket
@param userId the S3 user id of the Alluxio owner
@return the translated posix mode in short format
|
[
"Translates",
"GCS",
"bucket",
"owner",
"ACL",
"to",
"Alluxio",
"owner",
"mode",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/gcs/src/main/java/alluxio/underfs/gcs/GCSUtils.java#L31-L54
|
18,941
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/wire/SyncPointInfo.java
|
SyncPointInfo.fromProto
|
public static SyncPointInfo fromProto(alluxio.grpc.SyncPointInfo syncPointInfo) {
SyncStatus syncStatus;
switch (syncPointInfo.getSyncStatus()) {
case Not_Initially_Synced:
syncStatus = SyncStatus.NOT_INITIALLY_SYNCED;
break;
case Syncing:
syncStatus = SyncStatus.SYNCING;
break;
case Initially_Synced:
syncStatus = SyncStatus.INITIALLY_SYNCED;
break;
default:
syncStatus = SyncStatus.NOT_INITIALLY_SYNCED;
}
return new SyncPointInfo(new AlluxioURI(syncPointInfo.getSyncPointUri()), syncStatus);
}
|
java
|
public static SyncPointInfo fromProto(alluxio.grpc.SyncPointInfo syncPointInfo) {
SyncStatus syncStatus;
switch (syncPointInfo.getSyncStatus()) {
case Not_Initially_Synced:
syncStatus = SyncStatus.NOT_INITIALLY_SYNCED;
break;
case Syncing:
syncStatus = SyncStatus.SYNCING;
break;
case Initially_Synced:
syncStatus = SyncStatus.INITIALLY_SYNCED;
break;
default:
syncStatus = SyncStatus.NOT_INITIALLY_SYNCED;
}
return new SyncPointInfo(new AlluxioURI(syncPointInfo.getSyncPointUri()), syncStatus);
}
|
[
"public",
"static",
"SyncPointInfo",
"fromProto",
"(",
"alluxio",
".",
"grpc",
".",
"SyncPointInfo",
"syncPointInfo",
")",
"{",
"SyncStatus",
"syncStatus",
";",
"switch",
"(",
"syncPointInfo",
".",
"getSyncStatus",
"(",
")",
")",
"{",
"case",
"Not_Initially_Synced",
":",
"syncStatus",
"=",
"SyncStatus",
".",
"NOT_INITIALLY_SYNCED",
";",
"break",
";",
"case",
"Syncing",
":",
"syncStatus",
"=",
"SyncStatus",
".",
"SYNCING",
";",
"break",
";",
"case",
"Initially_Synced",
":",
"syncStatus",
"=",
"SyncStatus",
".",
"INITIALLY_SYNCED",
";",
"break",
";",
"default",
":",
"syncStatus",
"=",
"SyncStatus",
".",
"NOT_INITIALLY_SYNCED",
";",
"}",
"return",
"new",
"SyncPointInfo",
"(",
"new",
"AlluxioURI",
"(",
"syncPointInfo",
".",
"getSyncPointUri",
"(",
")",
")",
",",
"syncStatus",
")",
";",
"}"
] |
Generate sync point information from the proto representation.
@param syncPointInfo the proto representation
@return sync point info object
|
[
"Generate",
"sync",
"point",
"information",
"from",
"the",
"proto",
"representation",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/wire/SyncPointInfo.java#L77-L93
|
18,942
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/grpc/GrpcChannelBuilder.java
|
GrpcChannelBuilder.setChannelType
|
public GrpcChannelBuilder setChannelType(Class<? extends io.netty.channel.Channel> channelType) {
mChannelKey.setChannelType(channelType);
return this;
}
|
java
|
public GrpcChannelBuilder setChannelType(Class<? extends io.netty.channel.Channel> channelType) {
mChannelKey.setChannelType(channelType);
return this;
}
|
[
"public",
"GrpcChannelBuilder",
"setChannelType",
"(",
"Class",
"<",
"?",
"extends",
"io",
".",
"netty",
".",
"channel",
".",
"Channel",
">",
"channelType",
")",
"{",
"mChannelKey",
".",
"setChannelType",
"(",
"channelType",
")",
";",
"return",
"this",
";",
"}"
] |
Sets the channel type.
@param channelType the channel type
@return a new instance of {@link GrpcChannelBuilder}
|
[
"Sets",
"the",
"channel",
"type",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/grpc/GrpcChannelBuilder.java#L168-L171
|
18,943
|
Alluxio/alluxio
|
job/server/src/main/java/alluxio/master/job/JobMasterClientRestServiceHandler.java
|
JobMasterClientRestServiceHandler.getStatus
|
@GET
@Path(ServiceConstants.GET_STATUS)
@JacksonFeatures(serializationEnable = {SerializationFeature.INDENT_OUTPUT})
public Response getStatus(@QueryParam("jobId") final long jobId) {
return RestUtils.call(new RestUtils.RestCallable<JobInfo>() {
@Override
public JobInfo call() throws Exception {
return mJobMaster.getStatus(jobId);
}
}, ServerConfiguration.global());
}
|
java
|
@GET
@Path(ServiceConstants.GET_STATUS)
@JacksonFeatures(serializationEnable = {SerializationFeature.INDENT_OUTPUT})
public Response getStatus(@QueryParam("jobId") final long jobId) {
return RestUtils.call(new RestUtils.RestCallable<JobInfo>() {
@Override
public JobInfo call() throws Exception {
return mJobMaster.getStatus(jobId);
}
}, ServerConfiguration.global());
}
|
[
"@",
"GET",
"@",
"Path",
"(",
"ServiceConstants",
".",
"GET_STATUS",
")",
"@",
"JacksonFeatures",
"(",
"serializationEnable",
"=",
"{",
"SerializationFeature",
".",
"INDENT_OUTPUT",
"}",
")",
"public",
"Response",
"getStatus",
"(",
"@",
"QueryParam",
"(",
"\"jobId\"",
")",
"final",
"long",
"jobId",
")",
"{",
"return",
"RestUtils",
".",
"call",
"(",
"new",
"RestUtils",
".",
"RestCallable",
"<",
"JobInfo",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"JobInfo",
"call",
"(",
")",
"throws",
"Exception",
"{",
"return",
"mJobMaster",
".",
"getStatus",
"(",
"jobId",
")",
";",
"}",
"}",
",",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
";",
"}"
] |
Gets the job status.
@param jobId the job id
@return the response of the job status
|
[
"Gets",
"the",
"job",
"status",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/server/src/main/java/alluxio/master/job/JobMasterClientRestServiceHandler.java#L111-L121
|
18,944
|
Alluxio/alluxio
|
job/server/src/main/java/alluxio/master/job/JobMasterClientRestServiceHandler.java
|
JobMasterClientRestServiceHandler.list
|
@GET
@Path(ServiceConstants.LIST)
public Response list() {
return RestUtils.call(new RestUtils.RestCallable<List<Long>>() {
@Override
public List<Long> call() throws Exception {
return mJobMaster.list();
}
}, ServerConfiguration.global());
}
|
java
|
@GET
@Path(ServiceConstants.LIST)
public Response list() {
return RestUtils.call(new RestUtils.RestCallable<List<Long>>() {
@Override
public List<Long> call() throws Exception {
return mJobMaster.list();
}
}, ServerConfiguration.global());
}
|
[
"@",
"GET",
"@",
"Path",
"(",
"ServiceConstants",
".",
"LIST",
")",
"public",
"Response",
"list",
"(",
")",
"{",
"return",
"RestUtils",
".",
"call",
"(",
"new",
"RestUtils",
".",
"RestCallable",
"<",
"List",
"<",
"Long",
">",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"List",
"<",
"Long",
">",
"call",
"(",
")",
"throws",
"Exception",
"{",
"return",
"mJobMaster",
".",
"list",
"(",
")",
";",
"}",
"}",
",",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
";",
"}"
] |
Lists all the jobs in the history.
@return the response of the names of all the jobs
|
[
"Lists",
"all",
"the",
"jobs",
"in",
"the",
"history",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/server/src/main/java/alluxio/master/job/JobMasterClientRestServiceHandler.java#L128-L137
|
18,945
|
Alluxio/alluxio
|
job/server/src/main/java/alluxio/master/job/JobMasterClientRestServiceHandler.java
|
JobMasterClientRestServiceHandler.run
|
@POST
@Path(ServiceConstants.RUN)
@Consumes(MediaType.APPLICATION_JSON)
public Response run(final JobConfig jobConfig) {
return RestUtils.call(new RestUtils.RestCallable<Long>() {
@Override
public Long call() throws Exception {
return mJobMaster.run(jobConfig);
}
}, ServerConfiguration.global());
}
|
java
|
@POST
@Path(ServiceConstants.RUN)
@Consumes(MediaType.APPLICATION_JSON)
public Response run(final JobConfig jobConfig) {
return RestUtils.call(new RestUtils.RestCallable<Long>() {
@Override
public Long call() throws Exception {
return mJobMaster.run(jobConfig);
}
}, ServerConfiguration.global());
}
|
[
"@",
"POST",
"@",
"Path",
"(",
"ServiceConstants",
".",
"RUN",
")",
"@",
"Consumes",
"(",
"MediaType",
".",
"APPLICATION_JSON",
")",
"public",
"Response",
"run",
"(",
"final",
"JobConfig",
"jobConfig",
")",
"{",
"return",
"RestUtils",
".",
"call",
"(",
"new",
"RestUtils",
".",
"RestCallable",
"<",
"Long",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Long",
"call",
"(",
")",
"throws",
"Exception",
"{",
"return",
"mJobMaster",
".",
"run",
"(",
"jobConfig",
")",
";",
"}",
"}",
",",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
";",
"}"
] |
Runs a job.
@param jobConfig the configuration of the job
@return the job id that tracks the job
|
[
"Runs",
"a",
"job",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/server/src/main/java/alluxio/master/job/JobMasterClientRestServiceHandler.java#L145-L155
|
18,946
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/PathProperties.java
|
PathProperties.add
|
public void add(Supplier<JournalContext> ctx, String path, Map<PropertyKey, String> properties) {
try (LockResource r = new LockResource(mLock.writeLock())) {
if (!properties.isEmpty()) {
Map<String, String> newProperties = mState.getProperties(path);
properties.forEach((key, value) -> newProperties.put(key.getName(), value));
mState.applyAndJournal(ctx, PathPropertiesEntry.newBuilder().setPath(path)
.putAllProperties(newProperties).build());
}
}
}
|
java
|
public void add(Supplier<JournalContext> ctx, String path, Map<PropertyKey, String> properties) {
try (LockResource r = new LockResource(mLock.writeLock())) {
if (!properties.isEmpty()) {
Map<String, String> newProperties = mState.getProperties(path);
properties.forEach((key, value) -> newProperties.put(key.getName(), value));
mState.applyAndJournal(ctx, PathPropertiesEntry.newBuilder().setPath(path)
.putAllProperties(newProperties).build());
}
}
}
|
[
"public",
"void",
"add",
"(",
"Supplier",
"<",
"JournalContext",
">",
"ctx",
",",
"String",
"path",
",",
"Map",
"<",
"PropertyKey",
",",
"String",
">",
"properties",
")",
"{",
"try",
"(",
"LockResource",
"r",
"=",
"new",
"LockResource",
"(",
"mLock",
".",
"writeLock",
"(",
")",
")",
")",
"{",
"if",
"(",
"!",
"properties",
".",
"isEmpty",
"(",
")",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"newProperties",
"=",
"mState",
".",
"getProperties",
"(",
"path",
")",
";",
"properties",
".",
"forEach",
"(",
"(",
"key",
",",
"value",
")",
"->",
"newProperties",
".",
"put",
"(",
"key",
".",
"getName",
"(",
")",
",",
"value",
")",
")",
";",
"mState",
".",
"applyAndJournal",
"(",
"ctx",
",",
"PathPropertiesEntry",
".",
"newBuilder",
"(",
")",
".",
"setPath",
"(",
"path",
")",
".",
"putAllProperties",
"(",
"newProperties",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Adds properties for path.
If there are existing properties for path, they are merged with the new properties.
If a property key already exists, its old value is overwritten.
@param ctx the journal context
@param path the path
@param properties the new properties
|
[
"Adds",
"properties",
"for",
"path",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/PathProperties.java#L78-L87
|
18,947
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/PathProperties.java
|
PathProperties.remove
|
public void remove(Supplier<JournalContext> ctx, String path, Set<String> keys) {
try (LockResource r = new LockResource(mLock.writeLock())) {
Map<String, String> properties = mState.getProperties(path);
if (!properties.isEmpty()) {
keys.forEach(key -> properties.remove(key));
if (properties.isEmpty()) {
mState.applyAndJournal(ctx, RemovePathPropertiesEntry.newBuilder().setPath(path).build());
} else {
mState.applyAndJournal(ctx, PathPropertiesEntry.newBuilder()
.setPath(path).putAllProperties(properties).build());
}
}
}
}
|
java
|
public void remove(Supplier<JournalContext> ctx, String path, Set<String> keys) {
try (LockResource r = new LockResource(mLock.writeLock())) {
Map<String, String> properties = mState.getProperties(path);
if (!properties.isEmpty()) {
keys.forEach(key -> properties.remove(key));
if (properties.isEmpty()) {
mState.applyAndJournal(ctx, RemovePathPropertiesEntry.newBuilder().setPath(path).build());
} else {
mState.applyAndJournal(ctx, PathPropertiesEntry.newBuilder()
.setPath(path).putAllProperties(properties).build());
}
}
}
}
|
[
"public",
"void",
"remove",
"(",
"Supplier",
"<",
"JournalContext",
">",
"ctx",
",",
"String",
"path",
",",
"Set",
"<",
"String",
">",
"keys",
")",
"{",
"try",
"(",
"LockResource",
"r",
"=",
"new",
"LockResource",
"(",
"mLock",
".",
"writeLock",
"(",
")",
")",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
"=",
"mState",
".",
"getProperties",
"(",
"path",
")",
";",
"if",
"(",
"!",
"properties",
".",
"isEmpty",
"(",
")",
")",
"{",
"keys",
".",
"forEach",
"(",
"key",
"->",
"properties",
".",
"remove",
"(",
"key",
")",
")",
";",
"if",
"(",
"properties",
".",
"isEmpty",
"(",
")",
")",
"{",
"mState",
".",
"applyAndJournal",
"(",
"ctx",
",",
"RemovePathPropertiesEntry",
".",
"newBuilder",
"(",
")",
".",
"setPath",
"(",
"path",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"else",
"{",
"mState",
".",
"applyAndJournal",
"(",
"ctx",
",",
"PathPropertiesEntry",
".",
"newBuilder",
"(",
")",
".",
"setPath",
"(",
"path",
")",
".",
"putAllProperties",
"(",
"properties",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Removes the specified set of keys from the properties for path.
@param ctx the journal context
@param path the path
@param keys the keys to remove
|
[
"Removes",
"the",
"specified",
"set",
"of",
"keys",
"from",
"the",
"properties",
"for",
"path",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/PathProperties.java#L96-L109
|
18,948
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/PathProperties.java
|
PathProperties.removeAll
|
public void removeAll(Supplier<JournalContext> ctx, String path) {
try (LockResource r = new LockResource(mLock.writeLock())) {
Map<String, String> properties = mState.getProperties(path);
if (!properties.isEmpty()) {
mState.applyAndJournal(ctx, RemovePathPropertiesEntry.newBuilder().setPath(path).build());
}
}
}
|
java
|
public void removeAll(Supplier<JournalContext> ctx, String path) {
try (LockResource r = new LockResource(mLock.writeLock())) {
Map<String, String> properties = mState.getProperties(path);
if (!properties.isEmpty()) {
mState.applyAndJournal(ctx, RemovePathPropertiesEntry.newBuilder().setPath(path).build());
}
}
}
|
[
"public",
"void",
"removeAll",
"(",
"Supplier",
"<",
"JournalContext",
">",
"ctx",
",",
"String",
"path",
")",
"{",
"try",
"(",
"LockResource",
"r",
"=",
"new",
"LockResource",
"(",
"mLock",
".",
"writeLock",
"(",
")",
")",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
"=",
"mState",
".",
"getProperties",
"(",
"path",
")",
";",
"if",
"(",
"!",
"properties",
".",
"isEmpty",
"(",
")",
")",
"{",
"mState",
".",
"applyAndJournal",
"(",
"ctx",
",",
"RemovePathPropertiesEntry",
".",
"newBuilder",
"(",
")",
".",
"setPath",
"(",
"path",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Removes all properties for path.
@param ctx the journal context
@param path the path
|
[
"Removes",
"all",
"properties",
"for",
"path",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/PathProperties.java#L117-L124
|
18,949
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/TtlBucketList.java
|
TtlBucketList.getBucketContaining
|
@Nullable
private TtlBucket getBucketContaining(InodeView inode) {
if (inode.getTtl() == Constants.NO_TTL) {
// no bucket will contain a inode with NO_TTL.
return null;
}
long ttlEndTimeMs = inode.getCreationTimeMs() + inode.getTtl();
// Gets the last bucket with interval start time less than or equal to the inode's life end
// time.
TtlBucket bucket = mBucketList.floor(new TtlBucket(ttlEndTimeMs));
if (bucket == null || bucket.getTtlIntervalEndTimeMs() < ttlEndTimeMs
|| (bucket.getTtlIntervalEndTimeMs() == ttlEndTimeMs
&& TtlBucket.getTtlIntervalMs() != 0)) {
// 1. There is no bucket in the list, or
// 2. All buckets' interval start time is larger than the inode's life end time, or
// 3. No bucket actually contains ttlEndTimeMs in its interval.
return null;
}
return bucket;
}
|
java
|
@Nullable
private TtlBucket getBucketContaining(InodeView inode) {
if (inode.getTtl() == Constants.NO_TTL) {
// no bucket will contain a inode with NO_TTL.
return null;
}
long ttlEndTimeMs = inode.getCreationTimeMs() + inode.getTtl();
// Gets the last bucket with interval start time less than or equal to the inode's life end
// time.
TtlBucket bucket = mBucketList.floor(new TtlBucket(ttlEndTimeMs));
if (bucket == null || bucket.getTtlIntervalEndTimeMs() < ttlEndTimeMs
|| (bucket.getTtlIntervalEndTimeMs() == ttlEndTimeMs
&& TtlBucket.getTtlIntervalMs() != 0)) {
// 1. There is no bucket in the list, or
// 2. All buckets' interval start time is larger than the inode's life end time, or
// 3. No bucket actually contains ttlEndTimeMs in its interval.
return null;
}
return bucket;
}
|
[
"@",
"Nullable",
"private",
"TtlBucket",
"getBucketContaining",
"(",
"InodeView",
"inode",
")",
"{",
"if",
"(",
"inode",
".",
"getTtl",
"(",
")",
"==",
"Constants",
".",
"NO_TTL",
")",
"{",
"// no bucket will contain a inode with NO_TTL.",
"return",
"null",
";",
"}",
"long",
"ttlEndTimeMs",
"=",
"inode",
".",
"getCreationTimeMs",
"(",
")",
"+",
"inode",
".",
"getTtl",
"(",
")",
";",
"// Gets the last bucket with interval start time less than or equal to the inode's life end",
"// time.",
"TtlBucket",
"bucket",
"=",
"mBucketList",
".",
"floor",
"(",
"new",
"TtlBucket",
"(",
"ttlEndTimeMs",
")",
")",
";",
"if",
"(",
"bucket",
"==",
"null",
"||",
"bucket",
".",
"getTtlIntervalEndTimeMs",
"(",
")",
"<",
"ttlEndTimeMs",
"||",
"(",
"bucket",
".",
"getTtlIntervalEndTimeMs",
"(",
")",
"==",
"ttlEndTimeMs",
"&&",
"TtlBucket",
".",
"getTtlIntervalMs",
"(",
")",
"!=",
"0",
")",
")",
"{",
"// 1. There is no bucket in the list, or",
"// 2. All buckets' interval start time is larger than the inode's life end time, or",
"// 3. No bucket actually contains ttlEndTimeMs in its interval.",
"return",
"null",
";",
"}",
"return",
"bucket",
";",
"}"
] |
Gets the bucket in the list that contains the inode.
@param inode the inode to be contained
@return the bucket containing the inode, or null if no such bucket exists
|
[
"Gets",
"the",
"bucket",
"in",
"the",
"list",
"that",
"contains",
"the",
"inode",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/TtlBucketList.java#L69-L90
|
18,950
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/TtlBucketList.java
|
TtlBucketList.remove
|
public void remove(InodeView inode) {
TtlBucket bucket = getBucketContaining(inode);
if (bucket != null) {
bucket.removeInode(inode);
}
}
|
java
|
public void remove(InodeView inode) {
TtlBucket bucket = getBucketContaining(inode);
if (bucket != null) {
bucket.removeInode(inode);
}
}
|
[
"public",
"void",
"remove",
"(",
"InodeView",
"inode",
")",
"{",
"TtlBucket",
"bucket",
"=",
"getBucketContaining",
"(",
"inode",
")",
";",
"if",
"(",
"bucket",
"!=",
"null",
")",
"{",
"bucket",
".",
"removeInode",
"(",
"inode",
")",
";",
"}",
"}"
] |
Removes a inode from the bucket containing it if the inode is in one of the buckets, otherwise,
do nothing.
<p>
Assume that no inode in the buckets has ttl value that equals {@link Constants#NO_TTL}.
If a inode with valid ttl value is inserted to the buckets and its ttl value is going to be set
to {@link Constants#NO_TTL} later, be sure to remove the inode from the buckets first.
@param inode the inode to be removed
|
[
"Removes",
"a",
"inode",
"from",
"the",
"bucket",
"containing",
"it",
"if",
"the",
"inode",
"is",
"in",
"one",
"of",
"the",
"buckets",
"otherwise",
"do",
"nothing",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/TtlBucketList.java#L141-L146
|
18,951
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journalv0/ufs/UfsCheckpointManager.java
|
UfsCheckpointManager.recover
|
public void recover() {
try {
boolean checkpointExists = mUfs.isFile(mCheckpoint.toString());
boolean backupCheckpointExists = mUfs.isFile(mBackupCheckpoint.toString());
boolean tempBackupCheckpointExists = mUfs.isFile(mTempBackupCheckpoint.toString());
Preconditions
.checkState(!(checkpointExists && backupCheckpointExists && tempBackupCheckpointExists),
"checkpoint, temp backup checkpoint, and backup checkpoint should never all exist ");
if (tempBackupCheckpointExists) {
// If mCheckpointPath also exists, step 2 must have implemented rename as copy + delete, and
// failed during the delete.
UnderFileSystemUtils.deleteFileIfExists(mUfs, mCheckpoint.toString());
mUfs.renameFile(mTempBackupCheckpoint.toString(), mCheckpoint.toString());
}
if (backupCheckpointExists) {
// We must have crashed after step 3
if (checkpointExists) {
// We crashed after step 4, so we can finish steps 5 and 6.
mWriter.deleteCompletedLogs();
mUfs.deleteFile(mBackupCheckpoint.toString());
} else {
// We crashed before step 4, so we roll back to the backup checkpoint.
mUfs.renameFile(mBackupCheckpoint.toString(), mCheckpoint.toString());
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
public void recover() {
try {
boolean checkpointExists = mUfs.isFile(mCheckpoint.toString());
boolean backupCheckpointExists = mUfs.isFile(mBackupCheckpoint.toString());
boolean tempBackupCheckpointExists = mUfs.isFile(mTempBackupCheckpoint.toString());
Preconditions
.checkState(!(checkpointExists && backupCheckpointExists && tempBackupCheckpointExists),
"checkpoint, temp backup checkpoint, and backup checkpoint should never all exist ");
if (tempBackupCheckpointExists) {
// If mCheckpointPath also exists, step 2 must have implemented rename as copy + delete, and
// failed during the delete.
UnderFileSystemUtils.deleteFileIfExists(mUfs, mCheckpoint.toString());
mUfs.renameFile(mTempBackupCheckpoint.toString(), mCheckpoint.toString());
}
if (backupCheckpointExists) {
// We must have crashed after step 3
if (checkpointExists) {
// We crashed after step 4, so we can finish steps 5 and 6.
mWriter.deleteCompletedLogs();
mUfs.deleteFile(mBackupCheckpoint.toString());
} else {
// We crashed before step 4, so we roll back to the backup checkpoint.
mUfs.renameFile(mBackupCheckpoint.toString(), mCheckpoint.toString());
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"void",
"recover",
"(",
")",
"{",
"try",
"{",
"boolean",
"checkpointExists",
"=",
"mUfs",
".",
"isFile",
"(",
"mCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"boolean",
"backupCheckpointExists",
"=",
"mUfs",
".",
"isFile",
"(",
"mBackupCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"boolean",
"tempBackupCheckpointExists",
"=",
"mUfs",
".",
"isFile",
"(",
"mTempBackupCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"!",
"(",
"checkpointExists",
"&&",
"backupCheckpointExists",
"&&",
"tempBackupCheckpointExists",
")",
",",
"\"checkpoint, temp backup checkpoint, and backup checkpoint should never all exist \"",
")",
";",
"if",
"(",
"tempBackupCheckpointExists",
")",
"{",
"// If mCheckpointPath also exists, step 2 must have implemented rename as copy + delete, and",
"// failed during the delete.",
"UnderFileSystemUtils",
".",
"deleteFileIfExists",
"(",
"mUfs",
",",
"mCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"mUfs",
".",
"renameFile",
"(",
"mTempBackupCheckpoint",
".",
"toString",
"(",
")",
",",
"mCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"}",
"if",
"(",
"backupCheckpointExists",
")",
"{",
"// We must have crashed after step 3",
"if",
"(",
"checkpointExists",
")",
"{",
"// We crashed after step 4, so we can finish steps 5 and 6.",
"mWriter",
".",
"deleteCompletedLogs",
"(",
")",
";",
"mUfs",
".",
"deleteFile",
"(",
"mBackupCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"}",
"else",
"{",
"// We crashed before step 4, so we roll back to the backup checkpoint.",
"mUfs",
".",
"renameFile",
"(",
"mBackupCheckpoint",
".",
"toString",
"(",
")",
",",
"mCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Recovers the checkpoint in case the master crashed while updating it.
|
[
"Recovers",
"the",
"checkpoint",
"in",
"case",
"the",
"master",
"crashed",
"while",
"updating",
"it",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journalv0/ufs/UfsCheckpointManager.java#L94-L122
|
18,952
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journalv0/ufs/UfsCheckpointManager.java
|
UfsCheckpointManager.update
|
public void update(URI location) {
try {
if (mUfs.isFile(mCheckpoint.toString())) {
UnderFileSystemUtils.deleteFileIfExists(mUfs, mTempBackupCheckpoint.toString());
UnderFileSystemUtils.deleteFileIfExists(mUfs, mBackupCheckpoint.toString());
// Rename in two steps so that we never have identical mCheckpointPath and
// mBackupCheckpointPath. This is a concern since UFS may implement rename as copy + delete.
mUfs.renameFile(mCheckpoint.toString(), mTempBackupCheckpoint.toString());
mUfs.renameFile(mTempBackupCheckpoint.toString(), mBackupCheckpoint.toString());
LOG.info("Backed up the checkpoint file to {}", mBackupCheckpoint.toString());
}
mUfs.renameFile(location.getPath(), mCheckpoint.toString());
LOG.info("Renamed the checkpoint file from {} to {}", location,
mCheckpoint.toString());
// The checkpoint already reflects the information in the completed logs.
mWriter.deleteCompletedLogs();
UnderFileSystemUtils.deleteFileIfExists(mUfs, mBackupCheckpoint.toString());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
public void update(URI location) {
try {
if (mUfs.isFile(mCheckpoint.toString())) {
UnderFileSystemUtils.deleteFileIfExists(mUfs, mTempBackupCheckpoint.toString());
UnderFileSystemUtils.deleteFileIfExists(mUfs, mBackupCheckpoint.toString());
// Rename in two steps so that we never have identical mCheckpointPath and
// mBackupCheckpointPath. This is a concern since UFS may implement rename as copy + delete.
mUfs.renameFile(mCheckpoint.toString(), mTempBackupCheckpoint.toString());
mUfs.renameFile(mTempBackupCheckpoint.toString(), mBackupCheckpoint.toString());
LOG.info("Backed up the checkpoint file to {}", mBackupCheckpoint.toString());
}
mUfs.renameFile(location.getPath(), mCheckpoint.toString());
LOG.info("Renamed the checkpoint file from {} to {}", location,
mCheckpoint.toString());
// The checkpoint already reflects the information in the completed logs.
mWriter.deleteCompletedLogs();
UnderFileSystemUtils.deleteFileIfExists(mUfs, mBackupCheckpoint.toString());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"void",
"update",
"(",
"URI",
"location",
")",
"{",
"try",
"{",
"if",
"(",
"mUfs",
".",
"isFile",
"(",
"mCheckpoint",
".",
"toString",
"(",
")",
")",
")",
"{",
"UnderFileSystemUtils",
".",
"deleteFileIfExists",
"(",
"mUfs",
",",
"mTempBackupCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"UnderFileSystemUtils",
".",
"deleteFileIfExists",
"(",
"mUfs",
",",
"mBackupCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"// Rename in two steps so that we never have identical mCheckpointPath and",
"// mBackupCheckpointPath. This is a concern since UFS may implement rename as copy + delete.",
"mUfs",
".",
"renameFile",
"(",
"mCheckpoint",
".",
"toString",
"(",
")",
",",
"mTempBackupCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"mUfs",
".",
"renameFile",
"(",
"mTempBackupCheckpoint",
".",
"toString",
"(",
")",
",",
"mBackupCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Backed up the checkpoint file to {}\"",
",",
"mBackupCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"}",
"mUfs",
".",
"renameFile",
"(",
"location",
".",
"getPath",
"(",
")",
",",
"mCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Renamed the checkpoint file from {} to {}\"",
",",
"location",
",",
"mCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"// The checkpoint already reflects the information in the completed logs.",
"mWriter",
".",
"deleteCompletedLogs",
"(",
")",
";",
"UnderFileSystemUtils",
".",
"deleteFileIfExists",
"(",
"mUfs",
",",
"mBackupCheckpoint",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Updates the checkpoint to the specified URI.
@param location the location of the new checkpoint
|
[
"Updates",
"the",
"checkpoint",
"to",
"the",
"specified",
"URI",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journalv0/ufs/UfsCheckpointManager.java#L129-L150
|
18,953
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/metrics/Metric.java
|
Metric.getMetricNameWithUserTag
|
public static String getMetricNameWithUserTag(String metricName, String userName) {
UserMetricKey k = new UserMetricKey(metricName, userName);
String result = CACHED_METRICS.get(k);
if (result != null) {
return result;
}
return CACHED_METRICS.computeIfAbsent(k, key -> metricName + "." + CommonMetrics.TAG_USER
+ TAG_SEPARATOR + userName);
}
|
java
|
public static String getMetricNameWithUserTag(String metricName, String userName) {
UserMetricKey k = new UserMetricKey(metricName, userName);
String result = CACHED_METRICS.get(k);
if (result != null) {
return result;
}
return CACHED_METRICS.computeIfAbsent(k, key -> metricName + "." + CommonMetrics.TAG_USER
+ TAG_SEPARATOR + userName);
}
|
[
"public",
"static",
"String",
"getMetricNameWithUserTag",
"(",
"String",
"metricName",
",",
"String",
"userName",
")",
"{",
"UserMetricKey",
"k",
"=",
"new",
"UserMetricKey",
"(",
"metricName",
",",
"userName",
")",
";",
"String",
"result",
"=",
"CACHED_METRICS",
".",
"get",
"(",
"k",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"return",
"CACHED_METRICS",
".",
"computeIfAbsent",
"(",
"k",
",",
"key",
"->",
"metricName",
"+",
"\".\"",
"+",
"CommonMetrics",
".",
"TAG_USER",
"+",
"TAG_SEPARATOR",
"+",
"userName",
")",
";",
"}"
] |
Gets a metric name with a specific user tag.
@param metricName the name of the metric
@param userName the user
@return a metric name with the user tagged
|
[
"Gets",
"a",
"metric",
"name",
"with",
"a",
"specific",
"user",
"tag",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/metrics/Metric.java#L223-L231
|
18,954
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/metrics/Metric.java
|
Metric.from
|
public static Metric from(String fullName, double value) {
String[] pieces = fullName.split("\\.");
Preconditions.checkArgument(pieces.length > 1, "Incorrect metrics name: %s.", fullName);
String hostname = null;
String id = null;
String name = null;
int tagStartIdx = 0;
// Master or cluster metrics don't have hostname included.
if (pieces[0].equals(MetricsSystem.InstanceType.MASTER.toString())
|| pieces[0].equals(MetricsSystem.CLUSTER.toString())) {
name = pieces[1];
tagStartIdx = 2;
} else {
if (pieces[1].contains(ID_SEPARATOR)) {
String[] ids = pieces[1].split(ID_SEPARATOR);
hostname = ids[0];
id = ids[1];
} else {
hostname = pieces[1];
}
name = pieces[2];
tagStartIdx = 3;
}
MetricsSystem.InstanceType instance = MetricsSystem.InstanceType.fromString(pieces[0]);
Metric metric = new Metric(instance, hostname, id, name, value);
// parse tags
for (int i = tagStartIdx; i < pieces.length; i++) {
String tagStr = pieces[i];
if (!tagStr.contains(TAG_SEPARATOR)) {
// Unknown tag
continue;
}
int tagSeparatorIdx = tagStr.indexOf(TAG_SEPARATOR);
metric.addTag(tagStr.substring(0, tagSeparatorIdx), tagStr.substring(tagSeparatorIdx + 1));
}
return metric;
}
|
java
|
public static Metric from(String fullName, double value) {
String[] pieces = fullName.split("\\.");
Preconditions.checkArgument(pieces.length > 1, "Incorrect metrics name: %s.", fullName);
String hostname = null;
String id = null;
String name = null;
int tagStartIdx = 0;
// Master or cluster metrics don't have hostname included.
if (pieces[0].equals(MetricsSystem.InstanceType.MASTER.toString())
|| pieces[0].equals(MetricsSystem.CLUSTER.toString())) {
name = pieces[1];
tagStartIdx = 2;
} else {
if (pieces[1].contains(ID_SEPARATOR)) {
String[] ids = pieces[1].split(ID_SEPARATOR);
hostname = ids[0];
id = ids[1];
} else {
hostname = pieces[1];
}
name = pieces[2];
tagStartIdx = 3;
}
MetricsSystem.InstanceType instance = MetricsSystem.InstanceType.fromString(pieces[0]);
Metric metric = new Metric(instance, hostname, id, name, value);
// parse tags
for (int i = tagStartIdx; i < pieces.length; i++) {
String tagStr = pieces[i];
if (!tagStr.contains(TAG_SEPARATOR)) {
// Unknown tag
continue;
}
int tagSeparatorIdx = tagStr.indexOf(TAG_SEPARATOR);
metric.addTag(tagStr.substring(0, tagSeparatorIdx), tagStr.substring(tagSeparatorIdx + 1));
}
return metric;
}
|
[
"public",
"static",
"Metric",
"from",
"(",
"String",
"fullName",
",",
"double",
"value",
")",
"{",
"String",
"[",
"]",
"pieces",
"=",
"fullName",
".",
"split",
"(",
"\"\\\\.\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"pieces",
".",
"length",
">",
"1",
",",
"\"Incorrect metrics name: %s.\"",
",",
"fullName",
")",
";",
"String",
"hostname",
"=",
"null",
";",
"String",
"id",
"=",
"null",
";",
"String",
"name",
"=",
"null",
";",
"int",
"tagStartIdx",
"=",
"0",
";",
"// Master or cluster metrics don't have hostname included.",
"if",
"(",
"pieces",
"[",
"0",
"]",
".",
"equals",
"(",
"MetricsSystem",
".",
"InstanceType",
".",
"MASTER",
".",
"toString",
"(",
")",
")",
"||",
"pieces",
"[",
"0",
"]",
".",
"equals",
"(",
"MetricsSystem",
".",
"CLUSTER",
".",
"toString",
"(",
")",
")",
")",
"{",
"name",
"=",
"pieces",
"[",
"1",
"]",
";",
"tagStartIdx",
"=",
"2",
";",
"}",
"else",
"{",
"if",
"(",
"pieces",
"[",
"1",
"]",
".",
"contains",
"(",
"ID_SEPARATOR",
")",
")",
"{",
"String",
"[",
"]",
"ids",
"=",
"pieces",
"[",
"1",
"]",
".",
"split",
"(",
"ID_SEPARATOR",
")",
";",
"hostname",
"=",
"ids",
"[",
"0",
"]",
";",
"id",
"=",
"ids",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"hostname",
"=",
"pieces",
"[",
"1",
"]",
";",
"}",
"name",
"=",
"pieces",
"[",
"2",
"]",
";",
"tagStartIdx",
"=",
"3",
";",
"}",
"MetricsSystem",
".",
"InstanceType",
"instance",
"=",
"MetricsSystem",
".",
"InstanceType",
".",
"fromString",
"(",
"pieces",
"[",
"0",
"]",
")",
";",
"Metric",
"metric",
"=",
"new",
"Metric",
"(",
"instance",
",",
"hostname",
",",
"id",
",",
"name",
",",
"value",
")",
";",
"// parse tags",
"for",
"(",
"int",
"i",
"=",
"tagStartIdx",
";",
"i",
"<",
"pieces",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"tagStr",
"=",
"pieces",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"tagStr",
".",
"contains",
"(",
"TAG_SEPARATOR",
")",
")",
"{",
"// Unknown tag",
"continue",
";",
"}",
"int",
"tagSeparatorIdx",
"=",
"tagStr",
".",
"indexOf",
"(",
"TAG_SEPARATOR",
")",
";",
"metric",
".",
"addTag",
"(",
"tagStr",
".",
"substring",
"(",
"0",
",",
"tagSeparatorIdx",
")",
",",
"tagStr",
".",
"substring",
"(",
"tagSeparatorIdx",
"+",
"1",
")",
")",
";",
"}",
"return",
"metric",
";",
"}"
] |
Creates the metric from the full name and the value.
@param fullName the full name
@param value the value
@return the created metric
|
[
"Creates",
"the",
"metric",
"from",
"the",
"full",
"name",
"and",
"the",
"value",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/metrics/Metric.java#L240-L278
|
18,955
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/metrics/Metric.java
|
Metric.fromProto
|
public static Metric fromProto(alluxio.grpc.Metric metric) {
Metric created = new Metric(MetricsSystem.InstanceType.fromString(metric.getInstance()),
metric.getHostname(), metric.hasInstanceId() ? metric.getInstanceId() : null,
metric.getName(), metric.getValue());
for (Entry<String, String> entry : metric.getTagsMap().entrySet()) {
created.addTag(entry.getKey(), entry.getValue());
}
return created;
}
|
java
|
public static Metric fromProto(alluxio.grpc.Metric metric) {
Metric created = new Metric(MetricsSystem.InstanceType.fromString(metric.getInstance()),
metric.getHostname(), metric.hasInstanceId() ? metric.getInstanceId() : null,
metric.getName(), metric.getValue());
for (Entry<String, String> entry : metric.getTagsMap().entrySet()) {
created.addTag(entry.getKey(), entry.getValue());
}
return created;
}
|
[
"public",
"static",
"Metric",
"fromProto",
"(",
"alluxio",
".",
"grpc",
".",
"Metric",
"metric",
")",
"{",
"Metric",
"created",
"=",
"new",
"Metric",
"(",
"MetricsSystem",
".",
"InstanceType",
".",
"fromString",
"(",
"metric",
".",
"getInstance",
"(",
")",
")",
",",
"metric",
".",
"getHostname",
"(",
")",
",",
"metric",
".",
"hasInstanceId",
"(",
")",
"?",
"metric",
".",
"getInstanceId",
"(",
")",
":",
"null",
",",
"metric",
".",
"getName",
"(",
")",
",",
"metric",
".",
"getValue",
"(",
")",
")",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"metric",
".",
"getTagsMap",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"created",
".",
"addTag",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"return",
"created",
";",
"}"
] |
Constructs the metric object from the proto format.
@param metric the metric in proto format
@return the constructed metric
|
[
"Constructs",
"the",
"metric",
"object",
"from",
"the",
"proto",
"format",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/metrics/Metric.java#L286-L294
|
18,956
|
Alluxio/alluxio
|
underfs/hdfs/src/main/java/alluxio/underfs/hdfs/HdfsUnderFileSystem.java
|
HdfsUnderFileSystem.delete
|
private boolean delete(String path, boolean recursive) throws IOException {
IOException te = null;
FileSystem hdfs = getFs();
RetryPolicy retryPolicy = new CountingRetry(MAX_TRY);
while (retryPolicy.attempt()) {
try {
return hdfs.delete(new Path(path), recursive);
} catch (IOException e) {
LOG.warn("Attempt count {} : {}", retryPolicy.getAttemptCount(), e.getMessage());
te = e;
}
}
throw te;
}
|
java
|
private boolean delete(String path, boolean recursive) throws IOException {
IOException te = null;
FileSystem hdfs = getFs();
RetryPolicy retryPolicy = new CountingRetry(MAX_TRY);
while (retryPolicy.attempt()) {
try {
return hdfs.delete(new Path(path), recursive);
} catch (IOException e) {
LOG.warn("Attempt count {} : {}", retryPolicy.getAttemptCount(), e.getMessage());
te = e;
}
}
throw te;
}
|
[
"private",
"boolean",
"delete",
"(",
"String",
"path",
",",
"boolean",
"recursive",
")",
"throws",
"IOException",
"{",
"IOException",
"te",
"=",
"null",
";",
"FileSystem",
"hdfs",
"=",
"getFs",
"(",
")",
";",
"RetryPolicy",
"retryPolicy",
"=",
"new",
"CountingRetry",
"(",
"MAX_TRY",
")",
";",
"while",
"(",
"retryPolicy",
".",
"attempt",
"(",
")",
")",
"{",
"try",
"{",
"return",
"hdfs",
".",
"delete",
"(",
"new",
"Path",
"(",
"path",
")",
",",
"recursive",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Attempt count {} : {}\"",
",",
"retryPolicy",
".",
"getAttemptCount",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"te",
"=",
"e",
";",
"}",
"}",
"throw",
"te",
";",
"}"
] |
Delete a file or directory at path.
@param path file or directory path
@param recursive whether to delete path recursively
@return true, if succeed
|
[
"Delete",
"a",
"file",
"or",
"directory",
"at",
"path",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/hdfs/src/main/java/alluxio/underfs/hdfs/HdfsUnderFileSystem.java#L691-L704
|
18,957
|
Alluxio/alluxio
|
underfs/hdfs/src/main/java/alluxio/underfs/hdfs/HdfsUnderFileSystem.java
|
HdfsUnderFileSystem.rename
|
private boolean rename(String src, String dst) throws IOException {
IOException te = null;
FileSystem hdfs = getFs();
RetryPolicy retryPolicy = new CountingRetry(MAX_TRY);
while (retryPolicy.attempt()) {
try {
return hdfs.rename(new Path(src), new Path(dst));
} catch (IOException e) {
LOG.warn("{} try to rename {} to {} : {}", retryPolicy.getAttemptCount(), src, dst,
e.getMessage());
te = e;
}
}
throw te;
}
|
java
|
private boolean rename(String src, String dst) throws IOException {
IOException te = null;
FileSystem hdfs = getFs();
RetryPolicy retryPolicy = new CountingRetry(MAX_TRY);
while (retryPolicy.attempt()) {
try {
return hdfs.rename(new Path(src), new Path(dst));
} catch (IOException e) {
LOG.warn("{} try to rename {} to {} : {}", retryPolicy.getAttemptCount(), src, dst,
e.getMessage());
te = e;
}
}
throw te;
}
|
[
"private",
"boolean",
"rename",
"(",
"String",
"src",
",",
"String",
"dst",
")",
"throws",
"IOException",
"{",
"IOException",
"te",
"=",
"null",
";",
"FileSystem",
"hdfs",
"=",
"getFs",
"(",
")",
";",
"RetryPolicy",
"retryPolicy",
"=",
"new",
"CountingRetry",
"(",
"MAX_TRY",
")",
";",
"while",
"(",
"retryPolicy",
".",
"attempt",
"(",
")",
")",
"{",
"try",
"{",
"return",
"hdfs",
".",
"rename",
"(",
"new",
"Path",
"(",
"src",
")",
",",
"new",
"Path",
"(",
"dst",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"{} try to rename {} to {} : {}\"",
",",
"retryPolicy",
".",
"getAttemptCount",
"(",
")",
",",
"src",
",",
"dst",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"te",
"=",
"e",
";",
"}",
"}",
"throw",
"te",
";",
"}"
] |
Rename a file or folder to a file or folder.
@param src path of source file or directory
@param dst path of destination file or directory
@return true if rename succeeds
|
[
"Rename",
"a",
"file",
"or",
"folder",
"to",
"a",
"file",
"or",
"folder",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/hdfs/src/main/java/alluxio/underfs/hdfs/HdfsUnderFileSystem.java#L736-L750
|
18,958
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/web/WebInterfaceAbstractMetricsServlet.java
|
WebInterfaceAbstractMetricsServlet.populateCounterValues
|
protected void populateCounterValues(Map<String, Metric> operations,
Map<String, Counter> rpcInvocations, HttpServletRequest request) {
for (Map.Entry<String, Metric> entry : operations.entrySet()) {
if (entry.getValue() instanceof Gauge) {
request.setAttribute(entry.getKey(), ((Gauge<?>) entry.getValue()).getValue());
} else if (entry.getValue() instanceof Counter) {
request.setAttribute(entry.getKey(), ((Counter) entry.getValue()).getCount());
}
}
for (Map.Entry<String, Counter> entry : rpcInvocations.entrySet()) {
request.setAttribute(entry.getKey(), entry.getValue().getCount());
}
}
|
java
|
protected void populateCounterValues(Map<String, Metric> operations,
Map<String, Counter> rpcInvocations, HttpServletRequest request) {
for (Map.Entry<String, Metric> entry : operations.entrySet()) {
if (entry.getValue() instanceof Gauge) {
request.setAttribute(entry.getKey(), ((Gauge<?>) entry.getValue()).getValue());
} else if (entry.getValue() instanceof Counter) {
request.setAttribute(entry.getKey(), ((Counter) entry.getValue()).getCount());
}
}
for (Map.Entry<String, Counter> entry : rpcInvocations.entrySet()) {
request.setAttribute(entry.getKey(), entry.getValue().getCount());
}
}
|
[
"protected",
"void",
"populateCounterValues",
"(",
"Map",
"<",
"String",
",",
"Metric",
">",
"operations",
",",
"Map",
"<",
"String",
",",
"Counter",
">",
"rpcInvocations",
",",
"HttpServletRequest",
"request",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Metric",
">",
"entry",
":",
"operations",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
"instanceof",
"Gauge",
")",
"{",
"request",
".",
"setAttribute",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"(",
"(",
"Gauge",
"<",
"?",
">",
")",
"entry",
".",
"getValue",
"(",
")",
")",
".",
"getValue",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
"instanceof",
"Counter",
")",
"{",
"request",
".",
"setAttribute",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"(",
"(",
"Counter",
")",
"entry",
".",
"getValue",
"(",
")",
")",
".",
"getCount",
"(",
")",
")",
";",
"}",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Counter",
">",
"entry",
":",
"rpcInvocations",
".",
"entrySet",
"(",
")",
")",
"{",
"request",
".",
"setAttribute",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
".",
"getCount",
"(",
")",
")",
";",
"}",
"}"
] |
Populates operation metrics for displaying in the UI.
@param request The {@link HttpServletRequest} object
|
[
"Populates",
"operation",
"metrics",
"for",
"displaying",
"in",
"the",
"UI",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/web/WebInterfaceAbstractMetricsServlet.java#L47-L61
|
18,959
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/io/BufferUtils.java
|
BufferUtils.cleanDirectBuffer
|
public static synchronized void cleanDirectBuffer(ByteBuffer buffer) {
Preconditions.checkNotNull(buffer, "buffer");
Preconditions.checkArgument(buffer.isDirect(), "buffer isn't a DirectByteBuffer");
try {
if (sByteBufferCleanerMethod == null) {
sByteBufferCleanerMethod = buffer.getClass().getMethod("cleaner");
sByteBufferCleanerMethod.setAccessible(true);
}
final Object cleaner = sByteBufferCleanerMethod.invoke(buffer);
if (cleaner == null) {
if (buffer.capacity() > 0) {
LOG.warn("Failed to get cleaner for ByteBuffer: {}", buffer.getClass().getName());
}
// The cleaner could be null when the buffer is initialized as zero capacity.
return;
}
if (sCleanerCleanMethod == null) {
sCleanerCleanMethod = cleaner.getClass().getMethod("clean");
}
sCleanerCleanMethod.invoke(cleaner);
} catch (Exception e) {
LOG.warn("Failed to unmap direct ByteBuffer: {}, error message: {}",
buffer.getClass().getName(), e.getMessage());
} finally {
// Force to drop reference to the buffer to clean
buffer = null;
}
}
|
java
|
public static synchronized void cleanDirectBuffer(ByteBuffer buffer) {
Preconditions.checkNotNull(buffer, "buffer");
Preconditions.checkArgument(buffer.isDirect(), "buffer isn't a DirectByteBuffer");
try {
if (sByteBufferCleanerMethod == null) {
sByteBufferCleanerMethod = buffer.getClass().getMethod("cleaner");
sByteBufferCleanerMethod.setAccessible(true);
}
final Object cleaner = sByteBufferCleanerMethod.invoke(buffer);
if (cleaner == null) {
if (buffer.capacity() > 0) {
LOG.warn("Failed to get cleaner for ByteBuffer: {}", buffer.getClass().getName());
}
// The cleaner could be null when the buffer is initialized as zero capacity.
return;
}
if (sCleanerCleanMethod == null) {
sCleanerCleanMethod = cleaner.getClass().getMethod("clean");
}
sCleanerCleanMethod.invoke(cleaner);
} catch (Exception e) {
LOG.warn("Failed to unmap direct ByteBuffer: {}, error message: {}",
buffer.getClass().getName(), e.getMessage());
} finally {
// Force to drop reference to the buffer to clean
buffer = null;
}
}
|
[
"public",
"static",
"synchronized",
"void",
"cleanDirectBuffer",
"(",
"ByteBuffer",
"buffer",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"buffer",
",",
"\"buffer\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"buffer",
".",
"isDirect",
"(",
")",
",",
"\"buffer isn't a DirectByteBuffer\"",
")",
";",
"try",
"{",
"if",
"(",
"sByteBufferCleanerMethod",
"==",
"null",
")",
"{",
"sByteBufferCleanerMethod",
"=",
"buffer",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"\"cleaner\"",
")",
";",
"sByteBufferCleanerMethod",
".",
"setAccessible",
"(",
"true",
")",
";",
"}",
"final",
"Object",
"cleaner",
"=",
"sByteBufferCleanerMethod",
".",
"invoke",
"(",
"buffer",
")",
";",
"if",
"(",
"cleaner",
"==",
"null",
")",
"{",
"if",
"(",
"buffer",
".",
"capacity",
"(",
")",
">",
"0",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to get cleaner for ByteBuffer: {}\"",
",",
"buffer",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"// The cleaner could be null when the buffer is initialized as zero capacity.",
"return",
";",
"}",
"if",
"(",
"sCleanerCleanMethod",
"==",
"null",
")",
"{",
"sCleanerCleanMethod",
"=",
"cleaner",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"\"clean\"",
")",
";",
"}",
"sCleanerCleanMethod",
".",
"invoke",
"(",
"cleaner",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to unmap direct ByteBuffer: {}, error message: {}\"",
",",
"buffer",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"finally",
"{",
"// Force to drop reference to the buffer to clean",
"buffer",
"=",
"null",
";",
"}",
"}"
] |
Forces to unmap a direct buffer if this buffer is no longer used. After calling this method,
this direct buffer should be discarded. This is unsafe operation and currently a work-around to
avoid huge memory occupation caused by memory map.
<p>
NOTE: DirectByteBuffers are not guaranteed to be garbage-collected immediately after their
references are released and may lead to OutOfMemoryError. This function helps by calling the
Cleaner method of a DirectByteBuffer explicitly. See <a
href="http://stackoverflow.com/questions/1854398/how-to-garbage-collect-a-direct-buffer-java"
>more discussion</a>.
@param buffer the byte buffer to be unmapped, this must be a direct buffer
|
[
"Forces",
"to",
"unmap",
"a",
"direct",
"buffer",
"if",
"this",
"buffer",
"is",
"no",
"longer",
"used",
".",
"After",
"calling",
"this",
"method",
"this",
"direct",
"buffer",
"should",
"be",
"discarded",
".",
"This",
"is",
"unsafe",
"operation",
"and",
"currently",
"a",
"work",
"-",
"around",
"to",
"avoid",
"huge",
"memory",
"occupation",
"caused",
"by",
"memory",
"map",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/io/BufferUtils.java#L63-L90
|
18,960
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/io/BufferUtils.java
|
BufferUtils.getIncreasingByteArray
|
public static byte[] getIncreasingByteArray(int start, int len) {
byte[] ret = new byte[len];
for (int k = 0; k < len; k++) {
ret[k] = (byte) (k + start);
}
return ret;
}
|
java
|
public static byte[] getIncreasingByteArray(int start, int len) {
byte[] ret = new byte[len];
for (int k = 0; k < len; k++) {
ret[k] = (byte) (k + start);
}
return ret;
}
|
[
"public",
"static",
"byte",
"[",
"]",
"getIncreasingByteArray",
"(",
"int",
"start",
",",
"int",
"len",
")",
"{",
"byte",
"[",
"]",
"ret",
"=",
"new",
"byte",
"[",
"len",
"]",
";",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"len",
";",
"k",
"++",
")",
"{",
"ret",
"[",
"k",
"]",
"=",
"(",
"byte",
")",
"(",
"k",
"+",
"start",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Gets an increasing sequence of bytes starting with the given value.
@param start the starting value to use
@param len the target length of the sequence
@return an increasing sequence of bytes
|
[
"Gets",
"an",
"increasing",
"sequence",
"of",
"bytes",
"starting",
"with",
"the",
"given",
"value",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/io/BufferUtils.java#L154-L160
|
18,961
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/io/BufferUtils.java
|
BufferUtils.equalConstantByteArray
|
public static boolean equalConstantByteArray(byte value, int len, byte[] arr) {
if (arr == null || arr.length != len) {
return false;
}
for (int k = 0; k < len; k++) {
if (arr[k] != value) {
return false;
}
}
return true;
}
|
java
|
public static boolean equalConstantByteArray(byte value, int len, byte[] arr) {
if (arr == null || arr.length != len) {
return false;
}
for (int k = 0; k < len; k++) {
if (arr[k] != value) {
return false;
}
}
return true;
}
|
[
"public",
"static",
"boolean",
"equalConstantByteArray",
"(",
"byte",
"value",
",",
"int",
"len",
",",
"byte",
"[",
"]",
"arr",
")",
"{",
"if",
"(",
"arr",
"==",
"null",
"||",
"arr",
".",
"length",
"!=",
"len",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"len",
";",
"k",
"++",
")",
"{",
"if",
"(",
"arr",
"[",
"k",
"]",
"!=",
"value",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Checks if the given byte array starts with a constant sequence of bytes of the given value
and length.
@param value the value to check for
@param len the target length of the sequence
@param arr the byte array to check
@return true if the byte array has a prefix of length {@code len} that is a constant
sequence of bytes of the given value
|
[
"Checks",
"if",
"the",
"given",
"byte",
"array",
"starts",
"with",
"a",
"constant",
"sequence",
"of",
"bytes",
"of",
"the",
"given",
"value",
"and",
"length",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/io/BufferUtils.java#L172-L182
|
18,962
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/io/BufferUtils.java
|
BufferUtils.equalIncreasingByteArray
|
public static boolean equalIncreasingByteArray(int start, int len, byte[] arr) {
if (arr == null || arr.length != len) {
return false;
}
for (int k = 0; k < len; k++) {
if (arr[k] != (byte) (start + k)) {
return false;
}
}
return true;
}
|
java
|
public static boolean equalIncreasingByteArray(int start, int len, byte[] arr) {
if (arr == null || arr.length != len) {
return false;
}
for (int k = 0; k < len; k++) {
if (arr[k] != (byte) (start + k)) {
return false;
}
}
return true;
}
|
[
"public",
"static",
"boolean",
"equalIncreasingByteArray",
"(",
"int",
"start",
",",
"int",
"len",
",",
"byte",
"[",
"]",
"arr",
")",
"{",
"if",
"(",
"arr",
"==",
"null",
"||",
"arr",
".",
"length",
"!=",
"len",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"int",
"k",
"=",
"0",
";",
"k",
"<",
"len",
";",
"k",
"++",
")",
"{",
"if",
"(",
"arr",
"[",
"k",
"]",
"!=",
"(",
"byte",
")",
"(",
"start",
"+",
"k",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Checks if the given byte array starts with an increasing sequence of bytes of the given
length, starting from the given value. The array length must be equal to the length checked.
@param start the starting value to use
@param len the target length of the sequence
@param arr the byte array to check
@return true if the byte array has a prefix of length {@code len} that is an increasing
sequence of bytes starting at {@code start}
|
[
"Checks",
"if",
"the",
"given",
"byte",
"array",
"starts",
"with",
"an",
"increasing",
"sequence",
"of",
"bytes",
"of",
"the",
"given",
"length",
"starting",
"from",
"the",
"given",
"value",
".",
"The",
"array",
"length",
"must",
"be",
"equal",
"to",
"the",
"length",
"checked",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/io/BufferUtils.java#L207-L217
|
18,963
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/io/BufferUtils.java
|
BufferUtils.writeBufferToFile
|
public static void writeBufferToFile(String path, byte[] buffer) throws IOException {
try (FileOutputStream os = new FileOutputStream(path)) {
os.write(buffer);
}
}
|
java
|
public static void writeBufferToFile(String path, byte[] buffer) throws IOException {
try (FileOutputStream os = new FileOutputStream(path)) {
os.write(buffer);
}
}
|
[
"public",
"static",
"void",
"writeBufferToFile",
"(",
"String",
"path",
",",
"byte",
"[",
"]",
"buffer",
")",
"throws",
"IOException",
"{",
"try",
"(",
"FileOutputStream",
"os",
"=",
"new",
"FileOutputStream",
"(",
"path",
")",
")",
"{",
"os",
".",
"write",
"(",
"buffer",
")",
";",
"}",
"}"
] |
Writes buffer to the given file path.
@param path file path to write the data
@param buffer raw data
|
[
"Writes",
"buffer",
"to",
"the",
"given",
"file",
"path",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/io/BufferUtils.java#L273-L277
|
18,964
|
Alluxio/alluxio
|
job/server/src/main/java/alluxio/master/job/JobCoordinator.java
|
JobCoordinator.cancel
|
public synchronized void cancel() {
for (int taskId : mJobInfo.getTaskIdList()) {
mCommandManager.submitCancelTaskCommand(mJobInfo.getId(), taskId,
mTaskIdToWorkerInfo.get(taskId).getId());
}
}
|
java
|
public synchronized void cancel() {
for (int taskId : mJobInfo.getTaskIdList()) {
mCommandManager.submitCancelTaskCommand(mJobInfo.getId(), taskId,
mTaskIdToWorkerInfo.get(taskId).getId());
}
}
|
[
"public",
"synchronized",
"void",
"cancel",
"(",
")",
"{",
"for",
"(",
"int",
"taskId",
":",
"mJobInfo",
".",
"getTaskIdList",
"(",
")",
")",
"{",
"mCommandManager",
".",
"submitCancelTaskCommand",
"(",
"mJobInfo",
".",
"getId",
"(",
")",
",",
"taskId",
",",
"mTaskIdToWorkerInfo",
".",
"get",
"(",
"taskId",
")",
".",
"getId",
"(",
")",
")",
";",
"}",
"}"
] |
Cancels the current job.
|
[
"Cancels",
"the",
"current",
"job",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/server/src/main/java/alluxio/master/job/JobCoordinator.java#L143-L148
|
18,965
|
Alluxio/alluxio
|
job/server/src/main/java/alluxio/master/job/JobCoordinator.java
|
JobCoordinator.updateTasks
|
public synchronized void updateTasks(List<TaskInfo> taskInfoList) {
for (TaskInfo taskInfo : taskInfoList) {
mJobInfo.setTaskInfo(taskInfo.getTaskId(), taskInfo);
}
updateStatus();
}
|
java
|
public synchronized void updateTasks(List<TaskInfo> taskInfoList) {
for (TaskInfo taskInfo : taskInfoList) {
mJobInfo.setTaskInfo(taskInfo.getTaskId(), taskInfo);
}
updateStatus();
}
|
[
"public",
"synchronized",
"void",
"updateTasks",
"(",
"List",
"<",
"TaskInfo",
">",
"taskInfoList",
")",
"{",
"for",
"(",
"TaskInfo",
"taskInfo",
":",
"taskInfoList",
")",
"{",
"mJobInfo",
".",
"setTaskInfo",
"(",
"taskInfo",
".",
"getTaskId",
"(",
")",
",",
"taskInfo",
")",
";",
"}",
"updateStatus",
"(",
")",
";",
"}"
] |
Updates internal status with given tasks.
@param taskInfoList List of @TaskInfo instances to update
|
[
"Updates",
"internal",
"status",
"with",
"given",
"tasks",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/server/src/main/java/alluxio/master/job/JobCoordinator.java#L155-L160
|
18,966
|
Alluxio/alluxio
|
job/server/src/main/java/alluxio/master/job/JobCoordinator.java
|
JobCoordinator.setJobAsFailed
|
public synchronized void setJobAsFailed(String errorMessage) {
mJobInfo.setStatus(Status.FAILED);
mJobInfo.setErrorMessage(errorMessage);
}
|
java
|
public synchronized void setJobAsFailed(String errorMessage) {
mJobInfo.setStatus(Status.FAILED);
mJobInfo.setErrorMessage(errorMessage);
}
|
[
"public",
"synchronized",
"void",
"setJobAsFailed",
"(",
"String",
"errorMessage",
")",
"{",
"mJobInfo",
".",
"setStatus",
"(",
"Status",
".",
"FAILED",
")",
";",
"mJobInfo",
".",
"setErrorMessage",
"(",
"errorMessage",
")",
";",
"}"
] |
Sets the job as failed with given error message.
@param errorMessage Error message to set for failure
|
[
"Sets",
"the",
"job",
"as",
"failed",
"with",
"given",
"error",
"message",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/server/src/main/java/alluxio/master/job/JobCoordinator.java#L174-L177
|
18,967
|
Alluxio/alluxio
|
job/server/src/main/java/alluxio/master/job/JobCoordinator.java
|
JobCoordinator.failTasksForWorker
|
public synchronized void failTasksForWorker(long workerId) {
Integer taskId = mWorkerIdToTaskId.get(workerId);
if (taskId == null) {
return;
}
TaskInfo taskInfo = mJobInfo.getTaskInfo(taskId);
if (taskInfo.getStatus().isFinished()) {
return;
}
taskInfo.setStatus(Status.FAILED);
taskInfo.setErrorMessage("Job worker was lost before the task could complete");
updateStatus();
}
|
java
|
public synchronized void failTasksForWorker(long workerId) {
Integer taskId = mWorkerIdToTaskId.get(workerId);
if (taskId == null) {
return;
}
TaskInfo taskInfo = mJobInfo.getTaskInfo(taskId);
if (taskInfo.getStatus().isFinished()) {
return;
}
taskInfo.setStatus(Status.FAILED);
taskInfo.setErrorMessage("Job worker was lost before the task could complete");
updateStatus();
}
|
[
"public",
"synchronized",
"void",
"failTasksForWorker",
"(",
"long",
"workerId",
")",
"{",
"Integer",
"taskId",
"=",
"mWorkerIdToTaskId",
".",
"get",
"(",
"workerId",
")",
";",
"if",
"(",
"taskId",
"==",
"null",
")",
"{",
"return",
";",
"}",
"TaskInfo",
"taskInfo",
"=",
"mJobInfo",
".",
"getTaskInfo",
"(",
"taskId",
")",
";",
"if",
"(",
"taskInfo",
".",
"getStatus",
"(",
")",
".",
"isFinished",
"(",
")",
")",
"{",
"return",
";",
"}",
"taskInfo",
".",
"setStatus",
"(",
"Status",
".",
"FAILED",
")",
";",
"taskInfo",
".",
"setErrorMessage",
"(",
"\"Job worker was lost before the task could complete\"",
")",
";",
"updateStatus",
"(",
")",
";",
"}"
] |
Fails any incomplete tasks being run on the specified worker.
@param workerId the id of the worker to fail tasks for
|
[
"Fails",
"any",
"incomplete",
"tasks",
"being",
"run",
"on",
"the",
"specified",
"worker",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/server/src/main/java/alluxio/master/job/JobCoordinator.java#L184-L196
|
18,968
|
Alluxio/alluxio
|
job/server/src/main/java/alluxio/master/job/JobCoordinator.java
|
JobCoordinator.updateStatus
|
private void updateStatus() {
int completed = 0;
List<TaskInfo> taskInfoList = mJobInfo.getTaskInfoList();
for (TaskInfo info : taskInfoList) {
switch (info.getStatus()) {
case FAILED:
mJobInfo.setStatus(Status.FAILED);
if (mJobInfo.getErrorMessage().isEmpty()) {
mJobInfo.setErrorMessage("Task execution failed: " + info.getErrorMessage());
}
return;
case CANCELED:
if (mJobInfo.getStatus() != Status.FAILED) {
mJobInfo.setStatus(Status.CANCELED);
}
return;
case RUNNING:
if (mJobInfo.getStatus() != Status.FAILED && mJobInfo.getStatus() != Status.CANCELED) {
mJobInfo.setStatus(Status.RUNNING);
}
break;
case COMPLETED:
completed++;
break;
case CREATED:
// do nothing
break;
default:
throw new IllegalArgumentException("Unsupported status " + info.getStatus());
}
}
if (completed == taskInfoList.size()) {
if (mJobInfo.getStatus() == Status.COMPLETED) {
return;
}
// all the tasks completed, run join
try {
mJobInfo.setStatus(Status.COMPLETED);
mJobInfo.setResult(join(taskInfoList));
} catch (Exception e) {
mJobInfo.setStatus(Status.FAILED);
mJobInfo.setErrorMessage(e.getMessage());
}
}
}
|
java
|
private void updateStatus() {
int completed = 0;
List<TaskInfo> taskInfoList = mJobInfo.getTaskInfoList();
for (TaskInfo info : taskInfoList) {
switch (info.getStatus()) {
case FAILED:
mJobInfo.setStatus(Status.FAILED);
if (mJobInfo.getErrorMessage().isEmpty()) {
mJobInfo.setErrorMessage("Task execution failed: " + info.getErrorMessage());
}
return;
case CANCELED:
if (mJobInfo.getStatus() != Status.FAILED) {
mJobInfo.setStatus(Status.CANCELED);
}
return;
case RUNNING:
if (mJobInfo.getStatus() != Status.FAILED && mJobInfo.getStatus() != Status.CANCELED) {
mJobInfo.setStatus(Status.RUNNING);
}
break;
case COMPLETED:
completed++;
break;
case CREATED:
// do nothing
break;
default:
throw new IllegalArgumentException("Unsupported status " + info.getStatus());
}
}
if (completed == taskInfoList.size()) {
if (mJobInfo.getStatus() == Status.COMPLETED) {
return;
}
// all the tasks completed, run join
try {
mJobInfo.setStatus(Status.COMPLETED);
mJobInfo.setResult(join(taskInfoList));
} catch (Exception e) {
mJobInfo.setStatus(Status.FAILED);
mJobInfo.setErrorMessage(e.getMessage());
}
}
}
|
[
"private",
"void",
"updateStatus",
"(",
")",
"{",
"int",
"completed",
"=",
"0",
";",
"List",
"<",
"TaskInfo",
">",
"taskInfoList",
"=",
"mJobInfo",
".",
"getTaskInfoList",
"(",
")",
";",
"for",
"(",
"TaskInfo",
"info",
":",
"taskInfoList",
")",
"{",
"switch",
"(",
"info",
".",
"getStatus",
"(",
")",
")",
"{",
"case",
"FAILED",
":",
"mJobInfo",
".",
"setStatus",
"(",
"Status",
".",
"FAILED",
")",
";",
"if",
"(",
"mJobInfo",
".",
"getErrorMessage",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"mJobInfo",
".",
"setErrorMessage",
"(",
"\"Task execution failed: \"",
"+",
"info",
".",
"getErrorMessage",
"(",
")",
")",
";",
"}",
"return",
";",
"case",
"CANCELED",
":",
"if",
"(",
"mJobInfo",
".",
"getStatus",
"(",
")",
"!=",
"Status",
".",
"FAILED",
")",
"{",
"mJobInfo",
".",
"setStatus",
"(",
"Status",
".",
"CANCELED",
")",
";",
"}",
"return",
";",
"case",
"RUNNING",
":",
"if",
"(",
"mJobInfo",
".",
"getStatus",
"(",
")",
"!=",
"Status",
".",
"FAILED",
"&&",
"mJobInfo",
".",
"getStatus",
"(",
")",
"!=",
"Status",
".",
"CANCELED",
")",
"{",
"mJobInfo",
".",
"setStatus",
"(",
"Status",
".",
"RUNNING",
")",
";",
"}",
"break",
";",
"case",
"COMPLETED",
":",
"completed",
"++",
";",
"break",
";",
"case",
"CREATED",
":",
"// do nothing",
"break",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported status \"",
"+",
"info",
".",
"getStatus",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"completed",
"==",
"taskInfoList",
".",
"size",
"(",
")",
")",
"{",
"if",
"(",
"mJobInfo",
".",
"getStatus",
"(",
")",
"==",
"Status",
".",
"COMPLETED",
")",
"{",
"return",
";",
"}",
"// all the tasks completed, run join",
"try",
"{",
"mJobInfo",
".",
"setStatus",
"(",
"Status",
".",
"COMPLETED",
")",
";",
"mJobInfo",
".",
"setResult",
"(",
"join",
"(",
"taskInfoList",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"mJobInfo",
".",
"setStatus",
"(",
"Status",
".",
"FAILED",
")",
";",
"mJobInfo",
".",
"setErrorMessage",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Updates the status of the job. When all the tasks are completed, run the join method in the
definition.
|
[
"Updates",
"the",
"status",
"of",
"the",
"job",
".",
"When",
"all",
"the",
"tasks",
"are",
"completed",
"run",
"the",
"join",
"method",
"in",
"the",
"definition",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/server/src/main/java/alluxio/master/job/JobCoordinator.java#L209-L254
|
18,969
|
Alluxio/alluxio
|
job/server/src/main/java/alluxio/master/job/JobCoordinator.java
|
JobCoordinator.join
|
private String join(List<TaskInfo> taskInfoList) throws Exception {
// get the job definition
JobDefinition<JobConfig, Serializable, Serializable> definition =
JobDefinitionRegistry.INSTANCE.getJobDefinition(mJobInfo.getJobConfig());
Map<WorkerInfo, Serializable> taskResults = Maps.newHashMap();
for (TaskInfo taskInfo : taskInfoList) {
taskResults.put(mTaskIdToWorkerInfo.get(taskInfo.getTaskId()), taskInfo.getResult());
}
return definition.join(mJobInfo.getJobConfig(), taskResults);
}
|
java
|
private String join(List<TaskInfo> taskInfoList) throws Exception {
// get the job definition
JobDefinition<JobConfig, Serializable, Serializable> definition =
JobDefinitionRegistry.INSTANCE.getJobDefinition(mJobInfo.getJobConfig());
Map<WorkerInfo, Serializable> taskResults = Maps.newHashMap();
for (TaskInfo taskInfo : taskInfoList) {
taskResults.put(mTaskIdToWorkerInfo.get(taskInfo.getTaskId()), taskInfo.getResult());
}
return definition.join(mJobInfo.getJobConfig(), taskResults);
}
|
[
"private",
"String",
"join",
"(",
"List",
"<",
"TaskInfo",
">",
"taskInfoList",
")",
"throws",
"Exception",
"{",
"// get the job definition",
"JobDefinition",
"<",
"JobConfig",
",",
"Serializable",
",",
"Serializable",
">",
"definition",
"=",
"JobDefinitionRegistry",
".",
"INSTANCE",
".",
"getJobDefinition",
"(",
"mJobInfo",
".",
"getJobConfig",
"(",
")",
")",
";",
"Map",
"<",
"WorkerInfo",
",",
"Serializable",
">",
"taskResults",
"=",
"Maps",
".",
"newHashMap",
"(",
")",
";",
"for",
"(",
"TaskInfo",
"taskInfo",
":",
"taskInfoList",
")",
"{",
"taskResults",
".",
"put",
"(",
"mTaskIdToWorkerInfo",
".",
"get",
"(",
"taskInfo",
".",
"getTaskId",
"(",
")",
")",
",",
"taskInfo",
".",
"getResult",
"(",
")",
")",
";",
"}",
"return",
"definition",
".",
"join",
"(",
"mJobInfo",
".",
"getJobConfig",
"(",
")",
",",
"taskResults",
")",
";",
"}"
] |
Joins the task results and produces a final result.
@param taskInfoList the list of task information
@return the aggregated result as a String
@throws Exception if any error occurs
|
[
"Joins",
"the",
"task",
"results",
"and",
"produces",
"a",
"final",
"result",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/server/src/main/java/alluxio/master/job/JobCoordinator.java#L263-L272
|
18,970
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/underfs/MultiRangeObjectInputStream.java
|
MultiRangeObjectInputStream.openStream
|
private void openStream() throws IOException {
if (mClosed) {
throw new IOException("Stream closed");
}
if (mMultiRangeChunkSize <= 0) {
throw new IOException(ExceptionMessage.BLOCK_SIZE_INVALID.getMessage(mMultiRangeChunkSize));
}
if (mStream != null) { // stream is already open
return;
}
final long endPos = mPos + mMultiRangeChunkSize - (mPos % mMultiRangeChunkSize);
mEndPos = endPos;
mStream = createStream(mPos, endPos);
}
|
java
|
private void openStream() throws IOException {
if (mClosed) {
throw new IOException("Stream closed");
}
if (mMultiRangeChunkSize <= 0) {
throw new IOException(ExceptionMessage.BLOCK_SIZE_INVALID.getMessage(mMultiRangeChunkSize));
}
if (mStream != null) { // stream is already open
return;
}
final long endPos = mPos + mMultiRangeChunkSize - (mPos % mMultiRangeChunkSize);
mEndPos = endPos;
mStream = createStream(mPos, endPos);
}
|
[
"private",
"void",
"openStream",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mClosed",
")",
"{",
"throw",
"new",
"IOException",
"(",
"\"Stream closed\"",
")",
";",
"}",
"if",
"(",
"mMultiRangeChunkSize",
"<=",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"ExceptionMessage",
".",
"BLOCK_SIZE_INVALID",
".",
"getMessage",
"(",
"mMultiRangeChunkSize",
")",
")",
";",
"}",
"if",
"(",
"mStream",
"!=",
"null",
")",
"{",
"// stream is already open",
"return",
";",
"}",
"final",
"long",
"endPos",
"=",
"mPos",
"+",
"mMultiRangeChunkSize",
"-",
"(",
"mPos",
"%",
"mMultiRangeChunkSize",
")",
";",
"mEndPos",
"=",
"endPos",
";",
"mStream",
"=",
"createStream",
"(",
"mPos",
",",
"endPos",
")",
";",
"}"
] |
Opens a new stream at mPos if the wrapped stream mStream is null.
|
[
"Opens",
"a",
"new",
"stream",
"at",
"mPos",
"if",
"the",
"wrapped",
"stream",
"mStream",
"is",
"null",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/underfs/MultiRangeObjectInputStream.java#L134-L148
|
18,971
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalSnapshot.java
|
UfsJournalSnapshot.getSnapshot
|
public static UfsJournalSnapshot getSnapshot(UfsJournal journal) throws IOException {
// Checkpoints.
List<UfsJournalFile> checkpoints = new ArrayList<>();
UfsStatus[] statuses = journal.getUfs().listStatus(journal.getCheckpointDir().toString());
if (statuses != null) {
for (UfsStatus status : statuses) {
UfsJournalFile file = UfsJournalFile.decodeCheckpointFile(journal, status.getName());
if (file != null) {
checkpoints.add(file);
}
}
Collections.sort(checkpoints);
}
List<UfsJournalFile> logs = new ArrayList<>();
statuses = journal.getUfs().listStatus(journal.getLogDir().toString());
if (statuses != null) {
for (UfsStatus status : statuses) {
UfsJournalFile file = UfsJournalFile.decodeLogFile(journal, status.getName());
if (file != null) {
logs.add(file);
}
}
Collections.sort(logs);
}
List<UfsJournalFile> tmpCheckpoints = new ArrayList<>();
statuses = journal.getUfs().listStatus(journal.getTmpDir().toString());
if (statuses != null) {
for (UfsStatus status : statuses) {
tmpCheckpoints.add(UfsJournalFile.decodeTemporaryCheckpointFile(journal, status.getName()));
}
}
return new UfsJournalSnapshot(checkpoints, logs, tmpCheckpoints);
}
|
java
|
public static UfsJournalSnapshot getSnapshot(UfsJournal journal) throws IOException {
// Checkpoints.
List<UfsJournalFile> checkpoints = new ArrayList<>();
UfsStatus[] statuses = journal.getUfs().listStatus(journal.getCheckpointDir().toString());
if (statuses != null) {
for (UfsStatus status : statuses) {
UfsJournalFile file = UfsJournalFile.decodeCheckpointFile(journal, status.getName());
if (file != null) {
checkpoints.add(file);
}
}
Collections.sort(checkpoints);
}
List<UfsJournalFile> logs = new ArrayList<>();
statuses = journal.getUfs().listStatus(journal.getLogDir().toString());
if (statuses != null) {
for (UfsStatus status : statuses) {
UfsJournalFile file = UfsJournalFile.decodeLogFile(journal, status.getName());
if (file != null) {
logs.add(file);
}
}
Collections.sort(logs);
}
List<UfsJournalFile> tmpCheckpoints = new ArrayList<>();
statuses = journal.getUfs().listStatus(journal.getTmpDir().toString());
if (statuses != null) {
for (UfsStatus status : statuses) {
tmpCheckpoints.add(UfsJournalFile.decodeTemporaryCheckpointFile(journal, status.getName()));
}
}
return new UfsJournalSnapshot(checkpoints, logs, tmpCheckpoints);
}
|
[
"public",
"static",
"UfsJournalSnapshot",
"getSnapshot",
"(",
"UfsJournal",
"journal",
")",
"throws",
"IOException",
"{",
"// Checkpoints.",
"List",
"<",
"UfsJournalFile",
">",
"checkpoints",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"UfsStatus",
"[",
"]",
"statuses",
"=",
"journal",
".",
"getUfs",
"(",
")",
".",
"listStatus",
"(",
"journal",
".",
"getCheckpointDir",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"statuses",
"!=",
"null",
")",
"{",
"for",
"(",
"UfsStatus",
"status",
":",
"statuses",
")",
"{",
"UfsJournalFile",
"file",
"=",
"UfsJournalFile",
".",
"decodeCheckpointFile",
"(",
"journal",
",",
"status",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"file",
"!=",
"null",
")",
"{",
"checkpoints",
".",
"add",
"(",
"file",
")",
";",
"}",
"}",
"Collections",
".",
"sort",
"(",
"checkpoints",
")",
";",
"}",
"List",
"<",
"UfsJournalFile",
">",
"logs",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"statuses",
"=",
"journal",
".",
"getUfs",
"(",
")",
".",
"listStatus",
"(",
"journal",
".",
"getLogDir",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"statuses",
"!=",
"null",
")",
"{",
"for",
"(",
"UfsStatus",
"status",
":",
"statuses",
")",
"{",
"UfsJournalFile",
"file",
"=",
"UfsJournalFile",
".",
"decodeLogFile",
"(",
"journal",
",",
"status",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"file",
"!=",
"null",
")",
"{",
"logs",
".",
"add",
"(",
"file",
")",
";",
"}",
"}",
"Collections",
".",
"sort",
"(",
"logs",
")",
";",
"}",
"List",
"<",
"UfsJournalFile",
">",
"tmpCheckpoints",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"statuses",
"=",
"journal",
".",
"getUfs",
"(",
")",
".",
"listStatus",
"(",
"journal",
".",
"getTmpDir",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"statuses",
"!=",
"null",
")",
"{",
"for",
"(",
"UfsStatus",
"status",
":",
"statuses",
")",
"{",
"tmpCheckpoints",
".",
"add",
"(",
"UfsJournalFile",
".",
"decodeTemporaryCheckpointFile",
"(",
"journal",
",",
"status",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"}",
"return",
"new",
"UfsJournalSnapshot",
"(",
"checkpoints",
",",
"logs",
",",
"tmpCheckpoints",
")",
";",
"}"
] |
Creates a snapshot of the journal.
@param journal the journal
@return the journal snapshot
|
[
"Creates",
"a",
"snapshot",
"of",
"the",
"journal",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalSnapshot.java#L89-L124
|
18,972
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalSnapshot.java
|
UfsJournalSnapshot.getNextLogSequenceNumberToCheckpoint
|
static long getNextLogSequenceNumberToCheckpoint(UfsJournal journal) throws IOException {
List<UfsJournalFile> checkpoints = new ArrayList<>();
UfsStatus[] statuses = journal.getUfs().listStatus(journal.getCheckpointDir().toString());
if (statuses != null) {
for (UfsStatus status : statuses) {
UfsJournalFile file = UfsJournalFile.decodeCheckpointFile(journal, status.getName());
if (file != null) {
checkpoints.add(file);
}
}
Collections.sort(checkpoints);
}
if (checkpoints.isEmpty()) {
return 0;
}
return checkpoints.get(checkpoints.size() - 1).getEnd();
}
|
java
|
static long getNextLogSequenceNumberToCheckpoint(UfsJournal journal) throws IOException {
List<UfsJournalFile> checkpoints = new ArrayList<>();
UfsStatus[] statuses = journal.getUfs().listStatus(journal.getCheckpointDir().toString());
if (statuses != null) {
for (UfsStatus status : statuses) {
UfsJournalFile file = UfsJournalFile.decodeCheckpointFile(journal, status.getName());
if (file != null) {
checkpoints.add(file);
}
}
Collections.sort(checkpoints);
}
if (checkpoints.isEmpty()) {
return 0;
}
return checkpoints.get(checkpoints.size() - 1).getEnd();
}
|
[
"static",
"long",
"getNextLogSequenceNumberToCheckpoint",
"(",
"UfsJournal",
"journal",
")",
"throws",
"IOException",
"{",
"List",
"<",
"UfsJournalFile",
">",
"checkpoints",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"UfsStatus",
"[",
"]",
"statuses",
"=",
"journal",
".",
"getUfs",
"(",
")",
".",
"listStatus",
"(",
"journal",
".",
"getCheckpointDir",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"statuses",
"!=",
"null",
")",
"{",
"for",
"(",
"UfsStatus",
"status",
":",
"statuses",
")",
"{",
"UfsJournalFile",
"file",
"=",
"UfsJournalFile",
".",
"decodeCheckpointFile",
"(",
"journal",
",",
"status",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"file",
"!=",
"null",
")",
"{",
"checkpoints",
".",
"add",
"(",
"file",
")",
";",
"}",
"}",
"Collections",
".",
"sort",
"(",
"checkpoints",
")",
";",
"}",
"if",
"(",
"checkpoints",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"return",
"checkpoints",
".",
"get",
"(",
"checkpoints",
".",
"size",
"(",
")",
"-",
"1",
")",
".",
"getEnd",
"(",
")",
";",
"}"
] |
Gets the first journal log sequence number that is not yet checkpointed.
@return the first journal log sequence number that is not yet checkpointed
|
[
"Gets",
"the",
"first",
"journal",
"log",
"sequence",
"number",
"that",
"is",
"not",
"yet",
"checkpointed",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalSnapshot.java#L158-L174
|
18,973
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/io/PathUtils.java
|
PathUtils.cleanPath
|
public static String cleanPath(String path) throws InvalidPathException {
validatePath(path);
return FilenameUtils.separatorsToUnix(FilenameUtils.normalizeNoEndSeparator(path));
}
|
java
|
public static String cleanPath(String path) throws InvalidPathException {
validatePath(path);
return FilenameUtils.separatorsToUnix(FilenameUtils.normalizeNoEndSeparator(path));
}
|
[
"public",
"static",
"String",
"cleanPath",
"(",
"String",
"path",
")",
"throws",
"InvalidPathException",
"{",
"validatePath",
"(",
"path",
")",
";",
"return",
"FilenameUtils",
".",
"separatorsToUnix",
"(",
"FilenameUtils",
".",
"normalizeNoEndSeparator",
"(",
"path",
")",
")",
";",
"}"
] |
Checks and normalizes the given path.
@param path The path to clean up
@return a normalized version of the path, with single separators between path components and
dot components resolved
@throws InvalidPathException if the path is invalid
|
[
"Checks",
"and",
"normalizes",
"the",
"given",
"path",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/io/PathUtils.java#L44-L47
|
18,974
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/io/PathUtils.java
|
PathUtils.getParent
|
public static String getParent(String path) throws InvalidPathException {
String cleanedPath = cleanPath(path);
String name = FilenameUtils.getName(cleanedPath);
String parent = cleanedPath.substring(0, cleanedPath.length() - name.length() - 1);
if (parent.isEmpty()) {
// The parent is the root path.
return AlluxioURI.SEPARATOR;
}
return parent;
}
|
java
|
public static String getParent(String path) throws InvalidPathException {
String cleanedPath = cleanPath(path);
String name = FilenameUtils.getName(cleanedPath);
String parent = cleanedPath.substring(0, cleanedPath.length() - name.length() - 1);
if (parent.isEmpty()) {
// The parent is the root path.
return AlluxioURI.SEPARATOR;
}
return parent;
}
|
[
"public",
"static",
"String",
"getParent",
"(",
"String",
"path",
")",
"throws",
"InvalidPathException",
"{",
"String",
"cleanedPath",
"=",
"cleanPath",
"(",
"path",
")",
";",
"String",
"name",
"=",
"FilenameUtils",
".",
"getName",
"(",
"cleanedPath",
")",
";",
"String",
"parent",
"=",
"cleanedPath",
".",
"substring",
"(",
"0",
",",
"cleanedPath",
".",
"length",
"(",
")",
"-",
"name",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"if",
"(",
"parent",
".",
"isEmpty",
"(",
")",
")",
"{",
"// The parent is the root path.",
"return",
"AlluxioURI",
".",
"SEPARATOR",
";",
"}",
"return",
"parent",
";",
"}"
] |
Gets the parent of the file at a path.
@param path The path
@return the parent path of the file; this is "/" if the given path is the root
@throws InvalidPathException if the path is invalid
|
[
"Gets",
"the",
"parent",
"of",
"the",
"file",
"at",
"a",
"path",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/io/PathUtils.java#L131-L140
|
18,975
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/io/PathUtils.java
|
PathUtils.getPathComponents
|
public static String[] getPathComponents(String path) throws InvalidPathException {
path = cleanPath(path);
if (isRoot(path)) {
return new String[]{""};
}
return path.split(AlluxioURI.SEPARATOR);
}
|
java
|
public static String[] getPathComponents(String path) throws InvalidPathException {
path = cleanPath(path);
if (isRoot(path)) {
return new String[]{""};
}
return path.split(AlluxioURI.SEPARATOR);
}
|
[
"public",
"static",
"String",
"[",
"]",
"getPathComponents",
"(",
"String",
"path",
")",
"throws",
"InvalidPathException",
"{",
"path",
"=",
"cleanPath",
"(",
"path",
")",
";",
"if",
"(",
"isRoot",
"(",
"path",
")",
")",
"{",
"return",
"new",
"String",
"[",
"]",
"{",
"\"\"",
"}",
";",
"}",
"return",
"path",
".",
"split",
"(",
"AlluxioURI",
".",
"SEPARATOR",
")",
";",
"}"
] |
Gets the path components of the given path. The first component will be an empty string.
"/a/b/c" => {"", "a", "b", "c"}
"/" => {""}
@param path The path to split
@return the path split into components
@throws InvalidPathException if the path is invalid
|
[
"Gets",
"the",
"path",
"components",
"of",
"the",
"given",
"path",
".",
"The",
"first",
"component",
"will",
"be",
"an",
"empty",
"string",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/io/PathUtils.java#L152-L158
|
18,976
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/io/PathUtils.java
|
PathUtils.subtractPaths
|
public static String subtractPaths(String path, String prefix) throws InvalidPathException {
String cleanedPath = cleanPath(path);
String cleanedPrefix = cleanPath(prefix);
if (cleanedPath.equals(cleanedPrefix)) {
return "";
}
if (!hasPrefix(cleanedPath, cleanedPrefix)) {
throw new RuntimeException(
String.format("Cannot subtract %s from %s because it is not a prefix", prefix, path));
}
// The only clean path which ends in '/' is the root.
int prefixLen = cleanedPrefix.length();
int charsToDrop = PathUtils.isRoot(cleanedPrefix) ? prefixLen : prefixLen + 1;
return cleanedPath.substring(charsToDrop, cleanedPath.length());
}
|
java
|
public static String subtractPaths(String path, String prefix) throws InvalidPathException {
String cleanedPath = cleanPath(path);
String cleanedPrefix = cleanPath(prefix);
if (cleanedPath.equals(cleanedPrefix)) {
return "";
}
if (!hasPrefix(cleanedPath, cleanedPrefix)) {
throw new RuntimeException(
String.format("Cannot subtract %s from %s because it is not a prefix", prefix, path));
}
// The only clean path which ends in '/' is the root.
int prefixLen = cleanedPrefix.length();
int charsToDrop = PathUtils.isRoot(cleanedPrefix) ? prefixLen : prefixLen + 1;
return cleanedPath.substring(charsToDrop, cleanedPath.length());
}
|
[
"public",
"static",
"String",
"subtractPaths",
"(",
"String",
"path",
",",
"String",
"prefix",
")",
"throws",
"InvalidPathException",
"{",
"String",
"cleanedPath",
"=",
"cleanPath",
"(",
"path",
")",
";",
"String",
"cleanedPrefix",
"=",
"cleanPath",
"(",
"prefix",
")",
";",
"if",
"(",
"cleanedPath",
".",
"equals",
"(",
"cleanedPrefix",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"if",
"(",
"!",
"hasPrefix",
"(",
"cleanedPath",
",",
"cleanedPrefix",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"String",
".",
"format",
"(",
"\"Cannot subtract %s from %s because it is not a prefix\"",
",",
"prefix",
",",
"path",
")",
")",
";",
"}",
"// The only clean path which ends in '/' is the root.",
"int",
"prefixLen",
"=",
"cleanedPrefix",
".",
"length",
"(",
")",
";",
"int",
"charsToDrop",
"=",
"PathUtils",
".",
"isRoot",
"(",
"cleanedPrefix",
")",
"?",
"prefixLen",
":",
"prefixLen",
"+",
"1",
";",
"return",
"cleanedPath",
".",
"substring",
"(",
"charsToDrop",
",",
"cleanedPath",
".",
"length",
"(",
")",
")",
";",
"}"
] |
Removes the prefix from the path, yielding a relative path from the second path to the first.
If the paths are the same, this method returns the empty string.
@param path the full path
@param prefix the prefix to remove
@return the path with the prefix removed
@throws InvalidPathException if either of the arguments are not valid paths
|
[
"Removes",
"the",
"prefix",
"from",
"the",
"path",
"yielding",
"a",
"relative",
"path",
"from",
"the",
"second",
"path",
"to",
"the",
"first",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/io/PathUtils.java#L170-L184
|
18,977
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/io/PathUtils.java
|
PathUtils.validatePath
|
public static void validatePath(String path) throws InvalidPathException {
boolean invalid = (path == null || path.isEmpty());
if (!OSUtils.isWindows()) {
invalid = (invalid || !path.startsWith(AlluxioURI.SEPARATOR));
}
if (invalid) {
throw new InvalidPathException(ExceptionMessage.PATH_INVALID.getMessage(path));
}
}
|
java
|
public static void validatePath(String path) throws InvalidPathException {
boolean invalid = (path == null || path.isEmpty());
if (!OSUtils.isWindows()) {
invalid = (invalid || !path.startsWith(AlluxioURI.SEPARATOR));
}
if (invalid) {
throw new InvalidPathException(ExceptionMessage.PATH_INVALID.getMessage(path));
}
}
|
[
"public",
"static",
"void",
"validatePath",
"(",
"String",
"path",
")",
"throws",
"InvalidPathException",
"{",
"boolean",
"invalid",
"=",
"(",
"path",
"==",
"null",
"||",
"path",
".",
"isEmpty",
"(",
")",
")",
";",
"if",
"(",
"!",
"OSUtils",
".",
"isWindows",
"(",
")",
")",
"{",
"invalid",
"=",
"(",
"invalid",
"||",
"!",
"path",
".",
"startsWith",
"(",
"AlluxioURI",
".",
"SEPARATOR",
")",
")",
";",
"}",
"if",
"(",
"invalid",
")",
"{",
"throw",
"new",
"InvalidPathException",
"(",
"ExceptionMessage",
".",
"PATH_INVALID",
".",
"getMessage",
"(",
"path",
")",
")",
";",
"}",
"}"
] |
Checks if the given path is properly formed.
@param path The path to check
@throws InvalidPathException If the path is not properly formed
|
[
"Checks",
"if",
"the",
"given",
"path",
"is",
"properly",
"formed",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/io/PathUtils.java#L227-L236
|
18,978
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/io/PathUtils.java
|
PathUtils.temporaryFileName
|
public static String temporaryFileName(long nonce, String path) {
return path + String.format(TEMPORARY_SUFFIX_FORMAT, nonce);
}
|
java
|
public static String temporaryFileName(long nonce, String path) {
return path + String.format(TEMPORARY_SUFFIX_FORMAT, nonce);
}
|
[
"public",
"static",
"String",
"temporaryFileName",
"(",
"long",
"nonce",
",",
"String",
"path",
")",
"{",
"return",
"path",
"+",
"String",
".",
"format",
"(",
"TEMPORARY_SUFFIX_FORMAT",
",",
"nonce",
")",
";",
"}"
] |
Generates a deterministic temporary file name for the a path and a file id and a nonce.
@param nonce a nonce token
@param path a file path
@return a deterministic temporary file name
|
[
"Generates",
"a",
"deterministic",
"temporary",
"file",
"name",
"for",
"the",
"a",
"path",
"and",
"a",
"file",
"id",
"and",
"a",
"nonce",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/io/PathUtils.java#L245-L247
|
18,979
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/io/PathUtils.java
|
PathUtils.uniqPath
|
public static String uniqPath() {
StackTraceElement caller = new Throwable().getStackTrace()[1];
long time = System.nanoTime();
return "/" + caller.getClassName() + "/" + caller.getMethodName() + "/" + time;
}
|
java
|
public static String uniqPath() {
StackTraceElement caller = new Throwable().getStackTrace()[1];
long time = System.nanoTime();
return "/" + caller.getClassName() + "/" + caller.getMethodName() + "/" + time;
}
|
[
"public",
"static",
"String",
"uniqPath",
"(",
")",
"{",
"StackTraceElement",
"caller",
"=",
"new",
"Throwable",
"(",
")",
".",
"getStackTrace",
"(",
")",
"[",
"1",
"]",
";",
"long",
"time",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"return",
"\"/\"",
"+",
"caller",
".",
"getClassName",
"(",
")",
"+",
"\"/\"",
"+",
"caller",
".",
"getMethodName",
"(",
")",
"+",
"\"/\"",
"+",
"time",
";",
"}"
] |
Creates a unique path based off the caller.
@return unique path based off the caller
|
[
"Creates",
"a",
"unique",
"path",
"based",
"off",
"the",
"caller",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/io/PathUtils.java#L275-L279
|
18,980
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/io/PathUtils.java
|
PathUtils.normalizePath
|
public static String normalizePath(String path, String separator) {
return path.endsWith(separator) ? path : path + separator;
}
|
java
|
public static String normalizePath(String path, String separator) {
return path.endsWith(separator) ? path : path + separator;
}
|
[
"public",
"static",
"String",
"normalizePath",
"(",
"String",
"path",
",",
"String",
"separator",
")",
"{",
"return",
"path",
".",
"endsWith",
"(",
"separator",
")",
"?",
"path",
":",
"path",
"+",
"separator",
";",
"}"
] |
Adds a trailing separator if it does not exist in path.
@param path the file name
@param separator trailing separator to add
@return updated path with trailing separator
|
[
"Adds",
"a",
"trailing",
"separator",
"if",
"it",
"does",
"not",
"exist",
"in",
"path",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/io/PathUtils.java#L288-L290
|
18,981
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/Worker.java
|
Worker.start
|
public synchronized void start() throws IOException {
Preconditions.checkState(mProcess == null, "Worker is already running");
mProcess = new ExternalProcess(mProperties, LimitedLifeWorkerProcess.class,
new File(mLogsDir, "worker.out"));
mProcess.start();
}
|
java
|
public synchronized void start() throws IOException {
Preconditions.checkState(mProcess == null, "Worker is already running");
mProcess = new ExternalProcess(mProperties, LimitedLifeWorkerProcess.class,
new File(mLogsDir, "worker.out"));
mProcess.start();
}
|
[
"public",
"synchronized",
"void",
"start",
"(",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkState",
"(",
"mProcess",
"==",
"null",
",",
"\"Worker is already running\"",
")",
";",
"mProcess",
"=",
"new",
"ExternalProcess",
"(",
"mProperties",
",",
"LimitedLifeWorkerProcess",
".",
"class",
",",
"new",
"File",
"(",
"mLogsDir",
",",
"\"worker.out\"",
")",
")",
";",
"mProcess",
".",
"start",
"(",
")",
";",
"}"
] |
Launches the worker process.
|
[
"Launches",
"the",
"worker",
"process",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/Worker.java#L51-L56
|
18,982
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/executor/ControllableQueue.java
|
ControllableQueue.add
|
public void add(long delay, T value) {
mQueue.add(new DelayNode<>(value, delay + mPastTime));
}
|
java
|
public void add(long delay, T value) {
mQueue.add(new DelayNode<>(value, delay + mPastTime));
}
|
[
"public",
"void",
"add",
"(",
"long",
"delay",
",",
"T",
"value",
")",
"{",
"mQueue",
".",
"add",
"(",
"new",
"DelayNode",
"<>",
"(",
"value",
",",
"delay",
"+",
"mPastTime",
")",
")",
";",
"}"
] |
Adds a new node into the queue.
@param delay the delay in milliseconds
@param value the value
|
[
"Adds",
"a",
"new",
"node",
"into",
"the",
"queue",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/executor/ControllableQueue.java#L62-L64
|
18,983
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalLogWriter.java
|
UfsJournalLogWriter.maybeRecoverFromUfsFailures
|
private void maybeRecoverFromUfsFailures() throws IOException, JournalClosedException {
if (!mNeedsRecovery) {
return;
}
long lastPersistSeq = recoverLastPersistedJournalEntry();
createNewLogFile(lastPersistSeq + 1);
if (!mEntriesToFlush.isEmpty()) {
JournalEntry firstEntryToFlush = mEntriesToFlush.peek();
if (firstEntryToFlush.getSequenceNumber() > lastPersistSeq + 1) {
throw new RuntimeException(ExceptionMessage.JOURNAL_ENTRY_MISSING.getMessageWithUrl(
RuntimeConstants.ALLUXIO_DEBUG_DOCS_URL,
lastPersistSeq + 1, firstEntryToFlush.getSequenceNumber()));
}
long retryEndSeq = lastPersistSeq;
LOG.info("Retry writing unwritten journal entries from seq {}", lastPersistSeq + 1);
for (JournalEntry entry : mEntriesToFlush) {
if (entry.getSequenceNumber() > lastPersistSeq) {
try {
entry.toBuilder().build().writeDelimitedTo(mJournalOutputStream);
retryEndSeq = entry.getSequenceNumber();
} catch (IOJournalClosedException e) {
throw e.toJournalClosedException();
} catch (IOException e) {
throw new IOException(ExceptionMessage.JOURNAL_WRITE_FAILURE
.getMessageWithUrl(RuntimeConstants.ALLUXIO_DEBUG_DOCS_URL,
mJournalOutputStream.currentLog(), e.getMessage()), e);
}
}
}
LOG.info("Finished writing unwritten journal entries from {} to {}.",
lastPersistSeq + 1, retryEndSeq);
}
mNeedsRecovery = false;
}
|
java
|
private void maybeRecoverFromUfsFailures() throws IOException, JournalClosedException {
if (!mNeedsRecovery) {
return;
}
long lastPersistSeq = recoverLastPersistedJournalEntry();
createNewLogFile(lastPersistSeq + 1);
if (!mEntriesToFlush.isEmpty()) {
JournalEntry firstEntryToFlush = mEntriesToFlush.peek();
if (firstEntryToFlush.getSequenceNumber() > lastPersistSeq + 1) {
throw new RuntimeException(ExceptionMessage.JOURNAL_ENTRY_MISSING.getMessageWithUrl(
RuntimeConstants.ALLUXIO_DEBUG_DOCS_URL,
lastPersistSeq + 1, firstEntryToFlush.getSequenceNumber()));
}
long retryEndSeq = lastPersistSeq;
LOG.info("Retry writing unwritten journal entries from seq {}", lastPersistSeq + 1);
for (JournalEntry entry : mEntriesToFlush) {
if (entry.getSequenceNumber() > lastPersistSeq) {
try {
entry.toBuilder().build().writeDelimitedTo(mJournalOutputStream);
retryEndSeq = entry.getSequenceNumber();
} catch (IOJournalClosedException e) {
throw e.toJournalClosedException();
} catch (IOException e) {
throw new IOException(ExceptionMessage.JOURNAL_WRITE_FAILURE
.getMessageWithUrl(RuntimeConstants.ALLUXIO_DEBUG_DOCS_URL,
mJournalOutputStream.currentLog(), e.getMessage()), e);
}
}
}
LOG.info("Finished writing unwritten journal entries from {} to {}.",
lastPersistSeq + 1, retryEndSeq);
}
mNeedsRecovery = false;
}
|
[
"private",
"void",
"maybeRecoverFromUfsFailures",
"(",
")",
"throws",
"IOException",
",",
"JournalClosedException",
"{",
"if",
"(",
"!",
"mNeedsRecovery",
")",
"{",
"return",
";",
"}",
"long",
"lastPersistSeq",
"=",
"recoverLastPersistedJournalEntry",
"(",
")",
";",
"createNewLogFile",
"(",
"lastPersistSeq",
"+",
"1",
")",
";",
"if",
"(",
"!",
"mEntriesToFlush",
".",
"isEmpty",
"(",
")",
")",
"{",
"JournalEntry",
"firstEntryToFlush",
"=",
"mEntriesToFlush",
".",
"peek",
"(",
")",
";",
"if",
"(",
"firstEntryToFlush",
".",
"getSequenceNumber",
"(",
")",
">",
"lastPersistSeq",
"+",
"1",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ExceptionMessage",
".",
"JOURNAL_ENTRY_MISSING",
".",
"getMessageWithUrl",
"(",
"RuntimeConstants",
".",
"ALLUXIO_DEBUG_DOCS_URL",
",",
"lastPersistSeq",
"+",
"1",
",",
"firstEntryToFlush",
".",
"getSequenceNumber",
"(",
")",
")",
")",
";",
"}",
"long",
"retryEndSeq",
"=",
"lastPersistSeq",
";",
"LOG",
".",
"info",
"(",
"\"Retry writing unwritten journal entries from seq {}\"",
",",
"lastPersistSeq",
"+",
"1",
")",
";",
"for",
"(",
"JournalEntry",
"entry",
":",
"mEntriesToFlush",
")",
"{",
"if",
"(",
"entry",
".",
"getSequenceNumber",
"(",
")",
">",
"lastPersistSeq",
")",
"{",
"try",
"{",
"entry",
".",
"toBuilder",
"(",
")",
".",
"build",
"(",
")",
".",
"writeDelimitedTo",
"(",
"mJournalOutputStream",
")",
";",
"retryEndSeq",
"=",
"entry",
".",
"getSequenceNumber",
"(",
")",
";",
"}",
"catch",
"(",
"IOJournalClosedException",
"e",
")",
"{",
"throw",
"e",
".",
"toJournalClosedException",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"ExceptionMessage",
".",
"JOURNAL_WRITE_FAILURE",
".",
"getMessageWithUrl",
"(",
"RuntimeConstants",
".",
"ALLUXIO_DEBUG_DOCS_URL",
",",
"mJournalOutputStream",
".",
"currentLog",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
"LOG",
".",
"info",
"(",
"\"Finished writing unwritten journal entries from {} to {}.\"",
",",
"lastPersistSeq",
"+",
"1",
",",
"retryEndSeq",
")",
";",
"}",
"mNeedsRecovery",
"=",
"false",
";",
"}"
] |
Core logic of UFS journal recovery from UFS failures.
If Alluxio stores its journals in UFS, then Alluxio needs to handle UFS failures.
When UFS is dead, there is nothing Alluxio can do because Alluxio relies on UFS to
persist journal entries. Consequently any metadata operation will block because Alluxio
cannot flush their journal entries.
Once UFS comes back online, Alluxio needs to perform the following operations:
1. Find out the sequence number of the last persisted journal entry, say X. Then the first
non-persisted entry has sequence number Y = X + 1.
2. Check whether there is any missing journal entry between Y (inclusive) and the oldest
entry in mEntriesToFlush, say Z. If Z > Y, then it means journal entries in [Y, Z) are
missing, and Alluxio cannot recover. Otherwise, for each journal entry in
{@link #mEntriesToFlush}, if its sequence number is larger than or equal to Y, retry
writing it to UFS by calling the {@code UfsJournalLogWriter#write} method.
|
[
"Core",
"logic",
"of",
"UFS",
"journal",
"recovery",
"from",
"UFS",
"failures",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalLogWriter.java#L156-L191
|
18,984
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalLogWriter.java
|
UfsJournalLogWriter.recoverLastPersistedJournalEntry
|
private long recoverLastPersistedJournalEntry() throws IOException {
UfsJournalSnapshot snapshot = UfsJournalSnapshot.getSnapshot(mJournal);
long lastPersistSeq = -1;
UfsJournalFile currentLog = snapshot.getCurrentLog(mJournal);
if (currentLog != null) {
LOG.info("Recovering from previous UFS journal write failure."
+ " Scanning for the last persisted journal entry.");
try (JournalEntryStreamReader reader =
new JournalEntryStreamReader(mUfs.open(currentLog.getLocation().toString(),
OpenOptions.defaults().setRecoverFailedOpen(true)))) {
JournalEntry entry;
while ((entry = reader.readEntry()) != null) {
if (entry.getSequenceNumber() > lastPersistSeq) {
lastPersistSeq = entry.getSequenceNumber();
}
}
} catch (IOException e) {
throw e;
}
completeLog(currentLog, lastPersistSeq + 1);
}
// Search for and scan the latest COMPLETE journal and find out the sequence number of the
// last persisted journal entry, in case no entry has been found in the INCOMPLETE journal.
if (lastPersistSeq < 0) {
// Re-evaluate snapshot because the incomplete journal will be destroyed if
// it does not contain any valid entry.
snapshot = UfsJournalSnapshot.getSnapshot(mJournal);
// journalFiles[journalFiles.size()-1] is the latest complete journal file.
List<UfsJournalFile> journalFiles = snapshot.getLogs();
if (!journalFiles.isEmpty()) {
UfsJournalFile journal = journalFiles.get(journalFiles.size() - 1);
lastPersistSeq = journal.getEnd() - 1;
LOG.info("Found last persisted journal entry with seq {} in {}.",
lastPersistSeq, journal.getLocation().toString());
}
}
return lastPersistSeq;
}
|
java
|
private long recoverLastPersistedJournalEntry() throws IOException {
UfsJournalSnapshot snapshot = UfsJournalSnapshot.getSnapshot(mJournal);
long lastPersistSeq = -1;
UfsJournalFile currentLog = snapshot.getCurrentLog(mJournal);
if (currentLog != null) {
LOG.info("Recovering from previous UFS journal write failure."
+ " Scanning for the last persisted journal entry.");
try (JournalEntryStreamReader reader =
new JournalEntryStreamReader(mUfs.open(currentLog.getLocation().toString(),
OpenOptions.defaults().setRecoverFailedOpen(true)))) {
JournalEntry entry;
while ((entry = reader.readEntry()) != null) {
if (entry.getSequenceNumber() > lastPersistSeq) {
lastPersistSeq = entry.getSequenceNumber();
}
}
} catch (IOException e) {
throw e;
}
completeLog(currentLog, lastPersistSeq + 1);
}
// Search for and scan the latest COMPLETE journal and find out the sequence number of the
// last persisted journal entry, in case no entry has been found in the INCOMPLETE journal.
if (lastPersistSeq < 0) {
// Re-evaluate snapshot because the incomplete journal will be destroyed if
// it does not contain any valid entry.
snapshot = UfsJournalSnapshot.getSnapshot(mJournal);
// journalFiles[journalFiles.size()-1] is the latest complete journal file.
List<UfsJournalFile> journalFiles = snapshot.getLogs();
if (!journalFiles.isEmpty()) {
UfsJournalFile journal = journalFiles.get(journalFiles.size() - 1);
lastPersistSeq = journal.getEnd() - 1;
LOG.info("Found last persisted journal entry with seq {} in {}.",
lastPersistSeq, journal.getLocation().toString());
}
}
return lastPersistSeq;
}
|
[
"private",
"long",
"recoverLastPersistedJournalEntry",
"(",
")",
"throws",
"IOException",
"{",
"UfsJournalSnapshot",
"snapshot",
"=",
"UfsJournalSnapshot",
".",
"getSnapshot",
"(",
"mJournal",
")",
";",
"long",
"lastPersistSeq",
"=",
"-",
"1",
";",
"UfsJournalFile",
"currentLog",
"=",
"snapshot",
".",
"getCurrentLog",
"(",
"mJournal",
")",
";",
"if",
"(",
"currentLog",
"!=",
"null",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Recovering from previous UFS journal write failure.\"",
"+",
"\" Scanning for the last persisted journal entry.\"",
")",
";",
"try",
"(",
"JournalEntryStreamReader",
"reader",
"=",
"new",
"JournalEntryStreamReader",
"(",
"mUfs",
".",
"open",
"(",
"currentLog",
".",
"getLocation",
"(",
")",
".",
"toString",
"(",
")",
",",
"OpenOptions",
".",
"defaults",
"(",
")",
".",
"setRecoverFailedOpen",
"(",
"true",
")",
")",
")",
")",
"{",
"JournalEntry",
"entry",
";",
"while",
"(",
"(",
"entry",
"=",
"reader",
".",
"readEntry",
"(",
")",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"entry",
".",
"getSequenceNumber",
"(",
")",
">",
"lastPersistSeq",
")",
"{",
"lastPersistSeq",
"=",
"entry",
".",
"getSequenceNumber",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"completeLog",
"(",
"currentLog",
",",
"lastPersistSeq",
"+",
"1",
")",
";",
"}",
"// Search for and scan the latest COMPLETE journal and find out the sequence number of the",
"// last persisted journal entry, in case no entry has been found in the INCOMPLETE journal.",
"if",
"(",
"lastPersistSeq",
"<",
"0",
")",
"{",
"// Re-evaluate snapshot because the incomplete journal will be destroyed if",
"// it does not contain any valid entry.",
"snapshot",
"=",
"UfsJournalSnapshot",
".",
"getSnapshot",
"(",
"mJournal",
")",
";",
"// journalFiles[journalFiles.size()-1] is the latest complete journal file.",
"List",
"<",
"UfsJournalFile",
">",
"journalFiles",
"=",
"snapshot",
".",
"getLogs",
"(",
")",
";",
"if",
"(",
"!",
"journalFiles",
".",
"isEmpty",
"(",
")",
")",
"{",
"UfsJournalFile",
"journal",
"=",
"journalFiles",
".",
"get",
"(",
"journalFiles",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"lastPersistSeq",
"=",
"journal",
".",
"getEnd",
"(",
")",
"-",
"1",
";",
"LOG",
".",
"info",
"(",
"\"Found last persisted journal entry with seq {} in {}.\"",
",",
"lastPersistSeq",
",",
"journal",
".",
"getLocation",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"return",
"lastPersistSeq",
";",
"}"
] |
Examine the UFS to determine the most recent journal entry, and return its sequence number.
1. Locate the most recent incomplete journal file, i.e. journal file that starts with
a valid sequence number S (hex), and ends with 0x7fffffffffffffff. The journal file
name encodes this information, i.e. S-0x7fffffffffffffff.
2. Sequentially scan the incomplete journal file, and identify the last journal
entry that has been persisted in UFS. Suppose it is X.
3. Rename the incomplete journal file to S-<X+1>. Future journal writes will write to
a new file named <X+1>-0x7fffffffffffffff.
4. If the incomplete journal does not exist or no entry can be found in the incomplete
journal, check the last complete journal file for the last persisted journal entry.
@return sequence number of the last persisted journal entry, or -1 if no entry can be found
|
[
"Examine",
"the",
"UFS",
"to",
"determine",
"the",
"most",
"recent",
"journal",
"entry",
"and",
"return",
"its",
"sequence",
"number",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalLogWriter.java#L208-L245
|
18,985
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalLogWriter.java
|
UfsJournalLogWriter.maybeRotateLog
|
private void maybeRotateLog() throws IOException {
if (!mRotateLogForNextWrite) {
return;
}
if (mJournalOutputStream != null) {
mJournalOutputStream.close();
mJournalOutputStream = null;
}
createNewLogFile(mNextSequenceNumber);
mRotateLogForNextWrite = false;
}
|
java
|
private void maybeRotateLog() throws IOException {
if (!mRotateLogForNextWrite) {
return;
}
if (mJournalOutputStream != null) {
mJournalOutputStream.close();
mJournalOutputStream = null;
}
createNewLogFile(mNextSequenceNumber);
mRotateLogForNextWrite = false;
}
|
[
"private",
"void",
"maybeRotateLog",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"mRotateLogForNextWrite",
")",
"{",
"return",
";",
"}",
"if",
"(",
"mJournalOutputStream",
"!=",
"null",
")",
"{",
"mJournalOutputStream",
".",
"close",
"(",
")",
";",
"mJournalOutputStream",
"=",
"null",
";",
"}",
"createNewLogFile",
"(",
"mNextSequenceNumber",
")",
";",
"mRotateLogForNextWrite",
"=",
"false",
";",
"}"
] |
Closes the current journal output stream and creates a new one.
The implementation must be idempotent so that it can work when retrying during failures.
|
[
"Closes",
"the",
"current",
"journal",
"output",
"stream",
"and",
"creates",
"a",
"new",
"one",
".",
"The",
"implementation",
"must",
"be",
"idempotent",
"so",
"that",
"it",
"can",
"work",
"when",
"retrying",
"during",
"failures",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalLogWriter.java#L251-L262
|
18,986
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalLogWriter.java
|
UfsJournalLogWriter.completeLog
|
private void completeLog(UfsJournalFile currentLog, long nextSequenceNumber) throws IOException {
String current = currentLog.getLocation().toString();
if (nextSequenceNumber <= currentLog.getStart()) {
LOG.info("No journal entry found in current journal file {}. Deleting it", current);
if (!mUfs.deleteFile(current)) {
LOG.warn("Failed to delete empty journal file {}", current);
}
return;
}
LOG.info("Completing log {} with next sequence number {}", current, nextSequenceNumber);
String completed = UfsJournalFile
.encodeLogFileLocation(mJournal, currentLog.getStart(), nextSequenceNumber).toString();
if (!mUfs.renameFile(current, completed)) {
// Completes could happen concurrently, check whether another master already did the rename.
if (!mUfs.exists(completed)) {
throw new IOException(
String.format("Failed to rename journal log from %s to %s", current, completed));
}
if (mUfs.exists(current)) {
// Rename is not atomic, so this could happen if we failed partway through a rename.
LOG.info("Deleting current log {}", current);
if (!mUfs.deleteFile(current)) {
LOG.warn("Failed to delete current log file {}", current);
}
}
}
}
|
java
|
private void completeLog(UfsJournalFile currentLog, long nextSequenceNumber) throws IOException {
String current = currentLog.getLocation().toString();
if (nextSequenceNumber <= currentLog.getStart()) {
LOG.info("No journal entry found in current journal file {}. Deleting it", current);
if (!mUfs.deleteFile(current)) {
LOG.warn("Failed to delete empty journal file {}", current);
}
return;
}
LOG.info("Completing log {} with next sequence number {}", current, nextSequenceNumber);
String completed = UfsJournalFile
.encodeLogFileLocation(mJournal, currentLog.getStart(), nextSequenceNumber).toString();
if (!mUfs.renameFile(current, completed)) {
// Completes could happen concurrently, check whether another master already did the rename.
if (!mUfs.exists(completed)) {
throw new IOException(
String.format("Failed to rename journal log from %s to %s", current, completed));
}
if (mUfs.exists(current)) {
// Rename is not atomic, so this could happen if we failed partway through a rename.
LOG.info("Deleting current log {}", current);
if (!mUfs.deleteFile(current)) {
LOG.warn("Failed to delete current log file {}", current);
}
}
}
}
|
[
"private",
"void",
"completeLog",
"(",
"UfsJournalFile",
"currentLog",
",",
"long",
"nextSequenceNumber",
")",
"throws",
"IOException",
"{",
"String",
"current",
"=",
"currentLog",
".",
"getLocation",
"(",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"nextSequenceNumber",
"<=",
"currentLog",
".",
"getStart",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"No journal entry found in current journal file {}. Deleting it\"",
",",
"current",
")",
";",
"if",
"(",
"!",
"mUfs",
".",
"deleteFile",
"(",
"current",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to delete empty journal file {}\"",
",",
"current",
")",
";",
"}",
"return",
";",
"}",
"LOG",
".",
"info",
"(",
"\"Completing log {} with next sequence number {}\"",
",",
"current",
",",
"nextSequenceNumber",
")",
";",
"String",
"completed",
"=",
"UfsJournalFile",
".",
"encodeLogFileLocation",
"(",
"mJournal",
",",
"currentLog",
".",
"getStart",
"(",
")",
",",
"nextSequenceNumber",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"!",
"mUfs",
".",
"renameFile",
"(",
"current",
",",
"completed",
")",
")",
"{",
"// Completes could happen concurrently, check whether another master already did the rename.",
"if",
"(",
"!",
"mUfs",
".",
"exists",
"(",
"completed",
")",
")",
"{",
"throw",
"new",
"IOException",
"(",
"String",
".",
"format",
"(",
"\"Failed to rename journal log from %s to %s\"",
",",
"current",
",",
"completed",
")",
")",
";",
"}",
"if",
"(",
"mUfs",
".",
"exists",
"(",
"current",
")",
")",
"{",
"// Rename is not atomic, so this could happen if we failed partway through a rename.",
"LOG",
".",
"info",
"(",
"\"Deleting current log {}\"",
",",
"current",
")",
";",
"if",
"(",
"!",
"mUfs",
".",
"deleteFile",
"(",
"current",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to delete current log file {}\"",
",",
"current",
")",
";",
"}",
"}",
"}",
"}"
] |
Completes the given log.
If the log is empty, it will be deleted.
This method must be safe to run by multiple masters at the same time. This could happen if a
primary master loses leadership and takes a while to close its journal. By the time it
completes the current log, the new primary might be trying to close it as well.
@param currentLog the log to complete
@param nextSequenceNumber the next sequence number for the log to complete
|
[
"Completes",
"the",
"given",
"log",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalLogWriter.java#L288-L315
|
18,987
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/grpc/GrpcSerializationUtils.java
|
GrpcSerializationUtils.getBufferFromStream
|
public static ReadableBuffer getBufferFromStream(InputStream stream) {
if (!sZeroCopyReceiveSupported
|| !stream.getClass().equals(sReadableBufferField.getDeclaringClass())) {
return null;
}
try {
return (ReadableBuffer) sReadableBufferField.get(stream);
} catch (Exception e) {
LOG.warn("Failed to get data buffer from stream.", e);
return null;
}
}
|
java
|
public static ReadableBuffer getBufferFromStream(InputStream stream) {
if (!sZeroCopyReceiveSupported
|| !stream.getClass().equals(sReadableBufferField.getDeclaringClass())) {
return null;
}
try {
return (ReadableBuffer) sReadableBufferField.get(stream);
} catch (Exception e) {
LOG.warn("Failed to get data buffer from stream.", e);
return null;
}
}
|
[
"public",
"static",
"ReadableBuffer",
"getBufferFromStream",
"(",
"InputStream",
"stream",
")",
"{",
"if",
"(",
"!",
"sZeroCopyReceiveSupported",
"||",
"!",
"stream",
".",
"getClass",
"(",
")",
".",
"equals",
"(",
"sReadableBufferField",
".",
"getDeclaringClass",
"(",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"return",
"(",
"ReadableBuffer",
")",
"sReadableBufferField",
".",
"get",
"(",
"stream",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to get data buffer from stream.\"",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Gets a buffer directly from a gRPC input stream.
@param stream the input stream
@return the raw data buffer
|
[
"Gets",
"a",
"buffer",
"directly",
"from",
"a",
"gRPC",
"input",
"stream",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/grpc/GrpcSerializationUtils.java#L124-L135
|
18,988
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/grpc/GrpcSerializationUtils.java
|
GrpcSerializationUtils.getByteBufFromReadableBuffer
|
public static ByteBuf getByteBufFromReadableBuffer(ReadableBuffer buffer) {
if (!sZeroCopyReceiveSupported) {
return null;
}
try {
if (buffer instanceof CompositeReadableBuffer) {
Queue<ReadableBuffer> buffers = (Queue<ReadableBuffer>) sCompositeBuffers.get(buffer);
if (buffers.size() == 1) {
return getByteBufFromReadableBuffer(buffers.peek());
} else {
CompositeByteBuf buf = PooledByteBufAllocator.DEFAULT.compositeBuffer();
for (ReadableBuffer readableBuffer : buffers) {
ByteBuf subBuffer = getByteBufFromReadableBuffer(readableBuffer);
if (subBuffer == null) {
return null;
}
buf.addComponent(true, subBuffer);
}
return buf;
}
} else if (buffer.getClass().equals(sReadableByteBuf.getDeclaringClass())) {
return (ByteBuf) sReadableByteBuf.get(buffer);
}
} catch (Exception e) {
LOG.warn("Failed to get data buffer from stream: {}.", e.getMessage());
return null;
}
return null;
}
|
java
|
public static ByteBuf getByteBufFromReadableBuffer(ReadableBuffer buffer) {
if (!sZeroCopyReceiveSupported) {
return null;
}
try {
if (buffer instanceof CompositeReadableBuffer) {
Queue<ReadableBuffer> buffers = (Queue<ReadableBuffer>) sCompositeBuffers.get(buffer);
if (buffers.size() == 1) {
return getByteBufFromReadableBuffer(buffers.peek());
} else {
CompositeByteBuf buf = PooledByteBufAllocator.DEFAULT.compositeBuffer();
for (ReadableBuffer readableBuffer : buffers) {
ByteBuf subBuffer = getByteBufFromReadableBuffer(readableBuffer);
if (subBuffer == null) {
return null;
}
buf.addComponent(true, subBuffer);
}
return buf;
}
} else if (buffer.getClass().equals(sReadableByteBuf.getDeclaringClass())) {
return (ByteBuf) sReadableByteBuf.get(buffer);
}
} catch (Exception e) {
LOG.warn("Failed to get data buffer from stream: {}.", e.getMessage());
return null;
}
return null;
}
|
[
"public",
"static",
"ByteBuf",
"getByteBufFromReadableBuffer",
"(",
"ReadableBuffer",
"buffer",
")",
"{",
"if",
"(",
"!",
"sZeroCopyReceiveSupported",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"if",
"(",
"buffer",
"instanceof",
"CompositeReadableBuffer",
")",
"{",
"Queue",
"<",
"ReadableBuffer",
">",
"buffers",
"=",
"(",
"Queue",
"<",
"ReadableBuffer",
">",
")",
"sCompositeBuffers",
".",
"get",
"(",
"buffer",
")",
";",
"if",
"(",
"buffers",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"return",
"getByteBufFromReadableBuffer",
"(",
"buffers",
".",
"peek",
"(",
")",
")",
";",
"}",
"else",
"{",
"CompositeByteBuf",
"buf",
"=",
"PooledByteBufAllocator",
".",
"DEFAULT",
".",
"compositeBuffer",
"(",
")",
";",
"for",
"(",
"ReadableBuffer",
"readableBuffer",
":",
"buffers",
")",
"{",
"ByteBuf",
"subBuffer",
"=",
"getByteBufFromReadableBuffer",
"(",
"readableBuffer",
")",
";",
"if",
"(",
"subBuffer",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"buf",
".",
"addComponent",
"(",
"true",
",",
"subBuffer",
")",
";",
"}",
"return",
"buf",
";",
"}",
"}",
"else",
"if",
"(",
"buffer",
".",
"getClass",
"(",
")",
".",
"equals",
"(",
"sReadableByteBuf",
".",
"getDeclaringClass",
"(",
")",
")",
")",
"{",
"return",
"(",
"ByteBuf",
")",
"sReadableByteBuf",
".",
"get",
"(",
"buffer",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to get data buffer from stream: {}.\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets a Netty buffer directly from a gRPC ReadableBuffer.
@param buffer the input buffer
@return the raw ByteBuf, or null if the ByteBuf cannot be extracted
|
[
"Gets",
"a",
"Netty",
"buffer",
"directly",
"from",
"a",
"gRPC",
"ReadableBuffer",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/grpc/GrpcSerializationUtils.java#L143-L171
|
18,989
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/grpc/GrpcSerializationUtils.java
|
GrpcSerializationUtils.addBuffersToStream
|
public static boolean addBuffersToStream(ByteBuf[] buffers, OutputStream stream) {
if (!sZeroCopySendSupported || !stream.getClass().equals(sBufferList.getDeclaringClass())) {
return false;
}
try {
if (sCurrent.get(stream) != null) {
return false;
}
for (ByteBuf buffer : buffers) {
Object nettyBuffer = sNettyWritableBufferConstructor.newInstance(buffer);
List list = (List) sBufferList.get(stream);
list.add(nettyBuffer);
buffer.retain();
sCurrent.set(stream, nettyBuffer);
}
return true;
} catch (Exception e) {
LOG.warn("Failed to add data buffer to stream: {}.", e.getMessage());
return false;
}
}
|
java
|
public static boolean addBuffersToStream(ByteBuf[] buffers, OutputStream stream) {
if (!sZeroCopySendSupported || !stream.getClass().equals(sBufferList.getDeclaringClass())) {
return false;
}
try {
if (sCurrent.get(stream) != null) {
return false;
}
for (ByteBuf buffer : buffers) {
Object nettyBuffer = sNettyWritableBufferConstructor.newInstance(buffer);
List list = (List) sBufferList.get(stream);
list.add(nettyBuffer);
buffer.retain();
sCurrent.set(stream, nettyBuffer);
}
return true;
} catch (Exception e) {
LOG.warn("Failed to add data buffer to stream: {}.", e.getMessage());
return false;
}
}
|
[
"public",
"static",
"boolean",
"addBuffersToStream",
"(",
"ByteBuf",
"[",
"]",
"buffers",
",",
"OutputStream",
"stream",
")",
"{",
"if",
"(",
"!",
"sZeroCopySendSupported",
"||",
"!",
"stream",
".",
"getClass",
"(",
")",
".",
"equals",
"(",
"sBufferList",
".",
"getDeclaringClass",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"if",
"(",
"sCurrent",
".",
"get",
"(",
"stream",
")",
"!=",
"null",
")",
"{",
"return",
"false",
";",
"}",
"for",
"(",
"ByteBuf",
"buffer",
":",
"buffers",
")",
"{",
"Object",
"nettyBuffer",
"=",
"sNettyWritableBufferConstructor",
".",
"newInstance",
"(",
"buffer",
")",
";",
"List",
"list",
"=",
"(",
"List",
")",
"sBufferList",
".",
"get",
"(",
"stream",
")",
";",
"list",
".",
"add",
"(",
"nettyBuffer",
")",
";",
"buffer",
".",
"retain",
"(",
")",
";",
"sCurrent",
".",
"set",
"(",
"stream",
",",
"nettyBuffer",
")",
";",
"}",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to add data buffer to stream: {}.\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Add the given buffers directly to the gRPC output stream.
@param buffers the buffers to be added
@param stream the output stream
@return whether the buffers are added successfully
|
[
"Add",
"the",
"given",
"buffers",
"directly",
"to",
"the",
"gRPC",
"output",
"stream",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/grpc/GrpcSerializationUtils.java#L180-L200
|
18,990
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/grpc/GrpcSerializationUtils.java
|
GrpcSerializationUtils.overrideMethods
|
public static ServerServiceDefinition overrideMethods(
final ServerServiceDefinition service,
final Map<MethodDescriptor, MethodDescriptor> marshallers) {
List<ServerMethodDefinition<?, ?>> newMethods = new ArrayList<ServerMethodDefinition<?, ?>>();
List<MethodDescriptor<?, ?>> newDescriptors = new ArrayList<MethodDescriptor<?, ?>>();
// intercepts the descriptors
for (final ServerMethodDefinition<?, ?> definition : service.getMethods()) {
ServerMethodDefinition<?, ?> newMethod = interceptMethod(definition, marshallers);
newDescriptors.add(newMethod.getMethodDescriptor());
newMethods.add(newMethod);
}
// builds the new service descriptor
final ServerServiceDefinition.Builder serviceBuilder = ServerServiceDefinition
.builder(new ServiceDescriptor(service.getServiceDescriptor().getName(), newDescriptors));
// creates the new service definition
for (ServerMethodDefinition<?, ?> definition : newMethods) {
serviceBuilder.addMethod(definition);
}
return serviceBuilder.build();
}
|
java
|
public static ServerServiceDefinition overrideMethods(
final ServerServiceDefinition service,
final Map<MethodDescriptor, MethodDescriptor> marshallers) {
List<ServerMethodDefinition<?, ?>> newMethods = new ArrayList<ServerMethodDefinition<?, ?>>();
List<MethodDescriptor<?, ?>> newDescriptors = new ArrayList<MethodDescriptor<?, ?>>();
// intercepts the descriptors
for (final ServerMethodDefinition<?, ?> definition : service.getMethods()) {
ServerMethodDefinition<?, ?> newMethod = interceptMethod(definition, marshallers);
newDescriptors.add(newMethod.getMethodDescriptor());
newMethods.add(newMethod);
}
// builds the new service descriptor
final ServerServiceDefinition.Builder serviceBuilder = ServerServiceDefinition
.builder(new ServiceDescriptor(service.getServiceDescriptor().getName(), newDescriptors));
// creates the new service definition
for (ServerMethodDefinition<?, ?> definition : newMethods) {
serviceBuilder.addMethod(definition);
}
return serviceBuilder.build();
}
|
[
"public",
"static",
"ServerServiceDefinition",
"overrideMethods",
"(",
"final",
"ServerServiceDefinition",
"service",
",",
"final",
"Map",
"<",
"MethodDescriptor",
",",
"MethodDescriptor",
">",
"marshallers",
")",
"{",
"List",
"<",
"ServerMethodDefinition",
"<",
"?",
",",
"?",
">",
">",
"newMethods",
"=",
"new",
"ArrayList",
"<",
"ServerMethodDefinition",
"<",
"?",
",",
"?",
">",
">",
"(",
")",
";",
"List",
"<",
"MethodDescriptor",
"<",
"?",
",",
"?",
">",
">",
"newDescriptors",
"=",
"new",
"ArrayList",
"<",
"MethodDescriptor",
"<",
"?",
",",
"?",
">",
">",
"(",
")",
";",
"// intercepts the descriptors",
"for",
"(",
"final",
"ServerMethodDefinition",
"<",
"?",
",",
"?",
">",
"definition",
":",
"service",
".",
"getMethods",
"(",
")",
")",
"{",
"ServerMethodDefinition",
"<",
"?",
",",
"?",
">",
"newMethod",
"=",
"interceptMethod",
"(",
"definition",
",",
"marshallers",
")",
";",
"newDescriptors",
".",
"add",
"(",
"newMethod",
".",
"getMethodDescriptor",
"(",
")",
")",
";",
"newMethods",
".",
"add",
"(",
"newMethod",
")",
";",
"}",
"// builds the new service descriptor",
"final",
"ServerServiceDefinition",
".",
"Builder",
"serviceBuilder",
"=",
"ServerServiceDefinition",
".",
"builder",
"(",
"new",
"ServiceDescriptor",
"(",
"service",
".",
"getServiceDescriptor",
"(",
")",
".",
"getName",
"(",
")",
",",
"newDescriptors",
")",
")",
";",
"// creates the new service definition",
"for",
"(",
"ServerMethodDefinition",
"<",
"?",
",",
"?",
">",
"definition",
":",
"newMethods",
")",
"{",
"serviceBuilder",
".",
"addMethod",
"(",
"definition",
")",
";",
"}",
"return",
"serviceBuilder",
".",
"build",
"(",
")",
";",
"}"
] |
Creates a service definition that uses custom marshallers.
@param service the service to intercept
@param marshallers a map that specifies which marshaller to use for each method
@return the new service definition
|
[
"Creates",
"a",
"service",
"definition",
"that",
"uses",
"custom",
"marshallers",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/grpc/GrpcSerializationUtils.java#L209-L228
|
18,991
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/ForkJoinTask.java
|
ForkJoinTask.uncheckedThrow
|
@SuppressWarnings("unchecked")
static <T extends Throwable> void uncheckedThrow(Throwable t) throws T {
if (t != null)
throw (T) t; // rely on vacuous cast
else
throw new Error("Unknown Exception");
}
|
java
|
@SuppressWarnings("unchecked")
static <T extends Throwable> void uncheckedThrow(Throwable t) throws T {
if (t != null)
throw (T) t; // rely on vacuous cast
else
throw new Error("Unknown Exception");
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"static",
"<",
"T",
"extends",
"Throwable",
">",
"void",
"uncheckedThrow",
"(",
"Throwable",
"t",
")",
"throws",
"T",
"{",
"if",
"(",
"t",
"!=",
"null",
")",
"throw",
"(",
"T",
")",
"t",
";",
"// rely on vacuous cast",
"else",
"throw",
"new",
"Error",
"(",
"\"Unknown Exception\"",
")",
";",
"}"
] |
The sneaky part of sneaky throw, relying on generics limitations to evade compiler complaints
about rethrowing unchecked exceptions.
|
[
"The",
"sneaky",
"part",
"of",
"sneaky",
"throw",
"relying",
"on",
"generics",
"limitations",
"to",
"evade",
"compiler",
"complaints",
"about",
"rethrowing",
"unchecked",
"exceptions",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/ForkJoinTask.java#L287-L293
|
18,992
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/ForkJoinTask.java
|
ForkJoinTask.getQueuedTaskCount
|
public static int getQueuedTaskCount() {
Thread t;
ForkJoinPool.WorkQueue q;
if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)
q = ((ForkJoinWorkerThread) t).workQueue;
else
q = ForkJoinPool.commonSubmitterQueue();
return (q == null) ? 0 : q.queueSize();
}
|
java
|
public static int getQueuedTaskCount() {
Thread t;
ForkJoinPool.WorkQueue q;
if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)
q = ((ForkJoinWorkerThread) t).workQueue;
else
q = ForkJoinPool.commonSubmitterQueue();
return (q == null) ? 0 : q.queueSize();
}
|
[
"public",
"static",
"int",
"getQueuedTaskCount",
"(",
")",
"{",
"Thread",
"t",
";",
"ForkJoinPool",
".",
"WorkQueue",
"q",
";",
"if",
"(",
"(",
"t",
"=",
"Thread",
".",
"currentThread",
"(",
")",
")",
"instanceof",
"ForkJoinWorkerThread",
")",
"q",
"=",
"(",
"(",
"ForkJoinWorkerThread",
")",
"t",
")",
".",
"workQueue",
";",
"else",
"q",
"=",
"ForkJoinPool",
".",
"commonSubmitterQueue",
"(",
")",
";",
"return",
"(",
"q",
"==",
"null",
")",
"?",
"0",
":",
"q",
".",
"queueSize",
"(",
")",
";",
"}"
] |
Returns an estimate of the number of tasks that have been forked by the current worker thread
but not yet executed. This value may be useful for heuristic decisions about whether to fork
other tasks.
@return the number of tasks
|
[
"Returns",
"an",
"estimate",
"of",
"the",
"number",
"of",
"tasks",
"that",
"have",
"been",
"forked",
"by",
"the",
"current",
"worker",
"thread",
"but",
"not",
"yet",
"executed",
".",
"This",
"value",
"may",
"be",
"useful",
"for",
"heuristic",
"decisions",
"about",
"whether",
"to",
"fork",
"other",
"tasks",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/ForkJoinTask.java#L448-L456
|
18,993
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/ForkJoinTask.java
|
ForkJoinTask.peekNextLocalTask
|
protected static ForkJoinTask<?> peekNextLocalTask() {
Thread t;
ForkJoinPool.WorkQueue q;
if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)
q = ((ForkJoinWorkerThread) t).workQueue;
else
q = ForkJoinPool.commonSubmitterQueue();
return (q == null) ? null : q.peek();
}
|
java
|
protected static ForkJoinTask<?> peekNextLocalTask() {
Thread t;
ForkJoinPool.WorkQueue q;
if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)
q = ((ForkJoinWorkerThread) t).workQueue;
else
q = ForkJoinPool.commonSubmitterQueue();
return (q == null) ? null : q.peek();
}
|
[
"protected",
"static",
"ForkJoinTask",
"<",
"?",
">",
"peekNextLocalTask",
"(",
")",
"{",
"Thread",
"t",
";",
"ForkJoinPool",
".",
"WorkQueue",
"q",
";",
"if",
"(",
"(",
"t",
"=",
"Thread",
".",
"currentThread",
"(",
")",
")",
"instanceof",
"ForkJoinWorkerThread",
")",
"q",
"=",
"(",
"(",
"ForkJoinWorkerThread",
")",
"t",
")",
".",
"workQueue",
";",
"else",
"q",
"=",
"ForkJoinPool",
".",
"commonSubmitterQueue",
"(",
")",
";",
"return",
"(",
"q",
"==",
"null",
")",
"?",
"null",
":",
"q",
".",
"peek",
"(",
")",
";",
"}"
] |
Returns, but does not unschedule or execute, a task queued by the current thread but not yet
executed, if one is immediately available. There is no guarantee that this task will actually
be polled or executed next. Conversely, this method may return null even if a task exists but
cannot be accessed without contention with other threads. This method is designed primarily to
support extensions, and is unlikely to be useful otherwise.
@return the next task, or {@code null} if none are available
|
[
"Returns",
"but",
"does",
"not",
"unschedule",
"or",
"execute",
"a",
"task",
"queued",
"by",
"the",
"current",
"thread",
"but",
"not",
"yet",
"executed",
"if",
"one",
"is",
"immediately",
"available",
".",
"There",
"is",
"no",
"guarantee",
"that",
"this",
"task",
"will",
"actually",
"be",
"polled",
"or",
"executed",
"next",
".",
"Conversely",
"this",
"method",
"may",
"return",
"null",
"even",
"if",
"a",
"task",
"exists",
"but",
"cannot",
"be",
"accessed",
"without",
"contention",
"with",
"other",
"threads",
".",
"This",
"method",
"is",
"designed",
"primarily",
"to",
"support",
"extensions",
"and",
"is",
"unlikely",
"to",
"be",
"useful",
"otherwise",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/ForkJoinTask.java#L481-L489
|
18,994
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/ForkJoinTask.java
|
ForkJoinTask.pollNextLocalTask
|
protected static ForkJoinTask<?> pollNextLocalTask() {
Thread t;
return ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)
? ((ForkJoinWorkerThread) t).workQueue.nextLocalTask()
: null;
}
|
java
|
protected static ForkJoinTask<?> pollNextLocalTask() {
Thread t;
return ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)
? ((ForkJoinWorkerThread) t).workQueue.nextLocalTask()
: null;
}
|
[
"protected",
"static",
"ForkJoinTask",
"<",
"?",
">",
"pollNextLocalTask",
"(",
")",
"{",
"Thread",
"t",
";",
"return",
"(",
"(",
"t",
"=",
"Thread",
".",
"currentThread",
"(",
")",
")",
"instanceof",
"ForkJoinWorkerThread",
")",
"?",
"(",
"(",
"ForkJoinWorkerThread",
")",
"t",
")",
".",
"workQueue",
".",
"nextLocalTask",
"(",
")",
":",
"null",
";",
"}"
] |
Unschedules and returns, without executing, the next task queued by the current thread but not
yet executed, if the current thread is operating in a ForkJoinPool. This method is designed
primarily to support extensions, and is unlikely to be useful otherwise.
@return the next task, or {@code null} if none are available
|
[
"Unschedules",
"and",
"returns",
"without",
"executing",
"the",
"next",
"task",
"queued",
"by",
"the",
"current",
"thread",
"but",
"not",
"yet",
"executed",
"if",
"the",
"current",
"thread",
"is",
"operating",
"in",
"a",
"ForkJoinPool",
".",
"This",
"method",
"is",
"designed",
"primarily",
"to",
"support",
"extensions",
"and",
"is",
"unlikely",
"to",
"be",
"useful",
"otherwise",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/ForkJoinTask.java#L498-L503
|
18,995
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/ForkJoinTask.java
|
ForkJoinTask.getThrowableException
|
private Throwable getThrowableException() {
int h = System.identityHashCode(this);
ExceptionNode e;
final ReentrantLock lock = exceptionTableLock;
lock.lock();
try {
expungeStaleExceptions();
ExceptionNode[] t = exceptionTable;
e = t[h & (t.length - 1)];
while (e != null && e.get() != this)
e = e.next;
} finally {
lock.unlock();
}
Throwable ex;
if (e == null || (ex = e.ex) == null)
return null;
if (e.thrower != Thread.currentThread().getId()) {
try {
Constructor<?> noArgCtor = null;
// public ctors only
for (Constructor<?> c : ex.getClass().getConstructors()) {
Class<?>[] ps = c.getParameterTypes();
if (ps.length == 0)
noArgCtor = c;
else if (ps.length == 1 && ps[0] == Throwable.class)
return (Throwable) c.newInstance(ex);
}
if (noArgCtor != null) {
Throwable wx = (Throwable) noArgCtor.newInstance();
wx.initCause(ex);
return wx;
}
} catch (Exception ignore) {
}
}
return ex;
}
|
java
|
private Throwable getThrowableException() {
int h = System.identityHashCode(this);
ExceptionNode e;
final ReentrantLock lock = exceptionTableLock;
lock.lock();
try {
expungeStaleExceptions();
ExceptionNode[] t = exceptionTable;
e = t[h & (t.length - 1)];
while (e != null && e.get() != this)
e = e.next;
} finally {
lock.unlock();
}
Throwable ex;
if (e == null || (ex = e.ex) == null)
return null;
if (e.thrower != Thread.currentThread().getId()) {
try {
Constructor<?> noArgCtor = null;
// public ctors only
for (Constructor<?> c : ex.getClass().getConstructors()) {
Class<?>[] ps = c.getParameterTypes();
if (ps.length == 0)
noArgCtor = c;
else if (ps.length == 1 && ps[0] == Throwable.class)
return (Throwable) c.newInstance(ex);
}
if (noArgCtor != null) {
Throwable wx = (Throwable) noArgCtor.newInstance();
wx.initCause(ex);
return wx;
}
} catch (Exception ignore) {
}
}
return ex;
}
|
[
"private",
"Throwable",
"getThrowableException",
"(",
")",
"{",
"int",
"h",
"=",
"System",
".",
"identityHashCode",
"(",
"this",
")",
";",
"ExceptionNode",
"e",
";",
"final",
"ReentrantLock",
"lock",
"=",
"exceptionTableLock",
";",
"lock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"expungeStaleExceptions",
"(",
")",
";",
"ExceptionNode",
"[",
"]",
"t",
"=",
"exceptionTable",
";",
"e",
"=",
"t",
"[",
"h",
"&",
"(",
"t",
".",
"length",
"-",
"1",
")",
"]",
";",
"while",
"(",
"e",
"!=",
"null",
"&&",
"e",
".",
"get",
"(",
")",
"!=",
"this",
")",
"e",
"=",
"e",
".",
"next",
";",
"}",
"finally",
"{",
"lock",
".",
"unlock",
"(",
")",
";",
"}",
"Throwable",
"ex",
";",
"if",
"(",
"e",
"==",
"null",
"||",
"(",
"ex",
"=",
"e",
".",
"ex",
")",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"e",
".",
"thrower",
"!=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getId",
"(",
")",
")",
"{",
"try",
"{",
"Constructor",
"<",
"?",
">",
"noArgCtor",
"=",
"null",
";",
"// public ctors only",
"for",
"(",
"Constructor",
"<",
"?",
">",
"c",
":",
"ex",
".",
"getClass",
"(",
")",
".",
"getConstructors",
"(",
")",
")",
"{",
"Class",
"<",
"?",
">",
"[",
"]",
"ps",
"=",
"c",
".",
"getParameterTypes",
"(",
")",
";",
"if",
"(",
"ps",
".",
"length",
"==",
"0",
")",
"noArgCtor",
"=",
"c",
";",
"else",
"if",
"(",
"ps",
".",
"length",
"==",
"1",
"&&",
"ps",
"[",
"0",
"]",
"==",
"Throwable",
".",
"class",
")",
"return",
"(",
"Throwable",
")",
"c",
".",
"newInstance",
"(",
"ex",
")",
";",
"}",
"if",
"(",
"noArgCtor",
"!=",
"null",
")",
"{",
"Throwable",
"wx",
"=",
"(",
"Throwable",
")",
"noArgCtor",
".",
"newInstance",
"(",
")",
";",
"wx",
".",
"initCause",
"(",
"ex",
")",
";",
"return",
"wx",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ignore",
")",
"{",
"}",
"}",
"return",
"ex",
";",
"}"
] |
Returns a rethrowable exception for this task, if available. To provide accurate stack traces,
if the exception was not thrown by the current thread, we try to create a new exception of the
same type as the one thrown, but with the recorded exception as its cause. If there is no such
constructor, we instead try to use a no-arg constructor, followed by initCause, to the same
effect. If none of these apply, or any fail due to other exceptions, we return the recorded
exception, which is still correct, although it may contain a misleading stack trace.
@return the exception, or null if none
|
[
"Returns",
"a",
"rethrowable",
"exception",
"for",
"this",
"task",
"if",
"available",
".",
"To",
"provide",
"accurate",
"stack",
"traces",
"if",
"the",
"exception",
"was",
"not",
"thrown",
"by",
"the",
"current",
"thread",
"we",
"try",
"to",
"create",
"a",
"new",
"exception",
"of",
"the",
"same",
"type",
"as",
"the",
"one",
"thrown",
"but",
"with",
"the",
"recorded",
"exception",
"as",
"its",
"cause",
".",
"If",
"there",
"is",
"no",
"such",
"constructor",
"we",
"instead",
"try",
"to",
"use",
"a",
"no",
"-",
"arg",
"constructor",
"followed",
"by",
"initCause",
"to",
"the",
"same",
"effect",
".",
"If",
"none",
"of",
"these",
"apply",
"or",
"any",
"fail",
"due",
"to",
"other",
"exceptions",
"we",
"return",
"the",
"recorded",
"exception",
"which",
"is",
"still",
"correct",
"although",
"it",
"may",
"contain",
"a",
"misleading",
"stack",
"trace",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/ForkJoinTask.java#L819-L856
|
18,996
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/ForkJoinTask.java
|
ForkJoinTask.setForkJoinTaskTag
|
public final short setForkJoinTaskTag(short newValue) {
for (int s;;) {
if (U.compareAndSwapInt(this, STATUS, s = status, (s & ~SMASK) | (newValue & SMASK)))
return (short) s;
}
}
|
java
|
public final short setForkJoinTaskTag(short newValue) {
for (int s;;) {
if (U.compareAndSwapInt(this, STATUS, s = status, (s & ~SMASK) | (newValue & SMASK)))
return (short) s;
}
}
|
[
"public",
"final",
"short",
"setForkJoinTaskTag",
"(",
"short",
"newValue",
")",
"{",
"for",
"(",
"int",
"s",
";",
";",
")",
"{",
"if",
"(",
"U",
".",
"compareAndSwapInt",
"(",
"this",
",",
"STATUS",
",",
"s",
"=",
"status",
",",
"(",
"s",
"&",
"~",
"SMASK",
")",
"|",
"(",
"newValue",
"&",
"SMASK",
")",
")",
")",
"return",
"(",
"short",
")",
"s",
";",
"}",
"}"
] |
Atomically sets the tag value for this task and returns the old value.
@param newValue the new tag value
@return the previous value of the tag
@since 1.8
|
[
"Atomically",
"sets",
"the",
"tag",
"value",
"for",
"this",
"task",
"and",
"returns",
"the",
"old",
"value",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/ForkJoinTask.java#L1209-L1214
|
18,997
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java
|
NetworkAddressUtils.getBindAddress
|
public static InetSocketAddress getBindAddress(ServiceType service, AlluxioConfiguration conf) {
int port = getPort(service, conf);
assertValidPort(port);
return new InetSocketAddress(getBindHost(service, conf), getPort(service, conf));
}
|
java
|
public static InetSocketAddress getBindAddress(ServiceType service, AlluxioConfiguration conf) {
int port = getPort(service, conf);
assertValidPort(port);
return new InetSocketAddress(getBindHost(service, conf), getPort(service, conf));
}
|
[
"public",
"static",
"InetSocketAddress",
"getBindAddress",
"(",
"ServiceType",
"service",
",",
"AlluxioConfiguration",
"conf",
")",
"{",
"int",
"port",
"=",
"getPort",
"(",
"service",
",",
"conf",
")",
";",
"assertValidPort",
"(",
"port",
")",
";",
"return",
"new",
"InetSocketAddress",
"(",
"getBindHost",
"(",
"service",
",",
"conf",
")",
",",
"getPort",
"(",
"service",
",",
"conf",
")",
")",
";",
"}"
] |
Helper method to get the bind hostname for a given service.
@param service the service name
@param conf Alluxio configuration
@return the InetSocketAddress the service will bind to
|
[
"Helper",
"method",
"to",
"get",
"the",
"bind",
"hostname",
"for",
"a",
"given",
"service",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java#L319-L323
|
18,998
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java
|
NetworkAddressUtils.getClientHostName
|
@Deprecated
public static String getClientHostName(AlluxioConfiguration conf) {
if (conf.isSet(PropertyKey.USER_HOSTNAME)) {
return conf.get(PropertyKey.USER_HOSTNAME);
}
return getLocalHostName((int) conf.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS));
}
|
java
|
@Deprecated
public static String getClientHostName(AlluxioConfiguration conf) {
if (conf.isSet(PropertyKey.USER_HOSTNAME)) {
return conf.get(PropertyKey.USER_HOSTNAME);
}
return getLocalHostName((int) conf.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS));
}
|
[
"@",
"Deprecated",
"public",
"static",
"String",
"getClientHostName",
"(",
"AlluxioConfiguration",
"conf",
")",
"{",
"if",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"USER_HOSTNAME",
")",
")",
"{",
"return",
"conf",
".",
"get",
"(",
"PropertyKey",
".",
"USER_HOSTNAME",
")",
";",
"}",
"return",
"getLocalHostName",
"(",
"(",
"int",
")",
"conf",
".",
"getMs",
"(",
"PropertyKey",
".",
"NETWORK_HOST_RESOLUTION_TIMEOUT_MS",
")",
")",
";",
"}"
] |
Gets the local hostname to be used by the client. If this isn't configured, a
non-loopback local hostname will be looked up.
@param conf Alluxio configuration
@return the local hostname for the client
@deprecated This should not be used anymore as the USER_HOSTNAME key is deprecated
|
[
"Gets",
"the",
"local",
"hostname",
"to",
"be",
"used",
"by",
"the",
"client",
".",
"If",
"this",
"isn",
"t",
"configured",
"a",
"non",
"-",
"loopback",
"local",
"hostname",
"will",
"be",
"looked",
"up",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java#L356-L362
|
18,999
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java
|
NetworkAddressUtils.getLocalNodeName
|
public static String getLocalNodeName(AlluxioConfiguration conf) {
switch (CommonUtils.PROCESS_TYPE.get()) {
case JOB_MASTER:
if (conf.isSet(PropertyKey.JOB_MASTER_HOSTNAME)) {
return conf.get(PropertyKey.JOB_MASTER_HOSTNAME);
}
break;
case JOB_WORKER:
if (conf.isSet(PropertyKey.JOB_WORKER_HOSTNAME)) {
return conf.get(PropertyKey.JOB_WORKER_HOSTNAME);
}
break;
case CLIENT:
if (conf.isSet(PropertyKey.USER_HOSTNAME)) {
return conf.get(PropertyKey.USER_HOSTNAME);
}
break;
case MASTER:
if (conf.isSet(PropertyKey.MASTER_HOSTNAME)) {
return conf.get(PropertyKey.MASTER_HOSTNAME);
}
break;
case WORKER:
if (conf.isSet(PropertyKey.WORKER_HOSTNAME)) {
return conf.get(PropertyKey.WORKER_HOSTNAME);
}
break;
default:
break;
}
return getLocalHostName((int) conf.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS));
}
|
java
|
public static String getLocalNodeName(AlluxioConfiguration conf) {
switch (CommonUtils.PROCESS_TYPE.get()) {
case JOB_MASTER:
if (conf.isSet(PropertyKey.JOB_MASTER_HOSTNAME)) {
return conf.get(PropertyKey.JOB_MASTER_HOSTNAME);
}
break;
case JOB_WORKER:
if (conf.isSet(PropertyKey.JOB_WORKER_HOSTNAME)) {
return conf.get(PropertyKey.JOB_WORKER_HOSTNAME);
}
break;
case CLIENT:
if (conf.isSet(PropertyKey.USER_HOSTNAME)) {
return conf.get(PropertyKey.USER_HOSTNAME);
}
break;
case MASTER:
if (conf.isSet(PropertyKey.MASTER_HOSTNAME)) {
return conf.get(PropertyKey.MASTER_HOSTNAME);
}
break;
case WORKER:
if (conf.isSet(PropertyKey.WORKER_HOSTNAME)) {
return conf.get(PropertyKey.WORKER_HOSTNAME);
}
break;
default:
break;
}
return getLocalHostName((int) conf.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS));
}
|
[
"public",
"static",
"String",
"getLocalNodeName",
"(",
"AlluxioConfiguration",
"conf",
")",
"{",
"switch",
"(",
"CommonUtils",
".",
"PROCESS_TYPE",
".",
"get",
"(",
")",
")",
"{",
"case",
"JOB_MASTER",
":",
"if",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"JOB_MASTER_HOSTNAME",
")",
")",
"{",
"return",
"conf",
".",
"get",
"(",
"PropertyKey",
".",
"JOB_MASTER_HOSTNAME",
")",
";",
"}",
"break",
";",
"case",
"JOB_WORKER",
":",
"if",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"JOB_WORKER_HOSTNAME",
")",
")",
"{",
"return",
"conf",
".",
"get",
"(",
"PropertyKey",
".",
"JOB_WORKER_HOSTNAME",
")",
";",
"}",
"break",
";",
"case",
"CLIENT",
":",
"if",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"USER_HOSTNAME",
")",
")",
"{",
"return",
"conf",
".",
"get",
"(",
"PropertyKey",
".",
"USER_HOSTNAME",
")",
";",
"}",
"break",
";",
"case",
"MASTER",
":",
"if",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"MASTER_HOSTNAME",
")",
")",
"{",
"return",
"conf",
".",
"get",
"(",
"PropertyKey",
".",
"MASTER_HOSTNAME",
")",
";",
"}",
"break",
";",
"case",
"WORKER",
":",
"if",
"(",
"conf",
".",
"isSet",
"(",
"PropertyKey",
".",
"WORKER_HOSTNAME",
")",
")",
"{",
"return",
"conf",
".",
"get",
"(",
"PropertyKey",
".",
"WORKER_HOSTNAME",
")",
";",
"}",
"break",
";",
"default",
":",
"break",
";",
"}",
"return",
"getLocalHostName",
"(",
"(",
"int",
")",
"conf",
".",
"getMs",
"(",
"PropertyKey",
".",
"NETWORK_HOST_RESOLUTION_TIMEOUT_MS",
")",
")",
";",
"}"
] |
Gets a local node name from configuration if it is available, falling back on localhost lookup.
@param conf Alluxio configuration
@return the local node name
|
[
"Gets",
"a",
"local",
"node",
"name",
"from",
"configuration",
"if",
"it",
"is",
"available",
"falling",
"back",
"on",
"localhost",
"lookup",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java#L370-L401
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.