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,600
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/raft/RaftJournalConfiguration.java
|
RaftJournalConfiguration.validate
|
public void validate() {
Preconditions.checkState(getMaxLogSize() <= Integer.MAX_VALUE,
"{} has value {} but must not exceed {}", PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX,
getMaxLogSize(), Integer.MAX_VALUE);
Preconditions.checkState(getHeartbeatIntervalMs() < getElectionTimeoutMs() / 2,
"Heartbeat interval (%sms) should be less than half of the election timeout (%sms)",
getHeartbeatIntervalMs(), getElectionTimeoutMs());
Preconditions.checkState(getClusterAddresses().contains(getLocalAddress()),
"The cluster addresses (%s) must contain the local master address (%s)",
getClusterAddresses(), getLocalAddress());
}
|
java
|
public void validate() {
Preconditions.checkState(getMaxLogSize() <= Integer.MAX_VALUE,
"{} has value {} but must not exceed {}", PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX,
getMaxLogSize(), Integer.MAX_VALUE);
Preconditions.checkState(getHeartbeatIntervalMs() < getElectionTimeoutMs() / 2,
"Heartbeat interval (%sms) should be less than half of the election timeout (%sms)",
getHeartbeatIntervalMs(), getElectionTimeoutMs());
Preconditions.checkState(getClusterAddresses().contains(getLocalAddress()),
"The cluster addresses (%s) must contain the local master address (%s)",
getClusterAddresses(), getLocalAddress());
}
|
[
"public",
"void",
"validate",
"(",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"getMaxLogSize",
"(",
")",
"<=",
"Integer",
".",
"MAX_VALUE",
",",
"\"{} has value {} but must not exceed {}\"",
",",
"PropertyKey",
".",
"MASTER_JOURNAL_LOG_SIZE_BYTES_MAX",
",",
"getMaxLogSize",
"(",
")",
",",
"Integer",
".",
"MAX_VALUE",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"getHeartbeatIntervalMs",
"(",
")",
"<",
"getElectionTimeoutMs",
"(",
")",
"/",
"2",
",",
"\"Heartbeat interval (%sms) should be less than half of the election timeout (%sms)\"",
",",
"getHeartbeatIntervalMs",
"(",
")",
",",
"getElectionTimeoutMs",
"(",
")",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"getClusterAddresses",
"(",
")",
".",
"contains",
"(",
"getLocalAddress",
"(",
")",
")",
",",
"\"The cluster addresses (%s) must contain the local master address (%s)\"",
",",
"getClusterAddresses",
"(",
")",
",",
"getLocalAddress",
"(",
")",
")",
";",
"}"
] |
Validates the configuration.
|
[
"Validates",
"the",
"configuration",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/raft/RaftJournalConfiguration.java#L70-L80
|
18,601
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/security/group/CachedGroupMapping.java
|
CachedGroupMapping.getGroups
|
public List<String> getGroups(String user) throws IOException {
if (!mCacheEnabled) {
return mService.getGroups(user);
}
try {
return mCache.get(user);
} catch (ExecutionException e) {
throw new IOException(e);
}
}
|
java
|
public List<String> getGroups(String user) throws IOException {
if (!mCacheEnabled) {
return mService.getGroups(user);
}
try {
return mCache.get(user);
} catch (ExecutionException e) {
throw new IOException(e);
}
}
|
[
"public",
"List",
"<",
"String",
">",
"getGroups",
"(",
"String",
"user",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"mCacheEnabled",
")",
"{",
"return",
"mService",
".",
"getGroups",
"(",
"user",
")",
";",
"}",
"try",
"{",
"return",
"mCache",
".",
"get",
"(",
"user",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
")",
";",
"}",
"}"
] |
Gets a list of groups for the given user.
@param user user name
@return the list of groups that the user belongs to
|
[
"Gets",
"a",
"list",
"of",
"groups",
"for",
"the",
"given",
"user",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/security/group/CachedGroupMapping.java#L105-L114
|
18,602
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationStore.java
|
ServerConfigurationStore.registerNewConf
|
public synchronized void registerNewConf(Address address, List<ConfigProperty> configList) {
Preconditions.checkNotNull(address, "address should not be null");
Preconditions.checkNotNull(configList, "configuration list should not be null");
// Instead of recording property name, we record property key.
mConfMap.put(address, configList.stream().map(c -> new ConfigRecord()
.setKey(toPropertyKey(c.getName())).setSource(c.getSource())
.setValue(c.getValue())).collect(Collectors.toList()));
mLostNodes.remove(address);
for (Runnable function : mChangeListeners) {
function.run();
}
}
|
java
|
public synchronized void registerNewConf(Address address, List<ConfigProperty> configList) {
Preconditions.checkNotNull(address, "address should not be null");
Preconditions.checkNotNull(configList, "configuration list should not be null");
// Instead of recording property name, we record property key.
mConfMap.put(address, configList.stream().map(c -> new ConfigRecord()
.setKey(toPropertyKey(c.getName())).setSource(c.getSource())
.setValue(c.getValue())).collect(Collectors.toList()));
mLostNodes.remove(address);
for (Runnable function : mChangeListeners) {
function.run();
}
}
|
[
"public",
"synchronized",
"void",
"registerNewConf",
"(",
"Address",
"address",
",",
"List",
"<",
"ConfigProperty",
">",
"configList",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"address",
",",
"\"address should not be null\"",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"configList",
",",
"\"configuration list should not be null\"",
")",
";",
"// Instead of recording property name, we record property key.",
"mConfMap",
".",
"put",
"(",
"address",
",",
"configList",
".",
"stream",
"(",
")",
".",
"map",
"(",
"c",
"->",
"new",
"ConfigRecord",
"(",
")",
".",
"setKey",
"(",
"toPropertyKey",
"(",
"c",
".",
"getName",
"(",
")",
")",
")",
".",
"setSource",
"(",
"c",
".",
"getSource",
"(",
")",
")",
".",
"setValue",
"(",
"c",
".",
"getValue",
"(",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
")",
";",
"mLostNodes",
".",
"remove",
"(",
"address",
")",
";",
"for",
"(",
"Runnable",
"function",
":",
"mChangeListeners",
")",
"{",
"function",
".",
"run",
"(",
")",
";",
"}",
"}"
] |
Registers new configuration information.
@param address the node address
@param configList the configuration of this node
|
[
"Registers",
"new",
"configuration",
"information",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationStore.java#L64-L75
|
18,603
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationStore.java
|
ServerConfigurationStore.handleNodeLost
|
public synchronized void handleNodeLost(Address address) {
Preconditions.checkNotNull(address, "address should not be null");
mLostNodes.add(address);
for (Runnable function : mChangeListeners) {
function.run();
}
}
|
java
|
public synchronized void handleNodeLost(Address address) {
Preconditions.checkNotNull(address, "address should not be null");
mLostNodes.add(address);
for (Runnable function : mChangeListeners) {
function.run();
}
}
|
[
"public",
"synchronized",
"void",
"handleNodeLost",
"(",
"Address",
"address",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"address",
",",
"\"address should not be null\"",
")",
";",
"mLostNodes",
".",
"add",
"(",
"address",
")",
";",
"for",
"(",
"Runnable",
"function",
":",
"mChangeListeners",
")",
"{",
"function",
".",
"run",
"(",
")",
";",
"}",
"}"
] |
Updates configuration when a live node becomes lost.
@param address the node address
|
[
"Updates",
"configuration",
"when",
"a",
"live",
"node",
"becomes",
"lost",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationStore.java#L92-L98
|
18,604
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationStore.java
|
ServerConfigurationStore.lostNodeFound
|
public synchronized void lostNodeFound(Address address) {
Preconditions.checkNotNull(address, "address should not be null");
mLostNodes.remove(address);
for (Runnable function : mChangeListeners) {
function.run();
}
}
|
java
|
public synchronized void lostNodeFound(Address address) {
Preconditions.checkNotNull(address, "address should not be null");
mLostNodes.remove(address);
for (Runnable function : mChangeListeners) {
function.run();
}
}
|
[
"public",
"synchronized",
"void",
"lostNodeFound",
"(",
"Address",
"address",
")",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"address",
",",
"\"address should not be null\"",
")",
";",
"mLostNodes",
".",
"remove",
"(",
"address",
")",
";",
"for",
"(",
"Runnable",
"function",
":",
"mChangeListeners",
")",
"{",
"function",
".",
"run",
"(",
")",
";",
"}",
"}"
] |
Updates configuration when a lost node is found.
@param address the node address
|
[
"Updates",
"configuration",
"when",
"a",
"lost",
"node",
"is",
"found",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationStore.java#L105-L111
|
18,605
|
Alluxio/alluxio
|
job/common/src/main/java/alluxio/job/meta/JobInfo.java
|
JobInfo.addTask
|
public synchronized void addTask(int taskId) {
Preconditions.checkArgument(!mTaskIdToInfo.containsKey(taskId), "");
mTaskIdToInfo.put(taskId, new TaskInfo().setJobId(mId).setTaskId(taskId)
.setStatus(Status.CREATED).setErrorMessage("").setResult(null));
}
|
java
|
public synchronized void addTask(int taskId) {
Preconditions.checkArgument(!mTaskIdToInfo.containsKey(taskId), "");
mTaskIdToInfo.put(taskId, new TaskInfo().setJobId(mId).setTaskId(taskId)
.setStatus(Status.CREATED).setErrorMessage("").setResult(null));
}
|
[
"public",
"synchronized",
"void",
"addTask",
"(",
"int",
"taskId",
")",
"{",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"mTaskIdToInfo",
".",
"containsKey",
"(",
"taskId",
")",
",",
"\"\"",
")",
";",
"mTaskIdToInfo",
".",
"put",
"(",
"taskId",
",",
"new",
"TaskInfo",
"(",
")",
".",
"setJobId",
"(",
"mId",
")",
".",
"setTaskId",
"(",
"taskId",
")",
".",
"setStatus",
"(",
"Status",
".",
"CREATED",
")",
".",
"setErrorMessage",
"(",
"\"\"",
")",
".",
"setResult",
"(",
"null",
")",
")",
";",
"}"
] |
Registers a task.
@param taskId the task id
|
[
"Registers",
"a",
"task",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/common/src/main/java/alluxio/job/meta/JobInfo.java#L75-L79
|
18,606
|
Alluxio/alluxio
|
job/server/src/main/java/alluxio/master/AlluxioJobMasterProcess.java
|
AlluxioJobMasterProcess.start
|
@Override
public void start() throws Exception {
mJournalSystem.start();
mJournalSystem.gainPrimacy();
startMaster(true);
startServing();
}
|
java
|
@Override
public void start() throws Exception {
mJournalSystem.start();
mJournalSystem.gainPrimacy();
startMaster(true);
startServing();
}
|
[
"@",
"Override",
"public",
"void",
"start",
"(",
")",
"throws",
"Exception",
"{",
"mJournalSystem",
".",
"start",
"(",
")",
";",
"mJournalSystem",
".",
"gainPrimacy",
"(",
")",
";",
"startMaster",
"(",
"true",
")",
";",
"startServing",
"(",
")",
";",
"}"
] |
Starts the Alluxio job master server.
@throws Exception if starting the master fails
|
[
"Starts",
"the",
"Alluxio",
"job",
"master",
"server",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/server/src/main/java/alluxio/master/AlluxioJobMasterProcess.java#L129-L135
|
18,607
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/URIUtils.java
|
URIUtils.appendPath
|
public static URI appendPath(URI base, String path) throws URISyntaxException {
return new URI(base.getScheme(), base.getAuthority(),
PathUtils.concatPath(base.getPath(), path), base.getQuery(), base.getFragment());
}
|
java
|
public static URI appendPath(URI base, String path) throws URISyntaxException {
return new URI(base.getScheme(), base.getAuthority(),
PathUtils.concatPath(base.getPath(), path), base.getQuery(), base.getFragment());
}
|
[
"public",
"static",
"URI",
"appendPath",
"(",
"URI",
"base",
",",
"String",
"path",
")",
"throws",
"URISyntaxException",
"{",
"return",
"new",
"URI",
"(",
"base",
".",
"getScheme",
"(",
")",
",",
"base",
".",
"getAuthority",
"(",
")",
",",
"PathUtils",
".",
"concatPath",
"(",
"base",
".",
"getPath",
"(",
")",
",",
"path",
")",
",",
"base",
".",
"getQuery",
"(",
")",
",",
"base",
".",
"getFragment",
"(",
")",
")",
";",
"}"
] |
Appends the given path to the given base URI.
@param base the base URI
@param path the path to append
@return the URI resulting from appending the base and the path
@throws URISyntaxException if URI syntax error is encountered
|
[
"Appends",
"the",
"given",
"path",
"to",
"the",
"given",
"base",
"URI",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/URIUtils.java#L50-L53
|
18,608
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/URIUtils.java
|
URIUtils.parseQueryString
|
public static Map<String, String> parseQueryString(String query) {
Map<String, String> queryMap = new HashMap<>();
if (query == null || query.isEmpty()) {
return queryMap;
}
// The query string should escape '&'.
String[] entries = query.split(String.valueOf(QUERY_SEPARATOR));
try {
for (String entry : entries) {
// There should be at most 2 parts, since key and value both should escape '='.
String[] parts = entry.split(String.valueOf(QUERY_KEY_VALUE_SEPARATOR));
if (parts.length == 0) {
// Skip this empty entry.
} else if (parts.length == 1) {
// There is no value part. Just use empty string as the value.
String key = URLDecoder.decode(parts[0], "UTF-8");
queryMap.put(key, "");
} else {
// Save the key and value.
String key = URLDecoder.decode(parts[0], "UTF-8");
String value = URLDecoder.decode(parts[1], "UTF-8");
queryMap.put(key, value);
}
}
} catch (UnsupportedEncodingException e) {
// This is unexpected.
throw new RuntimeException(e);
}
return queryMap;
}
|
java
|
public static Map<String, String> parseQueryString(String query) {
Map<String, String> queryMap = new HashMap<>();
if (query == null || query.isEmpty()) {
return queryMap;
}
// The query string should escape '&'.
String[] entries = query.split(String.valueOf(QUERY_SEPARATOR));
try {
for (String entry : entries) {
// There should be at most 2 parts, since key and value both should escape '='.
String[] parts = entry.split(String.valueOf(QUERY_KEY_VALUE_SEPARATOR));
if (parts.length == 0) {
// Skip this empty entry.
} else if (parts.length == 1) {
// There is no value part. Just use empty string as the value.
String key = URLDecoder.decode(parts[0], "UTF-8");
queryMap.put(key, "");
} else {
// Save the key and value.
String key = URLDecoder.decode(parts[0], "UTF-8");
String value = URLDecoder.decode(parts[1], "UTF-8");
queryMap.put(key, value);
}
}
} catch (UnsupportedEncodingException e) {
// This is unexpected.
throw new RuntimeException(e);
}
return queryMap;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"String",
">",
"parseQueryString",
"(",
"String",
"query",
")",
"{",
"Map",
"<",
"String",
",",
"String",
">",
"queryMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"if",
"(",
"query",
"==",
"null",
"||",
"query",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"queryMap",
";",
"}",
"// The query string should escape '&'.",
"String",
"[",
"]",
"entries",
"=",
"query",
".",
"split",
"(",
"String",
".",
"valueOf",
"(",
"QUERY_SEPARATOR",
")",
")",
";",
"try",
"{",
"for",
"(",
"String",
"entry",
":",
"entries",
")",
"{",
"// There should be at most 2 parts, since key and value both should escape '='.",
"String",
"[",
"]",
"parts",
"=",
"entry",
".",
"split",
"(",
"String",
".",
"valueOf",
"(",
"QUERY_KEY_VALUE_SEPARATOR",
")",
")",
";",
"if",
"(",
"parts",
".",
"length",
"==",
"0",
")",
"{",
"// Skip this empty entry.",
"}",
"else",
"if",
"(",
"parts",
".",
"length",
"==",
"1",
")",
"{",
"// There is no value part. Just use empty string as the value.",
"String",
"key",
"=",
"URLDecoder",
".",
"decode",
"(",
"parts",
"[",
"0",
"]",
",",
"\"UTF-8\"",
")",
";",
"queryMap",
".",
"put",
"(",
"key",
",",
"\"\"",
")",
";",
"}",
"else",
"{",
"// Save the key and value.",
"String",
"key",
"=",
"URLDecoder",
".",
"decode",
"(",
"parts",
"[",
"0",
"]",
",",
"\"UTF-8\"",
")",
";",
"String",
"value",
"=",
"URLDecoder",
".",
"decode",
"(",
"parts",
"[",
"1",
"]",
",",
"\"UTF-8\"",
")",
";",
"queryMap",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"UnsupportedEncodingException",
"e",
")",
"{",
"// This is unexpected.",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"return",
"queryMap",
";",
"}"
] |
Parses the given query string, and returns a map of the query parameters.
@param query the query string to parse
@return the map of query keys and values
|
[
"Parses",
"the",
"given",
"query",
"string",
"and",
"returns",
"a",
"map",
"of",
"the",
"query",
"parameters",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/URIUtils.java#L103-L133
|
18,609
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/URIUtils.java
|
URIUtils.hash
|
public static int hash(int hash, String s) {
if (s == null) {
return hash;
}
// similar to Arrays.hashCode
return s.indexOf('%') < 0 ? 31 * hash + s.hashCode() : normalizedHash(hash, s);
}
|
java
|
public static int hash(int hash, String s) {
if (s == null) {
return hash;
}
// similar to Arrays.hashCode
return s.indexOf('%') < 0 ? 31 * hash + s.hashCode() : normalizedHash(hash, s);
}
|
[
"public",
"static",
"int",
"hash",
"(",
"int",
"hash",
",",
"String",
"s",
")",
"{",
"if",
"(",
"s",
"==",
"null",
")",
"{",
"return",
"hash",
";",
"}",
"// similar to Arrays.hashCode",
"return",
"s",
".",
"indexOf",
"(",
"'",
"'",
")",
"<",
"0",
"?",
"31",
"*",
"hash",
"+",
"s",
".",
"hashCode",
"(",
")",
":",
"normalizedHash",
"(",
"hash",
",",
"s",
")",
";",
"}"
] |
Hashes a string for a URI hash. Handles octets.
@param hash the input hash
@param s the string to hash and combine with the input hash
@return the resulting hash
|
[
"Hashes",
"a",
"string",
"for",
"a",
"URI",
"hash",
".",
"Handles",
"octets",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/URIUtils.java#L276-L282
|
18,610
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/util/URIUtils.java
|
URIUtils.hashIgnoreCase
|
public static int hashIgnoreCase(int hash, String s) {
if (s == null) {
return hash;
}
int length = s.length();
for (int i = 0; i < length; i++) {
hash = 31 * hash + URIUtils.toLower(s.charAt(i));
}
return hash;
}
|
java
|
public static int hashIgnoreCase(int hash, String s) {
if (s == null) {
return hash;
}
int length = s.length();
for (int i = 0; i < length; i++) {
hash = 31 * hash + URIUtils.toLower(s.charAt(i));
}
return hash;
}
|
[
"public",
"static",
"int",
"hashIgnoreCase",
"(",
"int",
"hash",
",",
"String",
"s",
")",
"{",
"if",
"(",
"s",
"==",
"null",
")",
"{",
"return",
"hash",
";",
"}",
"int",
"length",
"=",
"s",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"hash",
"=",
"31",
"*",
"hash",
"+",
"URIUtils",
".",
"toLower",
"(",
"s",
".",
"charAt",
"(",
"i",
")",
")",
";",
"}",
"return",
"hash",
";",
"}"
] |
Hashes a string for a URI hash, while ignoring the case.
@param hash the input hash
@param s the string to hash and combine with the input hash
@return the resulting hash
|
[
"Hashes",
"a",
"string",
"for",
"a",
"URI",
"hash",
"while",
"ignoring",
"the",
"case",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/util/URIUtils.java#L291-L300
|
18,611
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/SecurityUtils.java
|
SecurityUtils.isAuthenticationEnabled
|
public static boolean isAuthenticationEnabled(AlluxioConfiguration conf) {
return !conf.getEnum(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.class)
.equals(AuthType.NOSASL);
}
|
java
|
public static boolean isAuthenticationEnabled(AlluxioConfiguration conf) {
return !conf.getEnum(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.class)
.equals(AuthType.NOSASL);
}
|
[
"public",
"static",
"boolean",
"isAuthenticationEnabled",
"(",
"AlluxioConfiguration",
"conf",
")",
"{",
"return",
"!",
"conf",
".",
"getEnum",
"(",
"PropertyKey",
".",
"SECURITY_AUTHENTICATION_TYPE",
",",
"AuthType",
".",
"class",
")",
".",
"equals",
"(",
"AuthType",
".",
"NOSASL",
")",
";",
"}"
] |
Checks if authentication is enabled.
@param conf Alluxio configuration
@return true if authentication is enabled, false otherwise
|
[
"Checks",
"if",
"authentication",
"is",
"enabled",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/SecurityUtils.java#L49-L52
|
18,612
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/worker/AlluxioWorkerMonitor.java
|
AlluxioWorkerMonitor.main
|
public static void main(String[] args) {
if (args.length != 0) {
LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR,
AlluxioWorkerMonitor.class.getCanonicalName());
LOG.warn("ignoring arguments");
}
AlluxioConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
HealthCheckClient client = new WorkerHealthCheckClient(
NetworkAddressUtils.getConnectAddress(NetworkAddressUtils.ServiceType.WORKER_RPC, conf),
ONE_MIN_EXP_BACKOFF, conf);
if (!client.isServing()) {
System.exit(1);
}
System.exit(0);
}
|
java
|
public static void main(String[] args) {
if (args.length != 0) {
LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR,
AlluxioWorkerMonitor.class.getCanonicalName());
LOG.warn("ignoring arguments");
}
AlluxioConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
HealthCheckClient client = new WorkerHealthCheckClient(
NetworkAddressUtils.getConnectAddress(NetworkAddressUtils.ServiceType.WORKER_RPC, conf),
ONE_MIN_EXP_BACKOFF, conf);
if (!client.isServing()) {
System.exit(1);
}
System.exit(0);
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"if",
"(",
"args",
".",
"length",
"!=",
"0",
")",
"{",
"LOG",
".",
"info",
"(",
"\"java -cp {} {}\"",
",",
"RuntimeConstants",
".",
"ALLUXIO_JAR",
",",
"AlluxioWorkerMonitor",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
";",
"LOG",
".",
"warn",
"(",
"\"ignoring arguments\"",
")",
";",
"}",
"AlluxioConfiguration",
"conf",
"=",
"new",
"InstancedConfiguration",
"(",
"ConfigurationUtils",
".",
"defaults",
"(",
")",
")",
";",
"HealthCheckClient",
"client",
"=",
"new",
"WorkerHealthCheckClient",
"(",
"NetworkAddressUtils",
".",
"getConnectAddress",
"(",
"NetworkAddressUtils",
".",
"ServiceType",
".",
"WORKER_RPC",
",",
"conf",
")",
",",
"ONE_MIN_EXP_BACKOFF",
",",
"conf",
")",
";",
"if",
"(",
"!",
"client",
".",
"isServing",
"(",
")",
")",
"{",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}"
] |
Starts the Alluxio worker monitor.
@param args command line arguments, should be empty
|
[
"Starts",
"the",
"Alluxio",
"worker",
"monitor",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/worker/AlluxioWorkerMonitor.java#L42-L57
|
18,613
|
Alluxio/alluxio
|
job/server/src/main/java/alluxio/job/migrate/MigrateDefinition.java
|
MigrateDefinition.computeTargetPath
|
private static String computeTargetPath(String path, String source, String destination)
throws Exception {
String relativePath = PathUtils.subtractPaths(path, source);
return PathUtils.concatPath(destination, relativePath);
}
|
java
|
private static String computeTargetPath(String path, String source, String destination)
throws Exception {
String relativePath = PathUtils.subtractPaths(path, source);
return PathUtils.concatPath(destination, relativePath);
}
|
[
"private",
"static",
"String",
"computeTargetPath",
"(",
"String",
"path",
",",
"String",
"source",
",",
"String",
"destination",
")",
"throws",
"Exception",
"{",
"String",
"relativePath",
"=",
"PathUtils",
".",
"subtractPaths",
"(",
"path",
",",
"source",
")",
";",
"return",
"PathUtils",
".",
"concatPath",
"(",
"destination",
",",
"relativePath",
")",
";",
"}"
] |
Computes the path that the given path should end up at when source is migrated to destination.
@param path a path to migrate which must be a descendent path of the source path,
e.g. /src/file
@param source the base source path being migrated, e.g. /src
@param destination the path to migrate to, e.g. /dst/src
@return the path which file should be migrated to, e.g. /dst/src/file
|
[
"Computes",
"the",
"path",
"that",
"the",
"given",
"path",
"should",
"end",
"up",
"at",
"when",
"source",
"is",
"migrated",
"to",
"destination",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/server/src/main/java/alluxio/job/migrate/MigrateDefinition.java#L218-L222
|
18,614
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/metastore/rocks/RocksUtils.java
|
RocksUtils.generateDbPath
|
public static String generateDbPath(String baseDir, String dbName) {
return PathUtils.concatPath(baseDir, dbName);
}
|
java
|
public static String generateDbPath(String baseDir, String dbName) {
return PathUtils.concatPath(baseDir, dbName);
}
|
[
"public",
"static",
"String",
"generateDbPath",
"(",
"String",
"baseDir",
",",
"String",
"dbName",
")",
"{",
"return",
"PathUtils",
".",
"concatPath",
"(",
"baseDir",
",",
"dbName",
")",
";",
"}"
] |
Generates a path to use for a RocksDB database.
@param baseDir the base directory path
@param dbName a name for the database
@return the generated database path
|
[
"Generates",
"a",
"path",
"to",
"use",
"for",
"a",
"RocksDB",
"database",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/metastore/rocks/RocksUtils.java#L32-L34
|
18,615
|
Alluxio/alluxio
|
underfs/kodo/src/main/java/alluxio/underfs/kodo/KodoUnderFileSystem.java
|
KodoUnderFileSystem.getObjectStatus
|
@Nullable
@Override
protected ObjectStatus getObjectStatus(String key) {
try {
FileInfo fileInfo = mKodoClinet.getFileInfo(key);
if (fileInfo == null) {
return null;
}
return new ObjectStatus(key, fileInfo.hash, fileInfo.fsize, fileInfo.putTime / 10000);
} catch (QiniuException e) {
LOG.warn("Failed to get Object {}, Msg: {}", key, e);
}
return null;
}
|
java
|
@Nullable
@Override
protected ObjectStatus getObjectStatus(String key) {
try {
FileInfo fileInfo = mKodoClinet.getFileInfo(key);
if (fileInfo == null) {
return null;
}
return new ObjectStatus(key, fileInfo.hash, fileInfo.fsize, fileInfo.putTime / 10000);
} catch (QiniuException e) {
LOG.warn("Failed to get Object {}, Msg: {}", key, e);
}
return null;
}
|
[
"@",
"Nullable",
"@",
"Override",
"protected",
"ObjectStatus",
"getObjectStatus",
"(",
"String",
"key",
")",
"{",
"try",
"{",
"FileInfo",
"fileInfo",
"=",
"mKodoClinet",
".",
"getFileInfo",
"(",
"key",
")",
";",
"if",
"(",
"fileInfo",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"ObjectStatus",
"(",
"key",
",",
"fileInfo",
".",
"hash",
",",
"fileInfo",
".",
"fsize",
",",
"fileInfo",
".",
"putTime",
"/",
"10000",
")",
";",
"}",
"catch",
"(",
"QiniuException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to get Object {}, Msg: {}\"",
",",
"key",
",",
"e",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Gets metadata information about object. Implementations should process the key as is, which may
be a file or a directory key.
@param key ufs key to get metadata for
@return {@link ObjectStatus} if key exists and successful, otherwise null
|
[
"Gets",
"metadata",
"information",
"about",
"object",
".",
"Implementations",
"should",
"process",
"the",
"key",
"as",
"is",
"which",
"may",
"be",
"a",
"file",
"or",
"a",
"directory",
"key",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/kodo/src/main/java/alluxio/underfs/kodo/KodoUnderFileSystem.java#L186-L199
|
18,616
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/StorageTierAssoc.java
|
StorageTierAssoc.interpretOrdinal
|
static int interpretOrdinal(int ordinal, int numTiers) {
if (ordinal >= 0) {
return Math.min(ordinal, numTiers - 1);
}
return Math.max(numTiers + ordinal, 0);
}
|
java
|
static int interpretOrdinal(int ordinal, int numTiers) {
if (ordinal >= 0) {
return Math.min(ordinal, numTiers - 1);
}
return Math.max(numTiers + ordinal, 0);
}
|
[
"static",
"int",
"interpretOrdinal",
"(",
"int",
"ordinal",
",",
"int",
"numTiers",
")",
"{",
"if",
"(",
"ordinal",
">=",
"0",
")",
"{",
"return",
"Math",
".",
"min",
"(",
"ordinal",
",",
"numTiers",
"-",
"1",
")",
";",
"}",
"return",
"Math",
".",
"max",
"(",
"numTiers",
"+",
"ordinal",
",",
"0",
")",
";",
"}"
] |
Interprets a tier ordinal given the number of tiers.
Non-negative values identify tiers starting from top going down (0 identifies the first tier,
1 identifies the second tier, and so on). If the provided value is greater than the number
of tiers, it identifies the last tier. Negative values identify tiers starting from the bottom
going up (-1 identifies the last tier, -2 identifies the second to last tier, and so on). If
the absolute value of the provided value is greater than the number of tiers, it identifies
the first tier.
@param ordinal the storage tier ordinal to interpret
@param numTiers the number of storage tiers
@return a valid tier ordinal
|
[
"Interprets",
"a",
"tier",
"ordinal",
"given",
"the",
"number",
"of",
"tiers",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/StorageTierAssoc.java#L50-L55
|
18,617
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/webui/UIFileInfo.java
|
UIFileInfo.addBlock
|
public void addBlock(String tierAlias, long blockId, long blockSize, long blockLastAccessTimeMs) {
UIFileBlockInfo block =
new UIFileBlockInfo(blockId, blockSize, blockLastAccessTimeMs, tierAlias,
mAlluxioConfiguration);
List<UIFileBlockInfo> blocksOnTier = mBlocksOnTier.get(tierAlias);
if (blocksOnTier == null) {
blocksOnTier = new ArrayList<>();
mBlocksOnTier.put(tierAlias, blocksOnTier);
}
blocksOnTier.add(block);
Long sizeOnTier = mSizeOnTier.get(tierAlias);
mSizeOnTier.put(tierAlias, (sizeOnTier == null ? 0L : sizeOnTier) + blockSize);
}
|
java
|
public void addBlock(String tierAlias, long blockId, long blockSize, long blockLastAccessTimeMs) {
UIFileBlockInfo block =
new UIFileBlockInfo(blockId, blockSize, blockLastAccessTimeMs, tierAlias,
mAlluxioConfiguration);
List<UIFileBlockInfo> blocksOnTier = mBlocksOnTier.get(tierAlias);
if (blocksOnTier == null) {
blocksOnTier = new ArrayList<>();
mBlocksOnTier.put(tierAlias, blocksOnTier);
}
blocksOnTier.add(block);
Long sizeOnTier = mSizeOnTier.get(tierAlias);
mSizeOnTier.put(tierAlias, (sizeOnTier == null ? 0L : sizeOnTier) + blockSize);
}
|
[
"public",
"void",
"addBlock",
"(",
"String",
"tierAlias",
",",
"long",
"blockId",
",",
"long",
"blockSize",
",",
"long",
"blockLastAccessTimeMs",
")",
"{",
"UIFileBlockInfo",
"block",
"=",
"new",
"UIFileBlockInfo",
"(",
"blockId",
",",
"blockSize",
",",
"blockLastAccessTimeMs",
",",
"tierAlias",
",",
"mAlluxioConfiguration",
")",
";",
"List",
"<",
"UIFileBlockInfo",
">",
"blocksOnTier",
"=",
"mBlocksOnTier",
".",
"get",
"(",
"tierAlias",
")",
";",
"if",
"(",
"blocksOnTier",
"==",
"null",
")",
"{",
"blocksOnTier",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"mBlocksOnTier",
".",
"put",
"(",
"tierAlias",
",",
"blocksOnTier",
")",
";",
"}",
"blocksOnTier",
".",
"add",
"(",
"block",
")",
";",
"Long",
"sizeOnTier",
"=",
"mSizeOnTier",
".",
"get",
"(",
"tierAlias",
")",
";",
"mSizeOnTier",
".",
"put",
"(",
"tierAlias",
",",
"(",
"sizeOnTier",
"==",
"null",
"?",
"0L",
":",
"sizeOnTier",
")",
"+",
"blockSize",
")",
";",
"}"
] |
Adds a block to the file information.
@param tierAlias the tier alias
@param blockId the block id
@param blockSize the block size
@param blockLastAccessTimeMs the last access time (in milliseconds)
|
[
"Adds",
"a",
"block",
"to",
"the",
"file",
"information",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/webui/UIFileInfo.java#L189-L202
|
18,618
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/webui/UIFileInfo.java
|
UIFileInfo.getCreationTime
|
public String getCreationTime() {
if (mCreationTimeMs == UIFileInfo.LocalFileInfo.EMPTY_CREATION_TIME) {
return "";
}
return CommonUtils.convertMsToDate(mCreationTimeMs,
mAlluxioConfiguration.get(PropertyKey.USER_DATE_FORMAT_PATTERN));
}
|
java
|
public String getCreationTime() {
if (mCreationTimeMs == UIFileInfo.LocalFileInfo.EMPTY_CREATION_TIME) {
return "";
}
return CommonUtils.convertMsToDate(mCreationTimeMs,
mAlluxioConfiguration.get(PropertyKey.USER_DATE_FORMAT_PATTERN));
}
|
[
"public",
"String",
"getCreationTime",
"(",
")",
"{",
"if",
"(",
"mCreationTimeMs",
"==",
"UIFileInfo",
".",
"LocalFileInfo",
".",
"EMPTY_CREATION_TIME",
")",
"{",
"return",
"\"\"",
";",
"}",
"return",
"CommonUtils",
".",
"convertMsToDate",
"(",
"mCreationTimeMs",
",",
"mAlluxioConfiguration",
".",
"get",
"(",
"PropertyKey",
".",
"USER_DATE_FORMAT_PATTERN",
")",
")",
";",
"}"
] |
Gets creation time.
@return the creation time (in milliseconds)
|
[
"Gets",
"creation",
"time",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/webui/UIFileInfo.java#L240-L246
|
18,619
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/webui/UIFileInfo.java
|
UIFileInfo.getOnTierPercentages
|
public Map<String, Integer> getOnTierPercentages() {
return mOrderedTierAliases.stream().collect(Collectors.toMap(tier -> tier, tier -> {
Long sizeOnTier = mSizeOnTier.getOrDefault(tier, 0L);
return mSize > 0 ? (int) (100 * sizeOnTier / mSize) : 0;
}));
}
|
java
|
public Map<String, Integer> getOnTierPercentages() {
return mOrderedTierAliases.stream().collect(Collectors.toMap(tier -> tier, tier -> {
Long sizeOnTier = mSizeOnTier.getOrDefault(tier, 0L);
return mSize > 0 ? (int) (100 * sizeOnTier / mSize) : 0;
}));
}
|
[
"public",
"Map",
"<",
"String",
",",
"Integer",
">",
"getOnTierPercentages",
"(",
")",
"{",
"return",
"mOrderedTierAliases",
".",
"stream",
"(",
")",
".",
"collect",
"(",
"Collectors",
".",
"toMap",
"(",
"tier",
"->",
"tier",
",",
"tier",
"->",
"{",
"Long",
"sizeOnTier",
"=",
"mSizeOnTier",
".",
"getOrDefault",
"(",
"tier",
",",
"0L",
")",
";",
"return",
"mSize",
">",
"0",
"?",
"(",
"int",
")",
"(",
"100",
"*",
"sizeOnTier",
"/",
"mSize",
")",
":",
"0",
";",
"}",
")",
")",
";",
"}"
] |
Gets on-tier percentages.
@return the on-tier percentages
|
[
"Gets",
"on",
"-",
"tier",
"percentages",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/webui/UIFileInfo.java#L326-L331
|
18,620
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/command/ChgrpCommand.java
|
ChgrpCommand.chgrp
|
private void chgrp(AlluxioURI path, String group, boolean recursive)
throws AlluxioException, IOException {
SetAttributePOptions options =
SetAttributePOptions.newBuilder().setGroup(group).setRecursive(recursive).build();
mFileSystem.setAttribute(path, options);
System.out.println("Changed group of " + path + " to " + group);
}
|
java
|
private void chgrp(AlluxioURI path, String group, boolean recursive)
throws AlluxioException, IOException {
SetAttributePOptions options =
SetAttributePOptions.newBuilder().setGroup(group).setRecursive(recursive).build();
mFileSystem.setAttribute(path, options);
System.out.println("Changed group of " + path + " to " + group);
}
|
[
"private",
"void",
"chgrp",
"(",
"AlluxioURI",
"path",
",",
"String",
"group",
",",
"boolean",
"recursive",
")",
"throws",
"AlluxioException",
",",
"IOException",
"{",
"SetAttributePOptions",
"options",
"=",
"SetAttributePOptions",
".",
"newBuilder",
"(",
")",
".",
"setGroup",
"(",
"group",
")",
".",
"setRecursive",
"(",
"recursive",
")",
".",
"build",
"(",
")",
";",
"mFileSystem",
".",
"setAttribute",
"(",
"path",
",",
"options",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Changed group of \"",
"+",
"path",
"+",
"\" to \"",
"+",
"group",
")",
";",
"}"
] |
Changes the group for the directory or file with the path specified in args.
@param path The {@link AlluxioURI} path as the input of the command
@param group The group to be updated to the file or directory
@param recursive Whether change the group recursively
|
[
"Changes",
"the",
"group",
"for",
"the",
"directory",
"or",
"file",
"with",
"the",
"path",
"specified",
"in",
"args",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/command/ChgrpCommand.java#L74-L80
|
18,621
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockReader.java
|
UnderFileSystemBlockReader.transferTo
|
@Override
public int transferTo(ByteBuf buf) throws IOException {
Preconditions.checkState(!mClosed);
if (mUnderFileSystemInputStream == null) {
return -1;
}
if (mBlockMeta.getBlockSize() <= mInStreamPos) {
return -1;
}
// Make a copy of the state to keep track of what we have read in this transferTo call.
ByteBuf bufCopy = null;
if (mBlockWriter != null) {
bufCopy = buf.duplicate();
bufCopy.readerIndex(bufCopy.writerIndex());
}
int bytesToRead =
(int) Math.min(buf.writableBytes(), mBlockMeta.getBlockSize() - mInStreamPos);
int bytesRead = buf.writeBytes(mUnderFileSystemInputStream, bytesToRead);
if (bytesRead <= 0) {
return bytesRead;
}
mInStreamPos += bytesRead;
if (mBlockWriter != null && bufCopy != null) {
try {
bufCopy.writerIndex(buf.writerIndex());
while (bufCopy.readableBytes() > 0) {
mLocalBlockStore.requestSpace(mBlockMeta.getSessionId(), mBlockMeta.getBlockId(),
mInStreamPos - mBlockWriter.getPosition());
mBlockWriter.append(bufCopy);
}
} catch (Exception e) {
LOG.warn("Failed to cache data read from UFS (on transferTo()): {}", e.getMessage());
cancelBlockWriter();
}
}
return bytesRead;
}
|
java
|
@Override
public int transferTo(ByteBuf buf) throws IOException {
Preconditions.checkState(!mClosed);
if (mUnderFileSystemInputStream == null) {
return -1;
}
if (mBlockMeta.getBlockSize() <= mInStreamPos) {
return -1;
}
// Make a copy of the state to keep track of what we have read in this transferTo call.
ByteBuf bufCopy = null;
if (mBlockWriter != null) {
bufCopy = buf.duplicate();
bufCopy.readerIndex(bufCopy.writerIndex());
}
int bytesToRead =
(int) Math.min(buf.writableBytes(), mBlockMeta.getBlockSize() - mInStreamPos);
int bytesRead = buf.writeBytes(mUnderFileSystemInputStream, bytesToRead);
if (bytesRead <= 0) {
return bytesRead;
}
mInStreamPos += bytesRead;
if (mBlockWriter != null && bufCopy != null) {
try {
bufCopy.writerIndex(buf.writerIndex());
while (bufCopy.readableBytes() > 0) {
mLocalBlockStore.requestSpace(mBlockMeta.getSessionId(), mBlockMeta.getBlockId(),
mInStreamPos - mBlockWriter.getPosition());
mBlockWriter.append(bufCopy);
}
} catch (Exception e) {
LOG.warn("Failed to cache data read from UFS (on transferTo()): {}", e.getMessage());
cancelBlockWriter();
}
}
return bytesRead;
}
|
[
"@",
"Override",
"public",
"int",
"transferTo",
"(",
"ByteBuf",
"buf",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkState",
"(",
"!",
"mClosed",
")",
";",
"if",
"(",
"mUnderFileSystemInputStream",
"==",
"null",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"mBlockMeta",
".",
"getBlockSize",
"(",
")",
"<=",
"mInStreamPos",
")",
"{",
"return",
"-",
"1",
";",
"}",
"// Make a copy of the state to keep track of what we have read in this transferTo call.",
"ByteBuf",
"bufCopy",
"=",
"null",
";",
"if",
"(",
"mBlockWriter",
"!=",
"null",
")",
"{",
"bufCopy",
"=",
"buf",
".",
"duplicate",
"(",
")",
";",
"bufCopy",
".",
"readerIndex",
"(",
"bufCopy",
".",
"writerIndex",
"(",
")",
")",
";",
"}",
"int",
"bytesToRead",
"=",
"(",
"int",
")",
"Math",
".",
"min",
"(",
"buf",
".",
"writableBytes",
"(",
")",
",",
"mBlockMeta",
".",
"getBlockSize",
"(",
")",
"-",
"mInStreamPos",
")",
";",
"int",
"bytesRead",
"=",
"buf",
".",
"writeBytes",
"(",
"mUnderFileSystemInputStream",
",",
"bytesToRead",
")",
";",
"if",
"(",
"bytesRead",
"<=",
"0",
")",
"{",
"return",
"bytesRead",
";",
"}",
"mInStreamPos",
"+=",
"bytesRead",
";",
"if",
"(",
"mBlockWriter",
"!=",
"null",
"&&",
"bufCopy",
"!=",
"null",
")",
"{",
"try",
"{",
"bufCopy",
".",
"writerIndex",
"(",
"buf",
".",
"writerIndex",
"(",
")",
")",
";",
"while",
"(",
"bufCopy",
".",
"readableBytes",
"(",
")",
">",
"0",
")",
"{",
"mLocalBlockStore",
".",
"requestSpace",
"(",
"mBlockMeta",
".",
"getSessionId",
"(",
")",
",",
"mBlockMeta",
".",
"getBlockId",
"(",
")",
",",
"mInStreamPos",
"-",
"mBlockWriter",
".",
"getPosition",
"(",
")",
")",
";",
"mBlockWriter",
".",
"append",
"(",
"bufCopy",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to cache data read from UFS (on transferTo()): {}\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"cancelBlockWriter",
"(",
")",
";",
"}",
"}",
"return",
"bytesRead",
";",
"}"
] |
This interface is supposed to be used for sequence block reads.
@param buf the byte buffer
@return the number of bytes read, -1 if it reaches EOF and none was read
|
[
"This",
"interface",
"is",
"supposed",
"to",
"be",
"used",
"for",
"sequence",
"block",
"reads",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockReader.java#L206-L245
|
18,622
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockReader.java
|
UnderFileSystemBlockReader.close
|
@Override
public void close() throws IOException {
if (mClosed) {
return;
}
try {
// This aborts the block if the block is not fully read.
updateBlockWriter(mBlockMeta.getBlockSize());
if (mUnderFileSystemInputStream != null) {
mUfsInstreamManager.release(mUnderFileSystemInputStream);
mUnderFileSystemInputStream = null;
}
if (mBlockWriter != null) {
mBlockWriter.close();
}
mUfsResource.close();
} finally {
mClosed = true;
}
}
|
java
|
@Override
public void close() throws IOException {
if (mClosed) {
return;
}
try {
// This aborts the block if the block is not fully read.
updateBlockWriter(mBlockMeta.getBlockSize());
if (mUnderFileSystemInputStream != null) {
mUfsInstreamManager.release(mUnderFileSystemInputStream);
mUnderFileSystemInputStream = null;
}
if (mBlockWriter != null) {
mBlockWriter.close();
}
mUfsResource.close();
} finally {
mClosed = true;
}
}
|
[
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mClosed",
")",
"{",
"return",
";",
"}",
"try",
"{",
"// This aborts the block if the block is not fully read.",
"updateBlockWriter",
"(",
"mBlockMeta",
".",
"getBlockSize",
"(",
")",
")",
";",
"if",
"(",
"mUnderFileSystemInputStream",
"!=",
"null",
")",
"{",
"mUfsInstreamManager",
".",
"release",
"(",
"mUnderFileSystemInputStream",
")",
";",
"mUnderFileSystemInputStream",
"=",
"null",
";",
"}",
"if",
"(",
"mBlockWriter",
"!=",
"null",
")",
"{",
"mBlockWriter",
".",
"close",
"(",
")",
";",
"}",
"mUfsResource",
".",
"close",
"(",
")",
";",
"}",
"finally",
"{",
"mClosed",
"=",
"true",
";",
"}",
"}"
] |
Closes the block reader. After this, this block reader should not be used anymore.
This is recommended to be called after the client finishes reading the block. It is usually
triggered when the client unlocks the block.
|
[
"Closes",
"the",
"block",
"reader",
".",
"After",
"this",
"this",
"block",
"reader",
"should",
"not",
"be",
"used",
"anymore",
".",
"This",
"is",
"recommended",
"to",
"be",
"called",
"after",
"the",
"client",
"finishes",
"reading",
"the",
"block",
".",
"It",
"is",
"usually",
"triggered",
"when",
"the",
"client",
"unlocks",
"the",
"block",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockReader.java#L252-L275
|
18,623
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockReader.java
|
UnderFileSystemBlockReader.updateUnderFileSystemInputStream
|
private void updateUnderFileSystemInputStream(long offset) throws IOException {
if ((mUnderFileSystemInputStream != null) && offset != mInStreamPos) {
mUfsInstreamManager.release(mUnderFileSystemInputStream);
mUnderFileSystemInputStream = null;
mInStreamPos = -1;
}
if (mUnderFileSystemInputStream == null && offset < mBlockMeta.getBlockSize()) {
UnderFileSystem ufs = mUfsResource.get();
mUnderFileSystemInputStream = mUfsInstreamManager.acquire(ufs,
mBlockMeta.getUnderFileSystemPath(), IdUtils.fileIdFromBlockId(mBlockMeta.getBlockId()),
OpenOptions.defaults().setOffset(mBlockMeta.getOffset() + offset));
mInStreamPos = offset;
}
}
|
java
|
private void updateUnderFileSystemInputStream(long offset) throws IOException {
if ((mUnderFileSystemInputStream != null) && offset != mInStreamPos) {
mUfsInstreamManager.release(mUnderFileSystemInputStream);
mUnderFileSystemInputStream = null;
mInStreamPos = -1;
}
if (mUnderFileSystemInputStream == null && offset < mBlockMeta.getBlockSize()) {
UnderFileSystem ufs = mUfsResource.get();
mUnderFileSystemInputStream = mUfsInstreamManager.acquire(ufs,
mBlockMeta.getUnderFileSystemPath(), IdUtils.fileIdFromBlockId(mBlockMeta.getBlockId()),
OpenOptions.defaults().setOffset(mBlockMeta.getOffset() + offset));
mInStreamPos = offset;
}
}
|
[
"private",
"void",
"updateUnderFileSystemInputStream",
"(",
"long",
"offset",
")",
"throws",
"IOException",
"{",
"if",
"(",
"(",
"mUnderFileSystemInputStream",
"!=",
"null",
")",
"&&",
"offset",
"!=",
"mInStreamPos",
")",
"{",
"mUfsInstreamManager",
".",
"release",
"(",
"mUnderFileSystemInputStream",
")",
";",
"mUnderFileSystemInputStream",
"=",
"null",
";",
"mInStreamPos",
"=",
"-",
"1",
";",
"}",
"if",
"(",
"mUnderFileSystemInputStream",
"==",
"null",
"&&",
"offset",
"<",
"mBlockMeta",
".",
"getBlockSize",
"(",
")",
")",
"{",
"UnderFileSystem",
"ufs",
"=",
"mUfsResource",
".",
"get",
"(",
")",
";",
"mUnderFileSystemInputStream",
"=",
"mUfsInstreamManager",
".",
"acquire",
"(",
"ufs",
",",
"mBlockMeta",
".",
"getUnderFileSystemPath",
"(",
")",
",",
"IdUtils",
".",
"fileIdFromBlockId",
"(",
"mBlockMeta",
".",
"getBlockId",
"(",
")",
")",
",",
"OpenOptions",
".",
"defaults",
"(",
")",
".",
"setOffset",
"(",
"mBlockMeta",
".",
"getOffset",
"(",
")",
"+",
"offset",
")",
")",
";",
"mInStreamPos",
"=",
"offset",
";",
"}",
"}"
] |
Updates the UFS input stream given an offset to read.
@param offset the read offset within the block
|
[
"Updates",
"the",
"UFS",
"input",
"stream",
"given",
"an",
"offset",
"to",
"read",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockReader.java#L294-L308
|
18,624
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockReader.java
|
UnderFileSystemBlockReader.cancelBlockWriter
|
private void cancelBlockWriter() throws IOException {
if (mBlockWriter == null) {
return;
}
try {
mBlockWriter.close();
mBlockWriter = null;
mLocalBlockStore.abortBlock(mBlockMeta.getSessionId(), mBlockMeta.getBlockId());
} catch (BlockDoesNotExistException e) {
// This can only happen when the session is expired.
LOG.warn("Block {} does not exist when being aborted. The session may have expired.",
mBlockMeta.getBlockId());
} catch (BlockAlreadyExistsException | InvalidWorkerStateException | IOException e) {
// We cannot skip the exception here because we need to make sure that the user of this
// reader does not commit the block if it fails to abort the block.
throw AlluxioStatusException.fromCheckedException(e);
}
}
|
java
|
private void cancelBlockWriter() throws IOException {
if (mBlockWriter == null) {
return;
}
try {
mBlockWriter.close();
mBlockWriter = null;
mLocalBlockStore.abortBlock(mBlockMeta.getSessionId(), mBlockMeta.getBlockId());
} catch (BlockDoesNotExistException e) {
// This can only happen when the session is expired.
LOG.warn("Block {} does not exist when being aborted. The session may have expired.",
mBlockMeta.getBlockId());
} catch (BlockAlreadyExistsException | InvalidWorkerStateException | IOException e) {
// We cannot skip the exception here because we need to make sure that the user of this
// reader does not commit the block if it fails to abort the block.
throw AlluxioStatusException.fromCheckedException(e);
}
}
|
[
"private",
"void",
"cancelBlockWriter",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mBlockWriter",
"==",
"null",
")",
"{",
"return",
";",
"}",
"try",
"{",
"mBlockWriter",
".",
"close",
"(",
")",
";",
"mBlockWriter",
"=",
"null",
";",
"mLocalBlockStore",
".",
"abortBlock",
"(",
"mBlockMeta",
".",
"getSessionId",
"(",
")",
",",
"mBlockMeta",
".",
"getBlockId",
"(",
")",
")",
";",
"}",
"catch",
"(",
"BlockDoesNotExistException",
"e",
")",
"{",
"// This can only happen when the session is expired.",
"LOG",
".",
"warn",
"(",
"\"Block {} does not exist when being aborted. The session may have expired.\"",
",",
"mBlockMeta",
".",
"getBlockId",
"(",
")",
")",
";",
"}",
"catch",
"(",
"BlockAlreadyExistsException",
"|",
"InvalidWorkerStateException",
"|",
"IOException",
"e",
")",
"{",
"// We cannot skip the exception here because we need to make sure that the user of this",
"// reader does not commit the block if it fails to abort the block.",
"throw",
"AlluxioStatusException",
".",
"fromCheckedException",
"(",
"e",
")",
";",
"}",
"}"
] |
Closes the current block writer, cleans up its temp block and sets it to null.
|
[
"Closes",
"the",
"current",
"block",
"writer",
"cleans",
"up",
"its",
"temp",
"block",
"and",
"sets",
"it",
"to",
"null",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockReader.java#L313-L330
|
18,625
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockReader.java
|
UnderFileSystemBlockReader.updateBlockWriter
|
private void updateBlockWriter(long offset) throws IOException {
if (mBlockWriter != null && offset > mBlockWriter.getPosition()) {
cancelBlockWriter();
}
try {
if (mBlockWriter == null && offset == 0 && !mBlockMeta.isNoCache()) {
BlockStoreLocation loc = BlockStoreLocation.anyDirInTier(mStorageTierAssoc.getAlias(0));
mLocalBlockStore.createBlock(mBlockMeta.getSessionId(), mBlockMeta.getBlockId(), loc,
mInitialBlockSize);
mBlockWriter = mLocalBlockStore.getBlockWriter(
mBlockMeta.getSessionId(), mBlockMeta.getBlockId());
}
} catch (BlockAlreadyExistsException e) {
// This can happen when there are concurrent UFS readers who are all trying to cache to block.
LOG.debug(
"Failed to update block writer for UFS block [blockId: {}, ufsPath: {}, offset: {}]."
+ "Concurrent UFS readers may be caching the same block.",
mBlockMeta.getBlockId(), mBlockMeta.getUnderFileSystemPath(), offset, e);
mBlockWriter = null;
} catch (IOException | AlluxioException e) {
LOG.warn(
"Failed to update block writer for UFS block [blockId: {}, ufsPath: {}, offset: {}]: {}",
mBlockMeta.getBlockId(), mBlockMeta.getUnderFileSystemPath(), offset, e.getMessage());
mBlockWriter = null;
}
}
|
java
|
private void updateBlockWriter(long offset) throws IOException {
if (mBlockWriter != null && offset > mBlockWriter.getPosition()) {
cancelBlockWriter();
}
try {
if (mBlockWriter == null && offset == 0 && !mBlockMeta.isNoCache()) {
BlockStoreLocation loc = BlockStoreLocation.anyDirInTier(mStorageTierAssoc.getAlias(0));
mLocalBlockStore.createBlock(mBlockMeta.getSessionId(), mBlockMeta.getBlockId(), loc,
mInitialBlockSize);
mBlockWriter = mLocalBlockStore.getBlockWriter(
mBlockMeta.getSessionId(), mBlockMeta.getBlockId());
}
} catch (BlockAlreadyExistsException e) {
// This can happen when there are concurrent UFS readers who are all trying to cache to block.
LOG.debug(
"Failed to update block writer for UFS block [blockId: {}, ufsPath: {}, offset: {}]."
+ "Concurrent UFS readers may be caching the same block.",
mBlockMeta.getBlockId(), mBlockMeta.getUnderFileSystemPath(), offset, e);
mBlockWriter = null;
} catch (IOException | AlluxioException e) {
LOG.warn(
"Failed to update block writer for UFS block [blockId: {}, ufsPath: {}, offset: {}]: {}",
mBlockMeta.getBlockId(), mBlockMeta.getUnderFileSystemPath(), offset, e.getMessage());
mBlockWriter = null;
}
}
|
[
"private",
"void",
"updateBlockWriter",
"(",
"long",
"offset",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mBlockWriter",
"!=",
"null",
"&&",
"offset",
">",
"mBlockWriter",
".",
"getPosition",
"(",
")",
")",
"{",
"cancelBlockWriter",
"(",
")",
";",
"}",
"try",
"{",
"if",
"(",
"mBlockWriter",
"==",
"null",
"&&",
"offset",
"==",
"0",
"&&",
"!",
"mBlockMeta",
".",
"isNoCache",
"(",
")",
")",
"{",
"BlockStoreLocation",
"loc",
"=",
"BlockStoreLocation",
".",
"anyDirInTier",
"(",
"mStorageTierAssoc",
".",
"getAlias",
"(",
"0",
")",
")",
";",
"mLocalBlockStore",
".",
"createBlock",
"(",
"mBlockMeta",
".",
"getSessionId",
"(",
")",
",",
"mBlockMeta",
".",
"getBlockId",
"(",
")",
",",
"loc",
",",
"mInitialBlockSize",
")",
";",
"mBlockWriter",
"=",
"mLocalBlockStore",
".",
"getBlockWriter",
"(",
"mBlockMeta",
".",
"getSessionId",
"(",
")",
",",
"mBlockMeta",
".",
"getBlockId",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"BlockAlreadyExistsException",
"e",
")",
"{",
"// This can happen when there are concurrent UFS readers who are all trying to cache to block.",
"LOG",
".",
"debug",
"(",
"\"Failed to update block writer for UFS block [blockId: {}, ufsPath: {}, offset: {}].\"",
"+",
"\"Concurrent UFS readers may be caching the same block.\"",
",",
"mBlockMeta",
".",
"getBlockId",
"(",
")",
",",
"mBlockMeta",
".",
"getUnderFileSystemPath",
"(",
")",
",",
"offset",
",",
"e",
")",
";",
"mBlockWriter",
"=",
"null",
";",
"}",
"catch",
"(",
"IOException",
"|",
"AlluxioException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to update block writer for UFS block [blockId: {}, ufsPath: {}, offset: {}]: {}\"",
",",
"mBlockMeta",
".",
"getBlockId",
"(",
")",
",",
"mBlockMeta",
".",
"getUnderFileSystemPath",
"(",
")",
",",
"offset",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"mBlockWriter",
"=",
"null",
";",
"}",
"}"
] |
Updates the block writer given an offset to read. If the offset is beyond the current
position of the block writer, the block writer will be aborted.
@param offset the read offset
|
[
"Updates",
"the",
"block",
"writer",
"given",
"an",
"offset",
"to",
"read",
".",
"If",
"the",
"offset",
"is",
"beyond",
"the",
"current",
"position",
"of",
"the",
"block",
"writer",
"the",
"block",
"writer",
"will",
"be",
"aborted",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockReader.java#L338-L363
|
18,626
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/command/AbstractFileSystemCommand.java
|
AbstractFileSystemCommand.runWildCardCmd
|
protected void runWildCardCmd(AlluxioURI wildCardPath, CommandLine cl) throws IOException {
List<AlluxioURI> paths = FileSystemShellUtils.getAlluxioURIs(mFileSystem, wildCardPath);
if (paths.size() == 0) { // A unified sanity check on the paths
throw new IOException(wildCardPath + " does not exist.");
}
paths.sort(Comparator.comparing(AlluxioURI::getPath));
// TODO(lu) if errors occur in runPlainPath, we may not want to print header
processHeader(cl);
List<String> errorMessages = new ArrayList<>();
for (AlluxioURI path : paths) {
try {
runPlainPath(path, cl);
} catch (AlluxioException | IOException e) {
errorMessages.add(e.getMessage() != null ? e.getMessage() : e.toString());
}
}
if (errorMessages.size() != 0) {
throw new IOException(Joiner.on('\n').join(errorMessages));
}
}
|
java
|
protected void runWildCardCmd(AlluxioURI wildCardPath, CommandLine cl) throws IOException {
List<AlluxioURI> paths = FileSystemShellUtils.getAlluxioURIs(mFileSystem, wildCardPath);
if (paths.size() == 0) { // A unified sanity check on the paths
throw new IOException(wildCardPath + " does not exist.");
}
paths.sort(Comparator.comparing(AlluxioURI::getPath));
// TODO(lu) if errors occur in runPlainPath, we may not want to print header
processHeader(cl);
List<String> errorMessages = new ArrayList<>();
for (AlluxioURI path : paths) {
try {
runPlainPath(path, cl);
} catch (AlluxioException | IOException e) {
errorMessages.add(e.getMessage() != null ? e.getMessage() : e.toString());
}
}
if (errorMessages.size() != 0) {
throw new IOException(Joiner.on('\n').join(errorMessages));
}
}
|
[
"protected",
"void",
"runWildCardCmd",
"(",
"AlluxioURI",
"wildCardPath",
",",
"CommandLine",
"cl",
")",
"throws",
"IOException",
"{",
"List",
"<",
"AlluxioURI",
">",
"paths",
"=",
"FileSystemShellUtils",
".",
"getAlluxioURIs",
"(",
"mFileSystem",
",",
"wildCardPath",
")",
";",
"if",
"(",
"paths",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"// A unified sanity check on the paths",
"throw",
"new",
"IOException",
"(",
"wildCardPath",
"+",
"\" does not exist.\"",
")",
";",
"}",
"paths",
".",
"sort",
"(",
"Comparator",
".",
"comparing",
"(",
"AlluxioURI",
"::",
"getPath",
")",
")",
";",
"// TODO(lu) if errors occur in runPlainPath, we may not want to print header",
"processHeader",
"(",
"cl",
")",
";",
"List",
"<",
"String",
">",
"errorMessages",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"AlluxioURI",
"path",
":",
"paths",
")",
"{",
"try",
"{",
"runPlainPath",
"(",
"path",
",",
"cl",
")",
";",
"}",
"catch",
"(",
"AlluxioException",
"|",
"IOException",
"e",
")",
"{",
"errorMessages",
".",
"add",
"(",
"e",
".",
"getMessage",
"(",
")",
"!=",
"null",
"?",
"e",
".",
"getMessage",
"(",
")",
":",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"errorMessages",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"throw",
"new",
"IOException",
"(",
"Joiner",
".",
"on",
"(",
"'",
"'",
")",
".",
"join",
"(",
"errorMessages",
")",
")",
";",
"}",
"}"
] |
Runs the command for a particular URI that may contain wildcard in its path.
@param wildCardPath an AlluxioURI that may or may not contain a wildcard
@param cl object containing the original commandLine
|
[
"Runs",
"the",
"command",
"for",
"a",
"particular",
"URI",
"that",
"may",
"contain",
"wildcard",
"in",
"its",
"path",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/command/AbstractFileSystemCommand.java#L79-L101
|
18,627
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/grpc/GrpcServer.java
|
GrpcServer.start
|
public GrpcServer start() throws IOException {
RetryUtils.retry("Starting gRPC server", () -> mServer.start(),
new ExponentialBackoffRetry(100, 500, 5));
mStarted = true;
return this;
}
|
java
|
public GrpcServer start() throws IOException {
RetryUtils.retry("Starting gRPC server", () -> mServer.start(),
new ExponentialBackoffRetry(100, 500, 5));
mStarted = true;
return this;
}
|
[
"public",
"GrpcServer",
"start",
"(",
")",
"throws",
"IOException",
"{",
"RetryUtils",
".",
"retry",
"(",
"\"Starting gRPC server\"",
",",
"(",
")",
"->",
"mServer",
".",
"start",
"(",
")",
",",
"new",
"ExponentialBackoffRetry",
"(",
"100",
",",
"500",
",",
"5",
")",
")",
";",
"mStarted",
"=",
"true",
";",
"return",
"this",
";",
"}"
] |
Start serving.
@return this instance of {@link GrpcServer}
@throws IOException when unable to start serving
|
[
"Start",
"serving",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/grpc/GrpcServer.java#L50-L55
|
18,628
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/block/DefaultBlockMaster.java
|
DefaultBlockMaster.registerWorkerInternal
|
@Nullable
private MasterWorkerInfo registerWorkerInternal(long workerId) {
for (IndexedSet<MasterWorkerInfo> workers: Arrays.asList(mTempWorkers, mLostWorkers)) {
MasterWorkerInfo worker = workers.getFirstByField(ID_INDEX, workerId);
if (worker == null) {
continue;
}
synchronized (worker) {
worker.updateLastUpdatedTimeMs();
mWorkers.add(worker);
workers.remove(worker);
if (workers == mLostWorkers) {
for (Consumer<Address> function : mLostWorkerFoundListeners) {
function.accept(new Address(worker.getWorkerAddress().getHost(),
worker.getWorkerAddress().getRpcPort()));
}
LOG.warn("A lost worker {} has requested its old id {}.",
worker.getWorkerAddress(), worker.getId());
}
}
return worker;
}
return null;
}
|
java
|
@Nullable
private MasterWorkerInfo registerWorkerInternal(long workerId) {
for (IndexedSet<MasterWorkerInfo> workers: Arrays.asList(mTempWorkers, mLostWorkers)) {
MasterWorkerInfo worker = workers.getFirstByField(ID_INDEX, workerId);
if (worker == null) {
continue;
}
synchronized (worker) {
worker.updateLastUpdatedTimeMs();
mWorkers.add(worker);
workers.remove(worker);
if (workers == mLostWorkers) {
for (Consumer<Address> function : mLostWorkerFoundListeners) {
function.accept(new Address(worker.getWorkerAddress().getHost(),
worker.getWorkerAddress().getRpcPort()));
}
LOG.warn("A lost worker {} has requested its old id {}.",
worker.getWorkerAddress(), worker.getId());
}
}
return worker;
}
return null;
}
|
[
"@",
"Nullable",
"private",
"MasterWorkerInfo",
"registerWorkerInternal",
"(",
"long",
"workerId",
")",
"{",
"for",
"(",
"IndexedSet",
"<",
"MasterWorkerInfo",
">",
"workers",
":",
"Arrays",
".",
"asList",
"(",
"mTempWorkers",
",",
"mLostWorkers",
")",
")",
"{",
"MasterWorkerInfo",
"worker",
"=",
"workers",
".",
"getFirstByField",
"(",
"ID_INDEX",
",",
"workerId",
")",
";",
"if",
"(",
"worker",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"synchronized",
"(",
"worker",
")",
"{",
"worker",
".",
"updateLastUpdatedTimeMs",
"(",
")",
";",
"mWorkers",
".",
"add",
"(",
"worker",
")",
";",
"workers",
".",
"remove",
"(",
"worker",
")",
";",
"if",
"(",
"workers",
"==",
"mLostWorkers",
")",
"{",
"for",
"(",
"Consumer",
"<",
"Address",
">",
"function",
":",
"mLostWorkerFoundListeners",
")",
"{",
"function",
".",
"accept",
"(",
"new",
"Address",
"(",
"worker",
".",
"getWorkerAddress",
"(",
")",
".",
"getHost",
"(",
")",
",",
"worker",
".",
"getWorkerAddress",
"(",
")",
".",
"getRpcPort",
"(",
")",
")",
")",
";",
"}",
"LOG",
".",
"warn",
"(",
"\"A lost worker {} has requested its old id {}.\"",
",",
"worker",
".",
"getWorkerAddress",
"(",
")",
",",
"worker",
".",
"getId",
"(",
")",
")",
";",
"}",
"}",
"return",
"worker",
";",
"}",
"return",
"null",
";",
"}"
] |
Re-register a lost worker or complete registration after getting a worker id.
@param workerId the worker id to register
|
[
"Re",
"-",
"register",
"a",
"lost",
"worker",
"or",
"complete",
"registration",
"after",
"getting",
"a",
"worker",
"id",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/block/DefaultBlockMaster.java#L754-L779
|
18,629
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/block/DefaultBlockMaster.java
|
DefaultBlockMaster.processWorkerRemovedBlocks
|
@GuardedBy("workerInfo")
private void processWorkerRemovedBlocks(MasterWorkerInfo workerInfo,
Collection<Long> removedBlockIds) {
for (long removedBlockId : removedBlockIds) {
try (LockResource lr = lockBlock(removedBlockId)) {
Optional<BlockMeta> block = mBlockStore.getBlock(removedBlockId);
if (block.isPresent()) {
LOG.info("Block {} is removed on worker {}.", removedBlockId, workerInfo.getId());
mBlockStore.removeLocation(removedBlockId, workerInfo.getId());
if (mBlockStore.getLocations(removedBlockId).size() == 0) {
mLostBlocks.add(removedBlockId);
}
}
// Remove the block even if its metadata has been deleted already.
workerInfo.removeBlock(removedBlockId);
}
}
}
|
java
|
@GuardedBy("workerInfo")
private void processWorkerRemovedBlocks(MasterWorkerInfo workerInfo,
Collection<Long> removedBlockIds) {
for (long removedBlockId : removedBlockIds) {
try (LockResource lr = lockBlock(removedBlockId)) {
Optional<BlockMeta> block = mBlockStore.getBlock(removedBlockId);
if (block.isPresent()) {
LOG.info("Block {} is removed on worker {}.", removedBlockId, workerInfo.getId());
mBlockStore.removeLocation(removedBlockId, workerInfo.getId());
if (mBlockStore.getLocations(removedBlockId).size() == 0) {
mLostBlocks.add(removedBlockId);
}
}
// Remove the block even if its metadata has been deleted already.
workerInfo.removeBlock(removedBlockId);
}
}
}
|
[
"@",
"GuardedBy",
"(",
"\"workerInfo\"",
")",
"private",
"void",
"processWorkerRemovedBlocks",
"(",
"MasterWorkerInfo",
"workerInfo",
",",
"Collection",
"<",
"Long",
">",
"removedBlockIds",
")",
"{",
"for",
"(",
"long",
"removedBlockId",
":",
"removedBlockIds",
")",
"{",
"try",
"(",
"LockResource",
"lr",
"=",
"lockBlock",
"(",
"removedBlockId",
")",
")",
"{",
"Optional",
"<",
"BlockMeta",
">",
"block",
"=",
"mBlockStore",
".",
"getBlock",
"(",
"removedBlockId",
")",
";",
"if",
"(",
"block",
".",
"isPresent",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Block {} is removed on worker {}.\"",
",",
"removedBlockId",
",",
"workerInfo",
".",
"getId",
"(",
")",
")",
";",
"mBlockStore",
".",
"removeLocation",
"(",
"removedBlockId",
",",
"workerInfo",
".",
"getId",
"(",
")",
")",
";",
"if",
"(",
"mBlockStore",
".",
"getLocations",
"(",
"removedBlockId",
")",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"mLostBlocks",
".",
"add",
"(",
"removedBlockId",
")",
";",
"}",
"}",
"// Remove the block even if its metadata has been deleted already.",
"workerInfo",
".",
"removeBlock",
"(",
"removedBlockId",
")",
";",
"}",
"}",
"}"
] |
Updates the worker and block metadata for blocks removed from a worker.
@param workerInfo The worker metadata object
@param removedBlockIds A list of block ids removed from the worker
|
[
"Updates",
"the",
"worker",
"and",
"block",
"metadata",
"for",
"blocks",
"removed",
"from",
"a",
"worker",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/block/DefaultBlockMaster.java#L901-L918
|
18,630
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/block/DefaultBlockMaster.java
|
DefaultBlockMaster.processWorkerAddedBlocks
|
@GuardedBy("workerInfo")
private void processWorkerAddedBlocks(MasterWorkerInfo workerInfo,
Map<String, List<Long>> addedBlockIds) {
for (Map.Entry<String, List<Long>> entry : addedBlockIds.entrySet()) {
for (long blockId : entry.getValue()) {
try (LockResource lr = lockBlock(blockId)) {
Optional<BlockMeta> block = mBlockStore.getBlock(blockId);
if (block.isPresent()) {
workerInfo.addBlock(blockId);
mBlockStore.addLocation(blockId, BlockLocation.newBuilder()
.setWorkerId(workerInfo.getId())
.setTier(entry.getKey())
.build());
mLostBlocks.remove(blockId);
} else {
LOG.warn("Invalid block: {} from worker {}.", blockId,
workerInfo.getWorkerAddress().getHost());
}
}
}
}
}
|
java
|
@GuardedBy("workerInfo")
private void processWorkerAddedBlocks(MasterWorkerInfo workerInfo,
Map<String, List<Long>> addedBlockIds) {
for (Map.Entry<String, List<Long>> entry : addedBlockIds.entrySet()) {
for (long blockId : entry.getValue()) {
try (LockResource lr = lockBlock(blockId)) {
Optional<BlockMeta> block = mBlockStore.getBlock(blockId);
if (block.isPresent()) {
workerInfo.addBlock(blockId);
mBlockStore.addLocation(blockId, BlockLocation.newBuilder()
.setWorkerId(workerInfo.getId())
.setTier(entry.getKey())
.build());
mLostBlocks.remove(blockId);
} else {
LOG.warn("Invalid block: {} from worker {}.", blockId,
workerInfo.getWorkerAddress().getHost());
}
}
}
}
}
|
[
"@",
"GuardedBy",
"(",
"\"workerInfo\"",
")",
"private",
"void",
"processWorkerAddedBlocks",
"(",
"MasterWorkerInfo",
"workerInfo",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"Long",
">",
">",
"addedBlockIds",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"List",
"<",
"Long",
">",
">",
"entry",
":",
"addedBlockIds",
".",
"entrySet",
"(",
")",
")",
"{",
"for",
"(",
"long",
"blockId",
":",
"entry",
".",
"getValue",
"(",
")",
")",
"{",
"try",
"(",
"LockResource",
"lr",
"=",
"lockBlock",
"(",
"blockId",
")",
")",
"{",
"Optional",
"<",
"BlockMeta",
">",
"block",
"=",
"mBlockStore",
".",
"getBlock",
"(",
"blockId",
")",
";",
"if",
"(",
"block",
".",
"isPresent",
"(",
")",
")",
"{",
"workerInfo",
".",
"addBlock",
"(",
"blockId",
")",
";",
"mBlockStore",
".",
"addLocation",
"(",
"blockId",
",",
"BlockLocation",
".",
"newBuilder",
"(",
")",
".",
"setWorkerId",
"(",
"workerInfo",
".",
"getId",
"(",
")",
")",
".",
"setTier",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
".",
"build",
"(",
")",
")",
";",
"mLostBlocks",
".",
"remove",
"(",
"blockId",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"warn",
"(",
"\"Invalid block: {} from worker {}.\"",
",",
"blockId",
",",
"workerInfo",
".",
"getWorkerAddress",
"(",
")",
".",
"getHost",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Updates the worker and block metadata for blocks added to a worker.
@param workerInfo The worker metadata object
@param addedBlockIds A mapping from storage tier alias to a list of block ids added
|
[
"Updates",
"the",
"worker",
"and",
"block",
"metadata",
"for",
"blocks",
"added",
"to",
"a",
"worker",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/block/DefaultBlockMaster.java#L926-L947
|
18,631
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/block/DefaultBlockMaster.java
|
DefaultBlockMaster.generateBlockInfo
|
@GuardedBy("masterBlockInfo")
private Optional<BlockInfo> generateBlockInfo(long blockId) throws UnavailableException {
if (mSafeModeManager.isInSafeMode()) {
throw new UnavailableException(ExceptionMessage.MASTER_IN_SAFEMODE.getMessage());
}
BlockMeta block;
List<BlockLocation> blockLocations;
try (LockResource lr = lockBlock(blockId)) {
Optional<BlockMeta> blockOpt = mBlockStore.getBlock(blockId);
if (!blockOpt.isPresent()) {
return Optional.empty();
}
block = blockOpt.get();
blockLocations = new ArrayList<>(mBlockStore.getLocations(blockId));
}
// Sort the block locations by their alias ordinal in the master storage tier mapping
Collections.sort(blockLocations,
Comparator.comparingInt(o -> mGlobalStorageTierAssoc.getOrdinal(o.getTier())));
List<alluxio.wire.BlockLocation> locations = new ArrayList<>();
for (BlockLocation location : blockLocations) {
MasterWorkerInfo workerInfo =
mWorkers.getFirstByField(ID_INDEX, location.getWorkerId());
if (workerInfo != null) {
// worker metadata is intentionally not locked here because:
// - it would be an incorrect order (correct order is lock worker first, then block)
// - only uses getters of final variables
locations.add(new alluxio.wire.BlockLocation().setWorkerId(location.getWorkerId())
.setWorkerAddress(workerInfo.getWorkerAddress())
.setTierAlias(location.getTier()));
}
}
return Optional.of(
new BlockInfo().setBlockId(blockId).setLength(block.getLength()).setLocations(locations));
}
|
java
|
@GuardedBy("masterBlockInfo")
private Optional<BlockInfo> generateBlockInfo(long blockId) throws UnavailableException {
if (mSafeModeManager.isInSafeMode()) {
throw new UnavailableException(ExceptionMessage.MASTER_IN_SAFEMODE.getMessage());
}
BlockMeta block;
List<BlockLocation> blockLocations;
try (LockResource lr = lockBlock(blockId)) {
Optional<BlockMeta> blockOpt = mBlockStore.getBlock(blockId);
if (!blockOpt.isPresent()) {
return Optional.empty();
}
block = blockOpt.get();
blockLocations = new ArrayList<>(mBlockStore.getLocations(blockId));
}
// Sort the block locations by their alias ordinal in the master storage tier mapping
Collections.sort(blockLocations,
Comparator.comparingInt(o -> mGlobalStorageTierAssoc.getOrdinal(o.getTier())));
List<alluxio.wire.BlockLocation> locations = new ArrayList<>();
for (BlockLocation location : blockLocations) {
MasterWorkerInfo workerInfo =
mWorkers.getFirstByField(ID_INDEX, location.getWorkerId());
if (workerInfo != null) {
// worker metadata is intentionally not locked here because:
// - it would be an incorrect order (correct order is lock worker first, then block)
// - only uses getters of final variables
locations.add(new alluxio.wire.BlockLocation().setWorkerId(location.getWorkerId())
.setWorkerAddress(workerInfo.getWorkerAddress())
.setTierAlias(location.getTier()));
}
}
return Optional.of(
new BlockInfo().setBlockId(blockId).setLength(block.getLength()).setLocations(locations));
}
|
[
"@",
"GuardedBy",
"(",
"\"masterBlockInfo\"",
")",
"private",
"Optional",
"<",
"BlockInfo",
">",
"generateBlockInfo",
"(",
"long",
"blockId",
")",
"throws",
"UnavailableException",
"{",
"if",
"(",
"mSafeModeManager",
".",
"isInSafeMode",
"(",
")",
")",
"{",
"throw",
"new",
"UnavailableException",
"(",
"ExceptionMessage",
".",
"MASTER_IN_SAFEMODE",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"BlockMeta",
"block",
";",
"List",
"<",
"BlockLocation",
">",
"blockLocations",
";",
"try",
"(",
"LockResource",
"lr",
"=",
"lockBlock",
"(",
"blockId",
")",
")",
"{",
"Optional",
"<",
"BlockMeta",
">",
"blockOpt",
"=",
"mBlockStore",
".",
"getBlock",
"(",
"blockId",
")",
";",
"if",
"(",
"!",
"blockOpt",
".",
"isPresent",
"(",
")",
")",
"{",
"return",
"Optional",
".",
"empty",
"(",
")",
";",
"}",
"block",
"=",
"blockOpt",
".",
"get",
"(",
")",
";",
"blockLocations",
"=",
"new",
"ArrayList",
"<>",
"(",
"mBlockStore",
".",
"getLocations",
"(",
"blockId",
")",
")",
";",
"}",
"// Sort the block locations by their alias ordinal in the master storage tier mapping",
"Collections",
".",
"sort",
"(",
"blockLocations",
",",
"Comparator",
".",
"comparingInt",
"(",
"o",
"->",
"mGlobalStorageTierAssoc",
".",
"getOrdinal",
"(",
"o",
".",
"getTier",
"(",
")",
")",
")",
")",
";",
"List",
"<",
"alluxio",
".",
"wire",
".",
"BlockLocation",
">",
"locations",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"BlockLocation",
"location",
":",
"blockLocations",
")",
"{",
"MasterWorkerInfo",
"workerInfo",
"=",
"mWorkers",
".",
"getFirstByField",
"(",
"ID_INDEX",
",",
"location",
".",
"getWorkerId",
"(",
")",
")",
";",
"if",
"(",
"workerInfo",
"!=",
"null",
")",
"{",
"// worker metadata is intentionally not locked here because:",
"// - it would be an incorrect order (correct order is lock worker first, then block)",
"// - only uses getters of final variables",
"locations",
".",
"add",
"(",
"new",
"alluxio",
".",
"wire",
".",
"BlockLocation",
"(",
")",
".",
"setWorkerId",
"(",
"location",
".",
"getWorkerId",
"(",
")",
")",
".",
"setWorkerAddress",
"(",
"workerInfo",
".",
"getWorkerAddress",
"(",
")",
")",
".",
"setTierAlias",
"(",
"location",
".",
"getTier",
"(",
")",
")",
")",
";",
"}",
"}",
"return",
"Optional",
".",
"of",
"(",
"new",
"BlockInfo",
"(",
")",
".",
"setBlockId",
"(",
"blockId",
")",
".",
"setLength",
"(",
"block",
".",
"getLength",
"(",
")",
")",
".",
"setLocations",
"(",
"locations",
")",
")",
";",
"}"
] |
Generates block info, including worker locations, for a block id.
@param blockId a block id
@return optional block info, empty if the block does not exist
|
[
"Generates",
"block",
"info",
"including",
"worker",
"locations",
"for",
"a",
"block",
"id",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/block/DefaultBlockMaster.java#L971-L1007
|
18,632
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/block/DefaultBlockMaster.java
|
DefaultBlockMaster.selectInfoByAddress
|
private Set<MasterWorkerInfo> selectInfoByAddress(Set<String> addresses,
Set<MasterWorkerInfo> workerInfoSet, Set<String> workerNames) {
return workerInfoSet.stream().filter(info -> {
String host = info.getWorkerAddress().getHost();
workerNames.add(host);
String ip = null;
try {
ip = NetworkAddressUtils.resolveIpAddress(host);
workerNames.add(ip);
} catch (UnknownHostException e) {
// The host may already be an IP address
}
if (addresses.contains(host)) {
addresses.remove(host);
return true;
}
if (ip != null) {
if (addresses.contains(ip)) {
addresses.remove(ip);
return true;
}
}
return false;
}).collect(Collectors.toSet());
}
|
java
|
private Set<MasterWorkerInfo> selectInfoByAddress(Set<String> addresses,
Set<MasterWorkerInfo> workerInfoSet, Set<String> workerNames) {
return workerInfoSet.stream().filter(info -> {
String host = info.getWorkerAddress().getHost();
workerNames.add(host);
String ip = null;
try {
ip = NetworkAddressUtils.resolveIpAddress(host);
workerNames.add(ip);
} catch (UnknownHostException e) {
// The host may already be an IP address
}
if (addresses.contains(host)) {
addresses.remove(host);
return true;
}
if (ip != null) {
if (addresses.contains(ip)) {
addresses.remove(ip);
return true;
}
}
return false;
}).collect(Collectors.toSet());
}
|
[
"private",
"Set",
"<",
"MasterWorkerInfo",
">",
"selectInfoByAddress",
"(",
"Set",
"<",
"String",
">",
"addresses",
",",
"Set",
"<",
"MasterWorkerInfo",
">",
"workerInfoSet",
",",
"Set",
"<",
"String",
">",
"workerNames",
")",
"{",
"return",
"workerInfoSet",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"info",
"->",
"{",
"String",
"host",
"=",
"info",
".",
"getWorkerAddress",
"(",
")",
".",
"getHost",
"(",
")",
";",
"workerNames",
".",
"add",
"(",
"host",
")",
";",
"String",
"ip",
"=",
"null",
";",
"try",
"{",
"ip",
"=",
"NetworkAddressUtils",
".",
"resolveIpAddress",
"(",
"host",
")",
";",
"workerNames",
".",
"add",
"(",
"ip",
")",
";",
"}",
"catch",
"(",
"UnknownHostException",
"e",
")",
"{",
"// The host may already be an IP address",
"}",
"if",
"(",
"addresses",
".",
"contains",
"(",
"host",
")",
")",
"{",
"addresses",
".",
"remove",
"(",
"host",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"ip",
"!=",
"null",
")",
"{",
"if",
"(",
"addresses",
".",
"contains",
"(",
"ip",
")",
")",
"{",
"addresses",
".",
"remove",
"(",
"ip",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
")",
".",
"collect",
"(",
"Collectors",
".",
"toSet",
"(",
")",
")",
";",
"}"
] |
Selects the MasterWorkerInfo from workerInfoSet whose host or related IP address
exists in addresses.
@param addresses the address set that user passed in
@param workerInfoSet the MasterWorkerInfo set to select info from
@param workerNames the supported worker names
|
[
"Selects",
"the",
"MasterWorkerInfo",
"from",
"workerInfoSet",
"whose",
"host",
"or",
"related",
"IP",
"address",
"exists",
"in",
"addresses",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/block/DefaultBlockMaster.java#L1068-L1095
|
18,633
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java
|
AbstractWriteHandler.write
|
public void write(WriteRequest writeRequest) {
if (!tryAcquireSemaphore()) {
return;
}
mSerializingExecutor.execute(() -> {
try {
if (mContext == null) {
LOG.debug("Received write request {}.", writeRequest);
mContext = createRequestContext(writeRequest);
} else {
Preconditions.checkState(!mContext.isDoneUnsafe(),
"invalid request after write request is completed.");
}
if (mContext.isDoneUnsafe() || mContext.getError() != null) {
return;
}
validateWriteRequest(writeRequest);
if (writeRequest.hasCommand()) {
WriteRequestCommand command = writeRequest.getCommand();
if (command.getFlush()) {
flush();
} else {
handleCommand(command, mContext);
}
} else {
Preconditions.checkState(writeRequest.hasChunk(),
"write request is missing data chunk in non-command message");
ByteString data = writeRequest.getChunk().getData();
Preconditions.checkState(data != null && data.size() > 0,
"invalid data size from write request message");
writeData(new NioDataBuffer(data.asReadOnlyByteBuffer(), data.size()));
}
} catch (Exception e) {
LogUtils.warnWithException(LOG, "Exception occurred while processing write request {}.",
writeRequest, e);
abort(new Error(AlluxioStatusException.fromThrowable(e), true));
} finally {
mSemaphore.release();
}
});
}
|
java
|
public void write(WriteRequest writeRequest) {
if (!tryAcquireSemaphore()) {
return;
}
mSerializingExecutor.execute(() -> {
try {
if (mContext == null) {
LOG.debug("Received write request {}.", writeRequest);
mContext = createRequestContext(writeRequest);
} else {
Preconditions.checkState(!mContext.isDoneUnsafe(),
"invalid request after write request is completed.");
}
if (mContext.isDoneUnsafe() || mContext.getError() != null) {
return;
}
validateWriteRequest(writeRequest);
if (writeRequest.hasCommand()) {
WriteRequestCommand command = writeRequest.getCommand();
if (command.getFlush()) {
flush();
} else {
handleCommand(command, mContext);
}
} else {
Preconditions.checkState(writeRequest.hasChunk(),
"write request is missing data chunk in non-command message");
ByteString data = writeRequest.getChunk().getData();
Preconditions.checkState(data != null && data.size() > 0,
"invalid data size from write request message");
writeData(new NioDataBuffer(data.asReadOnlyByteBuffer(), data.size()));
}
} catch (Exception e) {
LogUtils.warnWithException(LOG, "Exception occurred while processing write request {}.",
writeRequest, e);
abort(new Error(AlluxioStatusException.fromThrowable(e), true));
} finally {
mSemaphore.release();
}
});
}
|
[
"public",
"void",
"write",
"(",
"WriteRequest",
"writeRequest",
")",
"{",
"if",
"(",
"!",
"tryAcquireSemaphore",
"(",
")",
")",
"{",
"return",
";",
"}",
"mSerializingExecutor",
".",
"execute",
"(",
"(",
")",
"->",
"{",
"try",
"{",
"if",
"(",
"mContext",
"==",
"null",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Received write request {}.\"",
",",
"writeRequest",
")",
";",
"mContext",
"=",
"createRequestContext",
"(",
"writeRequest",
")",
";",
"}",
"else",
"{",
"Preconditions",
".",
"checkState",
"(",
"!",
"mContext",
".",
"isDoneUnsafe",
"(",
")",
",",
"\"invalid request after write request is completed.\"",
")",
";",
"}",
"if",
"(",
"mContext",
".",
"isDoneUnsafe",
"(",
")",
"||",
"mContext",
".",
"getError",
"(",
")",
"!=",
"null",
")",
"{",
"return",
";",
"}",
"validateWriteRequest",
"(",
"writeRequest",
")",
";",
"if",
"(",
"writeRequest",
".",
"hasCommand",
"(",
")",
")",
"{",
"WriteRequestCommand",
"command",
"=",
"writeRequest",
".",
"getCommand",
"(",
")",
";",
"if",
"(",
"command",
".",
"getFlush",
"(",
")",
")",
"{",
"flush",
"(",
")",
";",
"}",
"else",
"{",
"handleCommand",
"(",
"command",
",",
"mContext",
")",
";",
"}",
"}",
"else",
"{",
"Preconditions",
".",
"checkState",
"(",
"writeRequest",
".",
"hasChunk",
"(",
")",
",",
"\"write request is missing data chunk in non-command message\"",
")",
";",
"ByteString",
"data",
"=",
"writeRequest",
".",
"getChunk",
"(",
")",
".",
"getData",
"(",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"data",
"!=",
"null",
"&&",
"data",
".",
"size",
"(",
")",
">",
"0",
",",
"\"invalid data size from write request message\"",
")",
";",
"writeData",
"(",
"new",
"NioDataBuffer",
"(",
"data",
".",
"asReadOnlyByteBuffer",
"(",
")",
",",
"data",
".",
"size",
"(",
")",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LogUtils",
".",
"warnWithException",
"(",
"LOG",
",",
"\"Exception occurred while processing write request {}.\"",
",",
"writeRequest",
",",
"e",
")",
";",
"abort",
"(",
"new",
"Error",
"(",
"AlluxioStatusException",
".",
"fromThrowable",
"(",
"e",
")",
",",
"true",
")",
")",
";",
"}",
"finally",
"{",
"mSemaphore",
".",
"release",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Handles write request.
@param writeRequest the request from the client
|
[
"Handles",
"write",
"request",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java#L101-L141
|
18,634
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java
|
AbstractWriteHandler.writeDataMessage
|
public void writeDataMessage(WriteRequest request, DataBuffer buffer) {
if (buffer == null) {
write(request);
return;
}
Preconditions.checkState(!request.hasCommand(),
"write request command should not come with data buffer");
Preconditions.checkState(buffer.readableBytes() > 0,
"invalid data size from write request message");
if (!tryAcquireSemaphore()) {
return;
}
mSerializingExecutor.execute(() -> {
try {
writeData(buffer);
} finally {
mSemaphore.release();
}
});
}
|
java
|
public void writeDataMessage(WriteRequest request, DataBuffer buffer) {
if (buffer == null) {
write(request);
return;
}
Preconditions.checkState(!request.hasCommand(),
"write request command should not come with data buffer");
Preconditions.checkState(buffer.readableBytes() > 0,
"invalid data size from write request message");
if (!tryAcquireSemaphore()) {
return;
}
mSerializingExecutor.execute(() -> {
try {
writeData(buffer);
} finally {
mSemaphore.release();
}
});
}
|
[
"public",
"void",
"writeDataMessage",
"(",
"WriteRequest",
"request",
",",
"DataBuffer",
"buffer",
")",
"{",
"if",
"(",
"buffer",
"==",
"null",
")",
"{",
"write",
"(",
"request",
")",
";",
"return",
";",
"}",
"Preconditions",
".",
"checkState",
"(",
"!",
"request",
".",
"hasCommand",
"(",
")",
",",
"\"write request command should not come with data buffer\"",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"buffer",
".",
"readableBytes",
"(",
")",
">",
"0",
",",
"\"invalid data size from write request message\"",
")",
";",
"if",
"(",
"!",
"tryAcquireSemaphore",
"(",
")",
")",
"{",
"return",
";",
"}",
"mSerializingExecutor",
".",
"execute",
"(",
"(",
")",
"->",
"{",
"try",
"{",
"writeData",
"(",
"buffer",
")",
";",
"}",
"finally",
"{",
"mSemaphore",
".",
"release",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Handles write request with data message.
@param request the request from the client
@param buffer the data associated with the request
|
[
"Handles",
"write",
"request",
"with",
"data",
"message",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java#L149-L168
|
18,635
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java
|
AbstractWriteHandler.onCompleted
|
public void onCompleted() {
mSerializingExecutor.execute(() -> {
Preconditions.checkState(mContext != null);
try {
completeRequest(mContext);
replySuccess();
} catch (Exception e) {
LogUtils.warnWithException(LOG, "Exception occurred while completing write request {}.",
mContext.getRequest(), e);
Throwables.throwIfUnchecked(e);
abort(new Error(AlluxioStatusException.fromCheckedException(e), true));
}
});
}
|
java
|
public void onCompleted() {
mSerializingExecutor.execute(() -> {
Preconditions.checkState(mContext != null);
try {
completeRequest(mContext);
replySuccess();
} catch (Exception e) {
LogUtils.warnWithException(LOG, "Exception occurred while completing write request {}.",
mContext.getRequest(), e);
Throwables.throwIfUnchecked(e);
abort(new Error(AlluxioStatusException.fromCheckedException(e), true));
}
});
}
|
[
"public",
"void",
"onCompleted",
"(",
")",
"{",
"mSerializingExecutor",
".",
"execute",
"(",
"(",
")",
"->",
"{",
"Preconditions",
".",
"checkState",
"(",
"mContext",
"!=",
"null",
")",
";",
"try",
"{",
"completeRequest",
"(",
"mContext",
")",
";",
"replySuccess",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LogUtils",
".",
"warnWithException",
"(",
"LOG",
",",
"\"Exception occurred while completing write request {}.\"",
",",
"mContext",
".",
"getRequest",
"(",
")",
",",
"e",
")",
";",
"Throwables",
".",
"throwIfUnchecked",
"(",
"e",
")",
";",
"abort",
"(",
"new",
"Error",
"(",
"AlluxioStatusException",
".",
"fromCheckedException",
"(",
"e",
")",
",",
"true",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Handles request complete event.
|
[
"Handles",
"request",
"complete",
"event",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java#L173-L186
|
18,636
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java
|
AbstractWriteHandler.onCancel
|
public void onCancel() {
mSerializingExecutor.execute(() -> {
try {
cancelRequest(mContext);
replyCancel();
} catch (Exception e) {
LogUtils.warnWithException(LOG, "Exception occurred while cancelling write request {}.",
mContext.getRequest(), e);
Throwables.throwIfUnchecked(e);
abort(new Error(AlluxioStatusException.fromCheckedException(e), true));
}
});
}
|
java
|
public void onCancel() {
mSerializingExecutor.execute(() -> {
try {
cancelRequest(mContext);
replyCancel();
} catch (Exception e) {
LogUtils.warnWithException(LOG, "Exception occurred while cancelling write request {}.",
mContext.getRequest(), e);
Throwables.throwIfUnchecked(e);
abort(new Error(AlluxioStatusException.fromCheckedException(e), true));
}
});
}
|
[
"public",
"void",
"onCancel",
"(",
")",
"{",
"mSerializingExecutor",
".",
"execute",
"(",
"(",
")",
"->",
"{",
"try",
"{",
"cancelRequest",
"(",
"mContext",
")",
";",
"replyCancel",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LogUtils",
".",
"warnWithException",
"(",
"LOG",
",",
"\"Exception occurred while cancelling write request {}.\"",
",",
"mContext",
".",
"getRequest",
"(",
")",
",",
"e",
")",
";",
"Throwables",
".",
"throwIfUnchecked",
"(",
"e",
")",
";",
"abort",
"(",
"new",
"Error",
"(",
"AlluxioStatusException",
".",
"fromCheckedException",
"(",
"e",
")",
",",
"true",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Handles request cancellation event.
|
[
"Handles",
"request",
"cancellation",
"event",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java#L191-L203
|
18,637
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java
|
AbstractWriteHandler.onError
|
public void onError(Throwable cause) {
if (cause instanceof StatusRuntimeException
&& ((StatusRuntimeException) cause).getStatus().getCode() == Status.Code.CANCELLED) {
// Cancellation is already handled.
return;
}
mSerializingExecutor.execute(() -> {
LogUtils.warnWithException(LOG, "Exception thrown while handling write request {}",
mContext == null ? "unknown" : mContext.getRequest(), cause);
abort(new Error(AlluxioStatusException.fromThrowable(cause), false));
});
}
|
java
|
public void onError(Throwable cause) {
if (cause instanceof StatusRuntimeException
&& ((StatusRuntimeException) cause).getStatus().getCode() == Status.Code.CANCELLED) {
// Cancellation is already handled.
return;
}
mSerializingExecutor.execute(() -> {
LogUtils.warnWithException(LOG, "Exception thrown while handling write request {}",
mContext == null ? "unknown" : mContext.getRequest(), cause);
abort(new Error(AlluxioStatusException.fromThrowable(cause), false));
});
}
|
[
"public",
"void",
"onError",
"(",
"Throwable",
"cause",
")",
"{",
"if",
"(",
"cause",
"instanceof",
"StatusRuntimeException",
"&&",
"(",
"(",
"StatusRuntimeException",
")",
"cause",
")",
".",
"getStatus",
"(",
")",
".",
"getCode",
"(",
")",
"==",
"Status",
".",
"Code",
".",
"CANCELLED",
")",
"{",
"// Cancellation is already handled.",
"return",
";",
"}",
"mSerializingExecutor",
".",
"execute",
"(",
"(",
")",
"->",
"{",
"LogUtils",
".",
"warnWithException",
"(",
"LOG",
",",
"\"Exception thrown while handling write request {}\"",
",",
"mContext",
"==",
"null",
"?",
"\"unknown\"",
":",
"mContext",
".",
"getRequest",
"(",
")",
",",
"cause",
")",
";",
"abort",
"(",
"new",
"Error",
"(",
"AlluxioStatusException",
".",
"fromThrowable",
"(",
"cause",
")",
",",
"false",
")",
")",
";",
"}",
")",
";",
"}"
] |
Handles errors from the request.
@param cause the exception
|
[
"Handles",
"errors",
"from",
"the",
"request",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java#L210-L221
|
18,638
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java
|
AbstractWriteHandler.validateWriteRequest
|
@GuardedBy("mLock")
private void validateWriteRequest(alluxio.grpc.WriteRequest request)
throws InvalidArgumentException {
if (request.hasCommand() && request.getCommand().hasOffset()
&& request.getCommand().getOffset() != mContext.getPos()) {
throw new InvalidArgumentException(String.format(
"Offsets do not match [received: %d, expected: %d].",
request.getCommand().getOffset(), mContext.getPos()));
}
}
|
java
|
@GuardedBy("mLock")
private void validateWriteRequest(alluxio.grpc.WriteRequest request)
throws InvalidArgumentException {
if (request.hasCommand() && request.getCommand().hasOffset()
&& request.getCommand().getOffset() != mContext.getPos()) {
throw new InvalidArgumentException(String.format(
"Offsets do not match [received: %d, expected: %d].",
request.getCommand().getOffset(), mContext.getPos()));
}
}
|
[
"@",
"GuardedBy",
"(",
"\"mLock\"",
")",
"private",
"void",
"validateWriteRequest",
"(",
"alluxio",
".",
"grpc",
".",
"WriteRequest",
"request",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"request",
".",
"hasCommand",
"(",
")",
"&&",
"request",
".",
"getCommand",
"(",
")",
".",
"hasOffset",
"(",
")",
"&&",
"request",
".",
"getCommand",
"(",
")",
".",
"getOffset",
"(",
")",
"!=",
"mContext",
".",
"getPos",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"String",
".",
"format",
"(",
"\"Offsets do not match [received: %d, expected: %d].\"",
",",
"request",
".",
"getCommand",
"(",
")",
".",
"getOffset",
"(",
")",
",",
"mContext",
".",
"getPos",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Validates a block write request.
@param request the block write request
@throws InvalidArgumentException if the write request is invalid
|
[
"Validates",
"a",
"block",
"write",
"request",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java#L242-L251
|
18,639
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java
|
AbstractWriteHandler.abort
|
private void abort(Error error) {
try {
if (mContext == null || mContext.getError() != null || mContext.isDoneUnsafe()) {
// Note, we may reach here via events due to network errors bubbling up before
// mContext is initialized, or stream error after the request is finished.
return;
}
mContext.setError(error);
cleanupRequest(mContext);
replyError();
} catch (Exception e) {
LOG.warn("Failed to cleanup states with error {}.", e.getMessage());
}
}
|
java
|
private void abort(Error error) {
try {
if (mContext == null || mContext.getError() != null || mContext.isDoneUnsafe()) {
// Note, we may reach here via events due to network errors bubbling up before
// mContext is initialized, or stream error after the request is finished.
return;
}
mContext.setError(error);
cleanupRequest(mContext);
replyError();
} catch (Exception e) {
LOG.warn("Failed to cleanup states with error {}.", e.getMessage());
}
}
|
[
"private",
"void",
"abort",
"(",
"Error",
"error",
")",
"{",
"try",
"{",
"if",
"(",
"mContext",
"==",
"null",
"||",
"mContext",
".",
"getError",
"(",
")",
"!=",
"null",
"||",
"mContext",
".",
"isDoneUnsafe",
"(",
")",
")",
"{",
"// Note, we may reach here via events due to network errors bubbling up before",
"// mContext is initialized, or stream error after the request is finished.",
"return",
";",
"}",
"mContext",
".",
"setError",
"(",
"error",
")",
";",
"cleanupRequest",
"(",
"mContext",
")",
";",
"replyError",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to cleanup states with error {}.\"",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Abort the write process due to error.
@param error the error
|
[
"Abort",
"the",
"write",
"process",
"due",
"to",
"error",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java#L287-L300
|
18,640
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java
|
AbstractWriteHandler.replyError
|
private void replyError() {
Error error = Preconditions.checkNotNull(mContext.getError());
if (error.isNotifyClient()) {
mResponseObserver.onError(error.getCause().toGrpcStatusException());
}
}
|
java
|
private void replyError() {
Error error = Preconditions.checkNotNull(mContext.getError());
if (error.isNotifyClient()) {
mResponseObserver.onError(error.getCause().toGrpcStatusException());
}
}
|
[
"private",
"void",
"replyError",
"(",
")",
"{",
"Error",
"error",
"=",
"Preconditions",
".",
"checkNotNull",
"(",
"mContext",
".",
"getError",
"(",
")",
")",
";",
"if",
"(",
"error",
".",
"isNotifyClient",
"(",
")",
")",
"{",
"mResponseObserver",
".",
"onError",
"(",
"error",
".",
"getCause",
"(",
")",
".",
"toGrpcStatusException",
"(",
")",
")",
";",
"}",
"}"
] |
Writes an error response.
|
[
"Writes",
"an",
"error",
"response",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/AbstractWriteHandler.java#L375-L380
|
18,641
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/stream/GrpcBlockingStream.java
|
GrpcBlockingStream.send
|
public void send(ReqT request, long timeoutMs) throws IOException {
if (mClosed || mCanceled || mClosedFromRemote) {
throw new CancelledException(formatErrorMessage(
"Failed to send request %s: stream is already closed or canceled.", request));
}
try (LockResource lr = new LockResource(mLock)) {
while (true) {
checkError();
if (mRequestObserver.isReady()) {
break;
}
try {
if (!mReadyOrFailed.await(timeoutMs, TimeUnit.MILLISECONDS)) {
throw new DeadlineExceededException(
formatErrorMessage("Timeout sending request %s after %dms.", request, timeoutMs));
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new CancelledException(formatErrorMessage(
"Failed to send request %s: interrupted while waiting for server.", request), e);
}
}
}
mRequestObserver.onNext(request);
}
|
java
|
public void send(ReqT request, long timeoutMs) throws IOException {
if (mClosed || mCanceled || mClosedFromRemote) {
throw new CancelledException(formatErrorMessage(
"Failed to send request %s: stream is already closed or canceled.", request));
}
try (LockResource lr = new LockResource(mLock)) {
while (true) {
checkError();
if (mRequestObserver.isReady()) {
break;
}
try {
if (!mReadyOrFailed.await(timeoutMs, TimeUnit.MILLISECONDS)) {
throw new DeadlineExceededException(
formatErrorMessage("Timeout sending request %s after %dms.", request, timeoutMs));
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new CancelledException(formatErrorMessage(
"Failed to send request %s: interrupted while waiting for server.", request), e);
}
}
}
mRequestObserver.onNext(request);
}
|
[
"public",
"void",
"send",
"(",
"ReqT",
"request",
",",
"long",
"timeoutMs",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mClosed",
"||",
"mCanceled",
"||",
"mClosedFromRemote",
")",
"{",
"throw",
"new",
"CancelledException",
"(",
"formatErrorMessage",
"(",
"\"Failed to send request %s: stream is already closed or canceled.\"",
",",
"request",
")",
")",
";",
"}",
"try",
"(",
"LockResource",
"lr",
"=",
"new",
"LockResource",
"(",
"mLock",
")",
")",
"{",
"while",
"(",
"true",
")",
"{",
"checkError",
"(",
")",
";",
"if",
"(",
"mRequestObserver",
".",
"isReady",
"(",
")",
")",
"{",
"break",
";",
"}",
"try",
"{",
"if",
"(",
"!",
"mReadyOrFailed",
".",
"await",
"(",
"timeoutMs",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
")",
"{",
"throw",
"new",
"DeadlineExceededException",
"(",
"formatErrorMessage",
"(",
"\"Timeout sending request %s after %dms.\"",
",",
"request",
",",
"timeoutMs",
")",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"throw",
"new",
"CancelledException",
"(",
"formatErrorMessage",
"(",
"\"Failed to send request %s: interrupted while waiting for server.\"",
",",
"request",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
"mRequestObserver",
".",
"onNext",
"(",
"request",
")",
";",
"}"
] |
Sends a request. Will wait until the stream is ready before sending or timeout if the
given timeout is reached.
@param request the request
@param timeoutMs maximum wait time before throwing a {@link DeadlineExceededException}
@throws IOException if any error occurs
|
[
"Sends",
"a",
"request",
".",
"Will",
"wait",
"until",
"the",
"stream",
"is",
"ready",
"before",
"sending",
"or",
"timeout",
"if",
"the",
"given",
"timeout",
"is",
"reached",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/stream/GrpcBlockingStream.java#L93-L117
|
18,642
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/stream/GrpcBlockingStream.java
|
GrpcBlockingStream.send
|
public void send(ReqT request) throws IOException {
if (mClosed || mCanceled || mClosedFromRemote) {
throw new CancelledException(formatErrorMessage(
"Failed to send request %s: stream is already closed or canceled.", request));
}
try (LockResource lr = new LockResource(mLock)) {
checkError();
}
mRequestObserver.onNext(request);
}
|
java
|
public void send(ReqT request) throws IOException {
if (mClosed || mCanceled || mClosedFromRemote) {
throw new CancelledException(formatErrorMessage(
"Failed to send request %s: stream is already closed or canceled.", request));
}
try (LockResource lr = new LockResource(mLock)) {
checkError();
}
mRequestObserver.onNext(request);
}
|
[
"public",
"void",
"send",
"(",
"ReqT",
"request",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mClosed",
"||",
"mCanceled",
"||",
"mClosedFromRemote",
")",
"{",
"throw",
"new",
"CancelledException",
"(",
"formatErrorMessage",
"(",
"\"Failed to send request %s: stream is already closed or canceled.\"",
",",
"request",
")",
")",
";",
"}",
"try",
"(",
"LockResource",
"lr",
"=",
"new",
"LockResource",
"(",
"mLock",
")",
")",
"{",
"checkError",
"(",
")",
";",
"}",
"mRequestObserver",
".",
"onNext",
"(",
"request",
")",
";",
"}"
] |
Sends a request. Will not wait for the stream to be ready.
@param request the request
@throws IOException if any error occurs
|
[
"Sends",
"a",
"request",
".",
"Will",
"not",
"wait",
"for",
"the",
"stream",
"to",
"be",
"ready",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/stream/GrpcBlockingStream.java#L125-L134
|
18,643
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/stream/GrpcBlockingStream.java
|
GrpcBlockingStream.receive
|
public ResT receive(long timeoutMs) throws IOException {
if (mCompleted) {
return null;
}
if (mCanceled) {
throw new CancelledException(formatErrorMessage("Stream is already canceled."));
}
try {
Object response = mResponses.poll(timeoutMs, TimeUnit.MILLISECONDS);
if (response == null) {
throw new DeadlineExceededException(
formatErrorMessage("Timeout waiting for response after %dms.", timeoutMs));
}
if (response == mResponseObserver) {
mCompleted = true;
return null;
}
checkError();
return (ResT) response;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new CancelledException(
formatErrorMessage("Interrupted while waiting for response."), e);
}
}
|
java
|
public ResT receive(long timeoutMs) throws IOException {
if (mCompleted) {
return null;
}
if (mCanceled) {
throw new CancelledException(formatErrorMessage("Stream is already canceled."));
}
try {
Object response = mResponses.poll(timeoutMs, TimeUnit.MILLISECONDS);
if (response == null) {
throw new DeadlineExceededException(
formatErrorMessage("Timeout waiting for response after %dms.", timeoutMs));
}
if (response == mResponseObserver) {
mCompleted = true;
return null;
}
checkError();
return (ResT) response;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new CancelledException(
formatErrorMessage("Interrupted while waiting for response."), e);
}
}
|
[
"public",
"ResT",
"receive",
"(",
"long",
"timeoutMs",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mCompleted",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"mCanceled",
")",
"{",
"throw",
"new",
"CancelledException",
"(",
"formatErrorMessage",
"(",
"\"Stream is already canceled.\"",
")",
")",
";",
"}",
"try",
"{",
"Object",
"response",
"=",
"mResponses",
".",
"poll",
"(",
"timeoutMs",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"if",
"(",
"response",
"==",
"null",
")",
"{",
"throw",
"new",
"DeadlineExceededException",
"(",
"formatErrorMessage",
"(",
"\"Timeout waiting for response after %dms.\"",
",",
"timeoutMs",
")",
")",
";",
"}",
"if",
"(",
"response",
"==",
"mResponseObserver",
")",
"{",
"mCompleted",
"=",
"true",
";",
"return",
"null",
";",
"}",
"checkError",
"(",
")",
";",
"return",
"(",
"ResT",
")",
"response",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"throw",
"new",
"CancelledException",
"(",
"formatErrorMessage",
"(",
"\"Interrupted while waiting for response.\"",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Receives a response from the server. Will wait until a response is received, or
throw an exception if times out.
@param timeoutMs maximum time to wait before giving up and throwing
a {@link DeadlineExceededException}
@return the response message, or null if the inbound stream is completed
@throws IOException if any error occurs
|
[
"Receives",
"a",
"response",
"from",
"the",
"server",
".",
"Will",
"wait",
"until",
"a",
"response",
"is",
"received",
"or",
"throw",
"an",
"exception",
"if",
"times",
"out",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/stream/GrpcBlockingStream.java#L145-L169
|
18,644
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/stream/GrpcBlockingStream.java
|
GrpcBlockingStream.cancel
|
public void cancel() {
if (isOpen()) {
LOG.debug("Cancelling stream ({})", mDescription);
mCanceled = true;
mRequestObserver.cancel("Request is cancelled by user.", null);
}
}
|
java
|
public void cancel() {
if (isOpen()) {
LOG.debug("Cancelling stream ({})", mDescription);
mCanceled = true;
mRequestObserver.cancel("Request is cancelled by user.", null);
}
}
|
[
"public",
"void",
"cancel",
"(",
")",
"{",
"if",
"(",
"isOpen",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Cancelling stream ({})\"",
",",
"mDescription",
")",
";",
"mCanceled",
"=",
"true",
";",
"mRequestObserver",
".",
"cancel",
"(",
"\"Request is cancelled by user.\"",
",",
"null",
")",
";",
"}",
"}"
] |
Cancels the stream.
|
[
"Cancels",
"the",
"stream",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/stream/GrpcBlockingStream.java#L185-L191
|
18,645
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/master/job/AlluxioJobMasterMonitor.java
|
AlluxioJobMasterMonitor.main
|
public static void main(String[] args) {
if (args.length != 0) {
LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR,
AlluxioJobMasterMonitor.class.getCanonicalName());
LOG.warn("ignoring arguments");
}
AlluxioConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
HealthCheckClient client;
// Only the primary master serves RPCs, so if we're configured for HA, fall back to simply
// checking for the running process.
if (ConfigurationUtils.isHaMode(conf)) {
client = new MasterHealthCheckClient.Builder(conf)
.withAlluxioMasterType(MasterHealthCheckClient.MasterType.JOB_MASTER)
.build();
} else {
client = new JobMasterRpcHealthCheckClient(NetworkAddressUtils
.getConnectAddress(NetworkAddressUtils.ServiceType.JOB_MASTER_RPC, conf),
AlluxioMasterMonitor.TWO_MIN_EXP_BACKOFF, conf);
}
if (!client.isServing()) {
System.exit(1);
}
System.exit(0);
}
|
java
|
public static void main(String[] args) {
if (args.length != 0) {
LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR,
AlluxioJobMasterMonitor.class.getCanonicalName());
LOG.warn("ignoring arguments");
}
AlluxioConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
HealthCheckClient client;
// Only the primary master serves RPCs, so if we're configured for HA, fall back to simply
// checking for the running process.
if (ConfigurationUtils.isHaMode(conf)) {
client = new MasterHealthCheckClient.Builder(conf)
.withAlluxioMasterType(MasterHealthCheckClient.MasterType.JOB_MASTER)
.build();
} else {
client = new JobMasterRpcHealthCheckClient(NetworkAddressUtils
.getConnectAddress(NetworkAddressUtils.ServiceType.JOB_MASTER_RPC, conf),
AlluxioMasterMonitor.TWO_MIN_EXP_BACKOFF, conf);
}
if (!client.isServing()) {
System.exit(1);
}
System.exit(0);
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"if",
"(",
"args",
".",
"length",
"!=",
"0",
")",
"{",
"LOG",
".",
"info",
"(",
"\"java -cp {} {}\"",
",",
"RuntimeConstants",
".",
"ALLUXIO_JAR",
",",
"AlluxioJobMasterMonitor",
".",
"class",
".",
"getCanonicalName",
"(",
")",
")",
";",
"LOG",
".",
"warn",
"(",
"\"ignoring arguments\"",
")",
";",
"}",
"AlluxioConfiguration",
"conf",
"=",
"new",
"InstancedConfiguration",
"(",
"ConfigurationUtils",
".",
"defaults",
"(",
")",
")",
";",
"HealthCheckClient",
"client",
";",
"// Only the primary master serves RPCs, so if we're configured for HA, fall back to simply",
"// checking for the running process.",
"if",
"(",
"ConfigurationUtils",
".",
"isHaMode",
"(",
"conf",
")",
")",
"{",
"client",
"=",
"new",
"MasterHealthCheckClient",
".",
"Builder",
"(",
"conf",
")",
".",
"withAlluxioMasterType",
"(",
"MasterHealthCheckClient",
".",
"MasterType",
".",
"JOB_MASTER",
")",
".",
"build",
"(",
")",
";",
"}",
"else",
"{",
"client",
"=",
"new",
"JobMasterRpcHealthCheckClient",
"(",
"NetworkAddressUtils",
".",
"getConnectAddress",
"(",
"NetworkAddressUtils",
".",
"ServiceType",
".",
"JOB_MASTER_RPC",
",",
"conf",
")",
",",
"AlluxioMasterMonitor",
".",
"TWO_MIN_EXP_BACKOFF",
",",
"conf",
")",
";",
"}",
"if",
"(",
"!",
"client",
".",
"isServing",
"(",
")",
")",
"{",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"System",
".",
"exit",
"(",
"0",
")",
";",
"}"
] |
Starts the Alluxio job_master monitor.
@param args command line arguments, should be empty
|
[
"Starts",
"the",
"Alluxio",
"job_master",
"monitor",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/master/job/AlluxioJobMasterMonitor.java#L37-L61
|
18,646
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/command/LoadCommand.java
|
LoadCommand.load
|
private void load(AlluxioURI filePath, boolean local) throws AlluxioException, IOException {
URIStatus status = mFileSystem.getStatus(filePath);
if (status.isFolder()) {
List<URIStatus> statuses = mFileSystem.listStatus(filePath);
for (URIStatus uriStatus : statuses) {
AlluxioURI newPath = new AlluxioURI(uriStatus.getPath());
load(newPath, local);
}
} else {
OpenFilePOptions options =
OpenFilePOptions.newBuilder().setReadType(ReadPType.CACHE_PROMOTE).build();
if (local) {
if (!mFsContext.hasLocalWorker()) {
System.out.println("When local option is specified,"
+ " there must be a local worker available");
return;
}
} else if (status.getInAlluxioPercentage() == 100) {
// The file has already been fully loaded into Alluxio.
System.out.println(filePath + " already in Alluxio fully");
return;
}
Closer closer = Closer.create();
try {
FileInStream in = closer.register(mFileSystem.openFile(filePath, options));
byte[] buf = new byte[8 * Constants.MB];
while (in.read(buf) != -1) {
}
} catch (Exception e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
}
System.out.println(filePath + " loaded");
}
|
java
|
private void load(AlluxioURI filePath, boolean local) throws AlluxioException, IOException {
URIStatus status = mFileSystem.getStatus(filePath);
if (status.isFolder()) {
List<URIStatus> statuses = mFileSystem.listStatus(filePath);
for (URIStatus uriStatus : statuses) {
AlluxioURI newPath = new AlluxioURI(uriStatus.getPath());
load(newPath, local);
}
} else {
OpenFilePOptions options =
OpenFilePOptions.newBuilder().setReadType(ReadPType.CACHE_PROMOTE).build();
if (local) {
if (!mFsContext.hasLocalWorker()) {
System.out.println("When local option is specified,"
+ " there must be a local worker available");
return;
}
} else if (status.getInAlluxioPercentage() == 100) {
// The file has already been fully loaded into Alluxio.
System.out.println(filePath + " already in Alluxio fully");
return;
}
Closer closer = Closer.create();
try {
FileInStream in = closer.register(mFileSystem.openFile(filePath, options));
byte[] buf = new byte[8 * Constants.MB];
while (in.read(buf) != -1) {
}
} catch (Exception e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
}
System.out.println(filePath + " loaded");
}
|
[
"private",
"void",
"load",
"(",
"AlluxioURI",
"filePath",
",",
"boolean",
"local",
")",
"throws",
"AlluxioException",
",",
"IOException",
"{",
"URIStatus",
"status",
"=",
"mFileSystem",
".",
"getStatus",
"(",
"filePath",
")",
";",
"if",
"(",
"status",
".",
"isFolder",
"(",
")",
")",
"{",
"List",
"<",
"URIStatus",
">",
"statuses",
"=",
"mFileSystem",
".",
"listStatus",
"(",
"filePath",
")",
";",
"for",
"(",
"URIStatus",
"uriStatus",
":",
"statuses",
")",
"{",
"AlluxioURI",
"newPath",
"=",
"new",
"AlluxioURI",
"(",
"uriStatus",
".",
"getPath",
"(",
")",
")",
";",
"load",
"(",
"newPath",
",",
"local",
")",
";",
"}",
"}",
"else",
"{",
"OpenFilePOptions",
"options",
"=",
"OpenFilePOptions",
".",
"newBuilder",
"(",
")",
".",
"setReadType",
"(",
"ReadPType",
".",
"CACHE_PROMOTE",
")",
".",
"build",
"(",
")",
";",
"if",
"(",
"local",
")",
"{",
"if",
"(",
"!",
"mFsContext",
".",
"hasLocalWorker",
"(",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"When local option is specified,\"",
"+",
"\" there must be a local worker available\"",
")",
";",
"return",
";",
"}",
"}",
"else",
"if",
"(",
"status",
".",
"getInAlluxioPercentage",
"(",
")",
"==",
"100",
")",
"{",
"// The file has already been fully loaded into Alluxio.",
"System",
".",
"out",
".",
"println",
"(",
"filePath",
"+",
"\" already in Alluxio fully\"",
")",
";",
"return",
";",
"}",
"Closer",
"closer",
"=",
"Closer",
".",
"create",
"(",
")",
";",
"try",
"{",
"FileInStream",
"in",
"=",
"closer",
".",
"register",
"(",
"mFileSystem",
".",
"openFile",
"(",
"filePath",
",",
"options",
")",
")",
";",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"8",
"*",
"Constants",
".",
"MB",
"]",
";",
"while",
"(",
"in",
".",
"read",
"(",
"buf",
")",
"!=",
"-",
"1",
")",
"{",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"closer",
".",
"rethrow",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"closer",
".",
"close",
"(",
")",
";",
"}",
"}",
"System",
".",
"out",
".",
"println",
"(",
"filePath",
"+",
"\" loaded\"",
")",
";",
"}"
] |
Loads a file or directory in Alluxio space, makes it resident in Alluxio.
@param filePath The {@link AlluxioURI} path to load into Alluxio
@param local whether to load data to local worker even when the data is already loaded remotely
|
[
"Loads",
"a",
"file",
"or",
"directory",
"in",
"Alluxio",
"space",
"makes",
"it",
"resident",
"in",
"Alluxio",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/command/LoadCommand.java#L88-L123
|
18,647
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockStore.java
|
UnderFileSystemBlockStore.closeReaderOrWriter
|
public void closeReaderOrWriter(long sessionId, long blockId) throws IOException {
BlockInfo blockInfo;
try (LockResource lr = new LockResource(mLock)) {
blockInfo = mBlocks.get(new Key(sessionId, blockId));
if (blockInfo == null) {
LOG.warn("Key (block ID: {}, session ID {}) is not found when cleaning up the UFS block.",
blockId, sessionId);
return;
}
}
blockInfo.closeReaderOrWriter();
}
|
java
|
public void closeReaderOrWriter(long sessionId, long blockId) throws IOException {
BlockInfo blockInfo;
try (LockResource lr = new LockResource(mLock)) {
blockInfo = mBlocks.get(new Key(sessionId, blockId));
if (blockInfo == null) {
LOG.warn("Key (block ID: {}, session ID {}) is not found when cleaning up the UFS block.",
blockId, sessionId);
return;
}
}
blockInfo.closeReaderOrWriter();
}
|
[
"public",
"void",
"closeReaderOrWriter",
"(",
"long",
"sessionId",
",",
"long",
"blockId",
")",
"throws",
"IOException",
"{",
"BlockInfo",
"blockInfo",
";",
"try",
"(",
"LockResource",
"lr",
"=",
"new",
"LockResource",
"(",
"mLock",
")",
")",
"{",
"blockInfo",
"=",
"mBlocks",
".",
"get",
"(",
"new",
"Key",
"(",
"sessionId",
",",
"blockId",
")",
")",
";",
"if",
"(",
"blockInfo",
"==",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Key (block ID: {}, session ID {}) is not found when cleaning up the UFS block.\"",
",",
"blockId",
",",
"sessionId",
")",
";",
"return",
";",
"}",
"}",
"blockInfo",
".",
"closeReaderOrWriter",
"(",
")",
";",
"}"
] |
Closes the block reader or writer and checks whether it is necessary to commit the block
to Local block store.
During UFS block read, this is triggered when the block is unlocked.
During UFS block write, this is triggered when the UFS block is committed.
@param sessionId the session ID
@param blockId the block ID
|
[
"Closes",
"the",
"block",
"reader",
"or",
"writer",
"and",
"checks",
"whether",
"it",
"is",
"necessary",
"to",
"commit",
"the",
"block",
"to",
"Local",
"block",
"store",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockStore.java#L145-L156
|
18,648
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockStore.java
|
UnderFileSystemBlockStore.getBlockReader
|
public BlockReader getBlockReader(final long sessionId, long blockId, long offset)
throws BlockDoesNotExistException, IOException {
final BlockInfo blockInfo;
try (LockResource lr = new LockResource(mLock)) {
blockInfo = getBlockInfo(sessionId, blockId);
BlockReader blockReader = blockInfo.getBlockReader();
if (blockReader != null) {
return blockReader;
}
}
BlockReader reader =
UnderFileSystemBlockReader.create(blockInfo.getMeta(), offset, mLocalBlockStore,
mUfsManager, mUfsInstreamManager);
blockInfo.setBlockReader(reader);
return reader;
}
|
java
|
public BlockReader getBlockReader(final long sessionId, long blockId, long offset)
throws BlockDoesNotExistException, IOException {
final BlockInfo blockInfo;
try (LockResource lr = new LockResource(mLock)) {
blockInfo = getBlockInfo(sessionId, blockId);
BlockReader blockReader = blockInfo.getBlockReader();
if (blockReader != null) {
return blockReader;
}
}
BlockReader reader =
UnderFileSystemBlockReader.create(blockInfo.getMeta(), offset, mLocalBlockStore,
mUfsManager, mUfsInstreamManager);
blockInfo.setBlockReader(reader);
return reader;
}
|
[
"public",
"BlockReader",
"getBlockReader",
"(",
"final",
"long",
"sessionId",
",",
"long",
"blockId",
",",
"long",
"offset",
")",
"throws",
"BlockDoesNotExistException",
",",
"IOException",
"{",
"final",
"BlockInfo",
"blockInfo",
";",
"try",
"(",
"LockResource",
"lr",
"=",
"new",
"LockResource",
"(",
"mLock",
")",
")",
"{",
"blockInfo",
"=",
"getBlockInfo",
"(",
"sessionId",
",",
"blockId",
")",
";",
"BlockReader",
"blockReader",
"=",
"blockInfo",
".",
"getBlockReader",
"(",
")",
";",
"if",
"(",
"blockReader",
"!=",
"null",
")",
"{",
"return",
"blockReader",
";",
"}",
"}",
"BlockReader",
"reader",
"=",
"UnderFileSystemBlockReader",
".",
"create",
"(",
"blockInfo",
".",
"getMeta",
"(",
")",
",",
"offset",
",",
"mLocalBlockStore",
",",
"mUfsManager",
",",
"mUfsInstreamManager",
")",
";",
"blockInfo",
".",
"setBlockReader",
"(",
"reader",
")",
";",
"return",
"reader",
";",
"}"
] |
Creates a block reader that reads from UFS and optionally caches the block to the Alluxio
block store.
@param sessionId the client session ID that requested this read
@param blockId the ID of the block to read
@param offset the read offset within the block (NOT the file)
@return the block reader instance
@throws BlockDoesNotExistException if the UFS block does not exist in the
{@link UnderFileSystemBlockStore}
|
[
"Creates",
"a",
"block",
"reader",
"that",
"reads",
"from",
"UFS",
"and",
"optionally",
"caches",
"the",
"block",
"to",
"the",
"Alluxio",
"block",
"store",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/UnderFileSystemBlockStore.java#L231-L246
|
18,649
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/InodeDirectoryIdGenerator.java
|
InodeDirectoryIdGenerator.getNewDirectoryId
|
synchronized long getNewDirectoryId(JournalContext context) throws UnavailableException {
initialize(context);
long containerId = mNextDirectoryId.getContainerId();
long sequenceNumber = mNextDirectoryId.getSequenceNumber();
long directoryId = BlockId.createBlockId(containerId, sequenceNumber);
if (sequenceNumber == BlockId.getMaxSequenceNumber()) {
// No more ids in this container. Get a new container for the next id.
containerId = mContainerIdGenerator.getNewContainerId();
sequenceNumber = 0;
} else {
sequenceNumber++;
}
applyAndJournal(context, toEntry(containerId, sequenceNumber));
return directoryId;
}
|
java
|
synchronized long getNewDirectoryId(JournalContext context) throws UnavailableException {
initialize(context);
long containerId = mNextDirectoryId.getContainerId();
long sequenceNumber = mNextDirectoryId.getSequenceNumber();
long directoryId = BlockId.createBlockId(containerId, sequenceNumber);
if (sequenceNumber == BlockId.getMaxSequenceNumber()) {
// No more ids in this container. Get a new container for the next id.
containerId = mContainerIdGenerator.getNewContainerId();
sequenceNumber = 0;
} else {
sequenceNumber++;
}
applyAndJournal(context, toEntry(containerId, sequenceNumber));
return directoryId;
}
|
[
"synchronized",
"long",
"getNewDirectoryId",
"(",
"JournalContext",
"context",
")",
"throws",
"UnavailableException",
"{",
"initialize",
"(",
"context",
")",
";",
"long",
"containerId",
"=",
"mNextDirectoryId",
".",
"getContainerId",
"(",
")",
";",
"long",
"sequenceNumber",
"=",
"mNextDirectoryId",
".",
"getSequenceNumber",
"(",
")",
";",
"long",
"directoryId",
"=",
"BlockId",
".",
"createBlockId",
"(",
"containerId",
",",
"sequenceNumber",
")",
";",
"if",
"(",
"sequenceNumber",
"==",
"BlockId",
".",
"getMaxSequenceNumber",
"(",
")",
")",
"{",
"// No more ids in this container. Get a new container for the next id.",
"containerId",
"=",
"mContainerIdGenerator",
".",
"getNewContainerId",
"(",
")",
";",
"sequenceNumber",
"=",
"0",
";",
"}",
"else",
"{",
"sequenceNumber",
"++",
";",
"}",
"applyAndJournal",
"(",
"context",
",",
"toEntry",
"(",
"containerId",
",",
"sequenceNumber",
")",
")",
";",
"return",
"directoryId",
";",
"}"
] |
Returns the next directory id, and journals the state.
@return the next directory id
|
[
"Returns",
"the",
"next",
"directory",
"id",
"and",
"journals",
"the",
"state",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/InodeDirectoryIdGenerator.java#L57-L71
|
18,650
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/CommonUtils.java
|
CommonUtils.listToString
|
public static <T> String listToString(List<T> list) {
StringBuilder sb = new StringBuilder();
for (T s : list) {
if (sb.length() != 0) {
sb.append(" ");
}
sb.append(s);
}
return sb.toString();
}
|
java
|
public static <T> String listToString(List<T> list) {
StringBuilder sb = new StringBuilder();
for (T s : list) {
if (sb.length() != 0) {
sb.append(" ");
}
sb.append(s);
}
return sb.toString();
}
|
[
"public",
"static",
"<",
"T",
">",
"String",
"listToString",
"(",
"List",
"<",
"T",
">",
"list",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"T",
"s",
":",
"list",
")",
"{",
"if",
"(",
"sb",
".",
"length",
"(",
")",
"!=",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"\" \"",
")",
";",
"}",
"sb",
".",
"append",
"(",
"s",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Converts a list of objects to a string.
@param list list of objects
@param <T> type of the objects
@return space-separated concatenation of the string representation returned by Object#toString
of the individual objects
|
[
"Converts",
"a",
"list",
"of",
"objects",
"to",
"a",
"string",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L112-L121
|
18,651
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/CommonUtils.java
|
CommonUtils.argsToString
|
public static <T> String argsToString(String separator, T... args) {
StringBuilder sb = new StringBuilder();
for (T s : args) {
if (sb.length() != 0) {
sb.append(separator);
}
sb.append(s);
}
return sb.toString();
}
|
java
|
public static <T> String argsToString(String separator, T... args) {
StringBuilder sb = new StringBuilder();
for (T s : args) {
if (sb.length() != 0) {
sb.append(separator);
}
sb.append(s);
}
return sb.toString();
}
|
[
"public",
"static",
"<",
"T",
">",
"String",
"argsToString",
"(",
"String",
"separator",
",",
"T",
"...",
"args",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"T",
"s",
":",
"args",
")",
"{",
"if",
"(",
"sb",
".",
"length",
"(",
")",
"!=",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"separator",
")",
";",
"}",
"sb",
".",
"append",
"(",
"s",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Converts varargs of objects to a string.
@param separator separator string
@param args variable arguments
@param <T> type of the objects
@return concatenation of the string representation returned by Object#toString
of the individual objects
|
[
"Converts",
"varargs",
"of",
"objects",
"to",
"a",
"string",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L132-L141
|
18,652
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/CommonUtils.java
|
CommonUtils.randomAlphaNumString
|
public static String randomAlphaNumString(int length) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < length; i++) {
sb.append(ALPHANUM.charAt(RANDOM.nextInt(ALPHANUM.length())));
}
return sb.toString();
}
|
java
|
public static String randomAlphaNumString(int length) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < length; i++) {
sb.append(ALPHANUM.charAt(RANDOM.nextInt(ALPHANUM.length())));
}
return sb.toString();
}
|
[
"public",
"static",
"String",
"randomAlphaNumString",
"(",
"int",
"length",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"sb",
".",
"append",
"(",
"ALPHANUM",
".",
"charAt",
"(",
"RANDOM",
".",
"nextInt",
"(",
"ALPHANUM",
".",
"length",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] |
Generates a random alphanumeric string of the given length.
@param length the length
@return a random string
|
[
"Generates",
"a",
"random",
"alphanumeric",
"string",
"of",
"the",
"given",
"length",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L160-L166
|
18,653
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/CommonUtils.java
|
CommonUtils.createNewClassInstance
|
public static <T> T createNewClassInstance(Class<T> cls, Class<?>[] ctorClassArgs,
Object[] ctorArgs) {
try {
if (ctorClassArgs == null) {
return cls.newInstance();
}
Constructor<T> ctor = cls.getConstructor(ctorClassArgs);
return ctor.newInstance(ctorArgs);
} catch (InvocationTargetException e) {
throw new RuntimeException(e.getCause());
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
|
java
|
public static <T> T createNewClassInstance(Class<T> cls, Class<?>[] ctorClassArgs,
Object[] ctorArgs) {
try {
if (ctorClassArgs == null) {
return cls.newInstance();
}
Constructor<T> ctor = cls.getConstructor(ctorClassArgs);
return ctor.newInstance(ctorArgs);
} catch (InvocationTargetException e) {
throw new RuntimeException(e.getCause());
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"createNewClassInstance",
"(",
"Class",
"<",
"T",
">",
"cls",
",",
"Class",
"<",
"?",
">",
"[",
"]",
"ctorClassArgs",
",",
"Object",
"[",
"]",
"ctorArgs",
")",
"{",
"try",
"{",
"if",
"(",
"ctorClassArgs",
"==",
"null",
")",
"{",
"return",
"cls",
".",
"newInstance",
"(",
")",
";",
"}",
"Constructor",
"<",
"T",
">",
"ctor",
"=",
"cls",
".",
"getConstructor",
"(",
"ctorClassArgs",
")",
";",
"return",
"ctor",
".",
"newInstance",
"(",
"ctorArgs",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
".",
"getCause",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ReflectiveOperationException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Creates new instance of a class by calling a constructor that receives ctorClassArgs arguments.
@param <T> type of the object
@param cls the class to create
@param ctorClassArgs parameters type list of the constructor to initiate, if null default
constructor will be called
@param ctorArgs the arguments to pass the constructor
@return new class object
@throws RuntimeException if the class cannot be instantiated
|
[
"Creates",
"new",
"instance",
"of",
"a",
"class",
"by",
"calling",
"a",
"constructor",
"that",
"receives",
"ctorClassArgs",
"arguments",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L224-L237
|
18,654
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/CommonUtils.java
|
CommonUtils.getUnixGroups
|
public static List<String> getUnixGroups(String user) throws IOException {
String result;
List<String> groups = new ArrayList<>();
try {
result = ShellUtils.execCommand(ShellUtils.getGroupsForUserCommand(user));
} catch (ExitCodeException e) {
// if we didn't get the group - just return empty list
LOG.warn("got exception trying to get groups for user " + user + ": " + e.getMessage());
return groups;
}
StringTokenizer tokenizer = new StringTokenizer(result, ShellUtils.TOKEN_SEPARATOR_REGEX);
while (tokenizer.hasMoreTokens()) {
groups.add(tokenizer.nextToken());
}
return groups;
}
|
java
|
public static List<String> getUnixGroups(String user) throws IOException {
String result;
List<String> groups = new ArrayList<>();
try {
result = ShellUtils.execCommand(ShellUtils.getGroupsForUserCommand(user));
} catch (ExitCodeException e) {
// if we didn't get the group - just return empty list
LOG.warn("got exception trying to get groups for user " + user + ": " + e.getMessage());
return groups;
}
StringTokenizer tokenizer = new StringTokenizer(result, ShellUtils.TOKEN_SEPARATOR_REGEX);
while (tokenizer.hasMoreTokens()) {
groups.add(tokenizer.nextToken());
}
return groups;
}
|
[
"public",
"static",
"List",
"<",
"String",
">",
"getUnixGroups",
"(",
"String",
"user",
")",
"throws",
"IOException",
"{",
"String",
"result",
";",
"List",
"<",
"String",
">",
"groups",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"try",
"{",
"result",
"=",
"ShellUtils",
".",
"execCommand",
"(",
"ShellUtils",
".",
"getGroupsForUserCommand",
"(",
"user",
")",
")",
";",
"}",
"catch",
"(",
"ExitCodeException",
"e",
")",
"{",
"// if we didn't get the group - just return empty list",
"LOG",
".",
"warn",
"(",
"\"got exception trying to get groups for user \"",
"+",
"user",
"+",
"\": \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"groups",
";",
"}",
"StringTokenizer",
"tokenizer",
"=",
"new",
"StringTokenizer",
"(",
"result",
",",
"ShellUtils",
".",
"TOKEN_SEPARATOR_REGEX",
")",
";",
"while",
"(",
"tokenizer",
".",
"hasMoreTokens",
"(",
")",
")",
"{",
"groups",
".",
"add",
"(",
"tokenizer",
".",
"nextToken",
"(",
")",
")",
";",
"}",
"return",
"groups",
";",
"}"
] |
Gets the current user's group list from Unix by running the command 'groups' NOTE. For
non-existing user it will return EMPTY list. This method may return duplicate groups.
@param user user name
@return the groups list that the {@code user} belongs to. The primary group is returned first
|
[
"Gets",
"the",
"current",
"user",
"s",
"group",
"list",
"from",
"Unix",
"by",
"running",
"the",
"command",
"groups",
"NOTE",
".",
"For",
"non",
"-",
"existing",
"user",
"it",
"will",
"return",
"EMPTY",
"list",
".",
"This",
"method",
"may",
"return",
"duplicate",
"groups",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L246-L262
|
18,655
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/CommonUtils.java
|
CommonUtils.waitForResult
|
public static <T> T waitForResult(String description, Supplier<T> operation,
WaitForOptions options) throws InterruptedException, TimeoutException {
T t;
long start = System.currentTimeMillis();
int interval = options.getInterval();
int timeout = options.getTimeoutMs();
while ((t = operation.get()) == null) {
if (timeout != WaitForOptions.NEVER && System.currentTimeMillis() - start > timeout) {
throw new TimeoutException("Timed out waiting for " + description + " options: " + options);
}
Thread.sleep(interval);
}
return t;
}
|
java
|
public static <T> T waitForResult(String description, Supplier<T> operation,
WaitForOptions options) throws InterruptedException, TimeoutException {
T t;
long start = System.currentTimeMillis();
int interval = options.getInterval();
int timeout = options.getTimeoutMs();
while ((t = operation.get()) == null) {
if (timeout != WaitForOptions.NEVER && System.currentTimeMillis() - start > timeout) {
throw new TimeoutException("Timed out waiting for " + description + " options: " + options);
}
Thread.sleep(interval);
}
return t;
}
|
[
"public",
"static",
"<",
"T",
">",
"T",
"waitForResult",
"(",
"String",
"description",
",",
"Supplier",
"<",
"T",
">",
"operation",
",",
"WaitForOptions",
"options",
")",
"throws",
"InterruptedException",
",",
"TimeoutException",
"{",
"T",
"t",
";",
"long",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"int",
"interval",
"=",
"options",
".",
"getInterval",
"(",
")",
";",
"int",
"timeout",
"=",
"options",
".",
"getTimeoutMs",
"(",
")",
";",
"while",
"(",
"(",
"t",
"=",
"operation",
".",
"get",
"(",
")",
")",
"==",
"null",
")",
"{",
"if",
"(",
"timeout",
"!=",
"WaitForOptions",
".",
"NEVER",
"&&",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"start",
">",
"timeout",
")",
"{",
"throw",
"new",
"TimeoutException",
"(",
"\"Timed out waiting for \"",
"+",
"description",
"+",
"\" options: \"",
"+",
"options",
")",
";",
"}",
"Thread",
".",
"sleep",
"(",
"interval",
")",
";",
"}",
"return",
"t",
";",
"}"
] |
Waits for an operation to return a non-null value with a specified timeout.
@param description the description of this operation
@param operation the operation
@param options the options to use
@param <T> the type of the return value
@throws TimeoutException if the function times out while waiting to get a non-null value
@return the first non-null value generated by the operation
|
[
"Waits",
"for",
"an",
"operation",
"to",
"return",
"a",
"non",
"-",
"null",
"value",
"with",
"a",
"specified",
"timeout",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L299-L312
|
18,656
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/CommonUtils.java
|
CommonUtils.getPrimaryGroupName
|
public static String getPrimaryGroupName(String userName, AlluxioConfiguration conf)
throws IOException {
List<String> groups = getGroups(userName, conf);
return (groups != null && groups.size() > 0) ? groups.get(0) : "";
}
|
java
|
public static String getPrimaryGroupName(String userName, AlluxioConfiguration conf)
throws IOException {
List<String> groups = getGroups(userName, conf);
return (groups != null && groups.size() > 0) ? groups.get(0) : "";
}
|
[
"public",
"static",
"String",
"getPrimaryGroupName",
"(",
"String",
"userName",
",",
"AlluxioConfiguration",
"conf",
")",
"throws",
"IOException",
"{",
"List",
"<",
"String",
">",
"groups",
"=",
"getGroups",
"(",
"userName",
",",
"conf",
")",
";",
"return",
"(",
"groups",
"!=",
"null",
"&&",
"groups",
".",
"size",
"(",
")",
">",
"0",
")",
"?",
"groups",
".",
"get",
"(",
"0",
")",
":",
"\"\"",
";",
"}"
] |
Gets the primary group name of a user.
@param userName Alluxio user name
@param conf Alluxio configuration
@return primary group name
|
[
"Gets",
"the",
"primary",
"group",
"name",
"of",
"a",
"user",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L321-L325
|
18,657
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/CommonUtils.java
|
CommonUtils.stripSuffixIfPresent
|
public static String stripSuffixIfPresent(final String key, final String suffix) {
if (key.endsWith(suffix)) {
return key.substring(0, key.length() - suffix.length());
}
return key;
}
|
java
|
public static String stripSuffixIfPresent(final String key, final String suffix) {
if (key.endsWith(suffix)) {
return key.substring(0, key.length() - suffix.length());
}
return key;
}
|
[
"public",
"static",
"String",
"stripSuffixIfPresent",
"(",
"final",
"String",
"key",
",",
"final",
"String",
"suffix",
")",
"{",
"if",
"(",
"key",
".",
"endsWith",
"(",
"suffix",
")",
")",
"{",
"return",
"key",
".",
"substring",
"(",
"0",
",",
"key",
".",
"length",
"(",
")",
"-",
"suffix",
".",
"length",
"(",
")",
")",
";",
"}",
"return",
"key",
";",
"}"
] |
Strips the suffix if it exists. This method will leave keys without a suffix unaltered.
@param key the key to strip the suffix from
@param suffix suffix to remove
@return the key with the suffix removed, or the key unaltered if the suffix is not present
|
[
"Strips",
"the",
"suffix",
"if",
"it",
"exists",
".",
"This",
"method",
"will",
"leave",
"keys",
"without",
"a",
"suffix",
"unaltered",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L347-L352
|
18,658
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/CommonUtils.java
|
CommonUtils.getRootCause
|
public static Throwable getRootCause(Throwable e) {
while (e.getCause() != null && !(e.getCause() instanceof StatusRuntimeException)) {
e = e.getCause();
}
return e;
}
|
java
|
public static Throwable getRootCause(Throwable e) {
while (e.getCause() != null && !(e.getCause() instanceof StatusRuntimeException)) {
e = e.getCause();
}
return e;
}
|
[
"public",
"static",
"Throwable",
"getRootCause",
"(",
"Throwable",
"e",
")",
"{",
"while",
"(",
"e",
".",
"getCause",
"(",
")",
"!=",
"null",
"&&",
"!",
"(",
"e",
".",
"getCause",
"(",
")",
"instanceof",
"StatusRuntimeException",
")",
")",
"{",
"e",
"=",
"e",
".",
"getCause",
"(",
")",
";",
"}",
"return",
"e",
";",
"}"
] |
Gets the root cause of an exception.
It stops at encountering gRPC's StatusRuntimeException.
@param e the exception
@return the root cause
|
[
"Gets",
"the",
"root",
"cause",
"of",
"an",
"exception",
".",
"It",
"stops",
"at",
"encountering",
"gRPC",
"s",
"StatusRuntimeException",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L411-L416
|
18,659
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/CommonUtils.java
|
CommonUtils.singleElementIterator
|
public static <T> Iterator<T> singleElementIterator(final T element) {
return new Iterator<T>() {
private boolean mHasNext = true;
@Override
public boolean hasNext() {
return mHasNext;
}
@Override
public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
mHasNext = false;
return element;
}
@Override
public void remove() {
throw new UnsupportedOperationException("remove is not supported.");
}
};
}
|
java
|
public static <T> Iterator<T> singleElementIterator(final T element) {
return new Iterator<T>() {
private boolean mHasNext = true;
@Override
public boolean hasNext() {
return mHasNext;
}
@Override
public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
mHasNext = false;
return element;
}
@Override
public void remove() {
throw new UnsupportedOperationException("remove is not supported.");
}
};
}
|
[
"public",
"static",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"singleElementIterator",
"(",
"final",
"T",
"element",
")",
"{",
"return",
"new",
"Iterator",
"<",
"T",
">",
"(",
")",
"{",
"private",
"boolean",
"mHasNext",
"=",
"true",
";",
"@",
"Override",
"public",
"boolean",
"hasNext",
"(",
")",
"{",
"return",
"mHasNext",
";",
"}",
"@",
"Override",
"public",
"T",
"next",
"(",
")",
"{",
"if",
"(",
"!",
"hasNext",
"(",
")",
")",
"{",
"throw",
"new",
"NoSuchElementException",
"(",
")",
";",
"}",
"mHasNext",
"=",
"false",
";",
"return",
"element",
";",
"}",
"@",
"Override",
"public",
"void",
"remove",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"remove is not supported.\"",
")",
";",
"}",
"}",
";",
"}"
] |
Returns an iterator that iterates on a single element.
@param element the element
@param <T> the type of the element
@return the iterator
|
[
"Returns",
"an",
"iterator",
"that",
"iterates",
"on",
"a",
"single",
"element",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L439-L462
|
18,660
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/CommonUtils.java
|
CommonUtils.closeAndRethrow
|
public static RuntimeException closeAndRethrow(Closer closer, Throwable t) throws IOException {
try {
throw closer.rethrow(t);
} finally {
closer.close();
}
}
|
java
|
public static RuntimeException closeAndRethrow(Closer closer, Throwable t) throws IOException {
try {
throw closer.rethrow(t);
} finally {
closer.close();
}
}
|
[
"public",
"static",
"RuntimeException",
"closeAndRethrow",
"(",
"Closer",
"closer",
",",
"Throwable",
"t",
")",
"throws",
"IOException",
"{",
"try",
"{",
"throw",
"closer",
".",
"rethrow",
"(",
"t",
")",
";",
"}",
"finally",
"{",
"closer",
".",
"close",
"(",
")",
";",
"}",
"}"
] |
Closes the Closer and re-throws the Throwable. Any exceptions thrown while closing the Closer
will be added as suppressed exceptions to the Throwable. This method always throws the given
Throwable, wrapping it in a RuntimeException if it's a non-IOException checked exception.
Note: This method will wrap non-IOExceptions in RuntimeException. Do not use this method in
methods which throw non-IOExceptions.
<pre>
Closer closer = new Closer();
try {
Closeable c = closer.register(new Closeable());
} catch (Throwable t) {
throw closeAndRethrow(closer, t);
}
</pre>
@param closer the Closer to close
@param t the Throwable to re-throw
@return this method never returns
|
[
"Closes",
"the",
"Closer",
"and",
"re",
"-",
"throws",
"the",
"Throwable",
".",
"Any",
"exceptions",
"thrown",
"while",
"closing",
"the",
"Closer",
"will",
"be",
"added",
"as",
"suppressed",
"exceptions",
"to",
"the",
"Throwable",
".",
"This",
"method",
"always",
"throws",
"the",
"given",
"Throwable",
"wrapping",
"it",
"in",
"a",
"RuntimeException",
"if",
"it",
"s",
"a",
"non",
"-",
"IOException",
"checked",
"exception",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L536-L542
|
18,661
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/CommonUtils.java
|
CommonUtils.convertMsToDate
|
public static String convertMsToDate(long millis, String dateFormatPattern) {
DateFormat dateFormat = new SimpleDateFormat(dateFormatPattern);
return dateFormat.format(new Date(millis));
}
|
java
|
public static String convertMsToDate(long millis, String dateFormatPattern) {
DateFormat dateFormat = new SimpleDateFormat(dateFormatPattern);
return dateFormat.format(new Date(millis));
}
|
[
"public",
"static",
"String",
"convertMsToDate",
"(",
"long",
"millis",
",",
"String",
"dateFormatPattern",
")",
"{",
"DateFormat",
"dateFormat",
"=",
"new",
"SimpleDateFormat",
"(",
"dateFormatPattern",
")",
";",
"return",
"dateFormat",
".",
"format",
"(",
"new",
"Date",
"(",
"millis",
")",
")",
";",
"}"
] |
Converts a millisecond number to a formatted date String.
@param millis a long millisecond number
@param dateFormatPattern the date format to follow when converting. i.e. mm-dd-yyyy
@return formatted date String
|
[
"Converts",
"a",
"millisecond",
"number",
"to",
"a",
"formatted",
"date",
"String",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/CommonUtils.java#L606-L609
|
18,662
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/underfs/Fingerprint.java
|
Fingerprint.createTags
|
private static Map<Tag, String> createTags(String ufsName, UfsStatus status) {
Map<Tag, String> tagMap = new HashMap<>();
tagMap.put(Tag.UFS, ufsName);
tagMap.put(Tag.OWNER, status.getOwner());
tagMap.put(Tag.GROUP, status.getGroup());
tagMap.put(Tag.MODE, String.valueOf(status.getMode()));
if (status instanceof UfsFileStatus) {
tagMap.put(Tag.TYPE, Type.FILE.name());
tagMap.put(Tag.CONTENT_HASH, ((UfsFileStatus) status).getContentHash());
} else {
tagMap.put(Tag.TYPE, Type.DIRECTORY.name());
}
return tagMap;
}
|
java
|
private static Map<Tag, String> createTags(String ufsName, UfsStatus status) {
Map<Tag, String> tagMap = new HashMap<>();
tagMap.put(Tag.UFS, ufsName);
tagMap.put(Tag.OWNER, status.getOwner());
tagMap.put(Tag.GROUP, status.getGroup());
tagMap.put(Tag.MODE, String.valueOf(status.getMode()));
if (status instanceof UfsFileStatus) {
tagMap.put(Tag.TYPE, Type.FILE.name());
tagMap.put(Tag.CONTENT_HASH, ((UfsFileStatus) status).getContentHash());
} else {
tagMap.put(Tag.TYPE, Type.DIRECTORY.name());
}
return tagMap;
}
|
[
"private",
"static",
"Map",
"<",
"Tag",
",",
"String",
">",
"createTags",
"(",
"String",
"ufsName",
",",
"UfsStatus",
"status",
")",
"{",
"Map",
"<",
"Tag",
",",
"String",
">",
"tagMap",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"tagMap",
".",
"put",
"(",
"Tag",
".",
"UFS",
",",
"ufsName",
")",
";",
"tagMap",
".",
"put",
"(",
"Tag",
".",
"OWNER",
",",
"status",
".",
"getOwner",
"(",
")",
")",
";",
"tagMap",
".",
"put",
"(",
"Tag",
".",
"GROUP",
",",
"status",
".",
"getGroup",
"(",
")",
")",
";",
"tagMap",
".",
"put",
"(",
"Tag",
".",
"MODE",
",",
"String",
".",
"valueOf",
"(",
"status",
".",
"getMode",
"(",
")",
")",
")",
";",
"if",
"(",
"status",
"instanceof",
"UfsFileStatus",
")",
"{",
"tagMap",
".",
"put",
"(",
"Tag",
".",
"TYPE",
",",
"Type",
".",
"FILE",
".",
"name",
"(",
")",
")",
";",
"tagMap",
".",
"put",
"(",
"Tag",
".",
"CONTENT_HASH",
",",
"(",
"(",
"UfsFileStatus",
")",
"status",
")",
".",
"getContentHash",
"(",
")",
")",
";",
"}",
"else",
"{",
"tagMap",
".",
"put",
"(",
"Tag",
".",
"TYPE",
",",
"Type",
".",
"DIRECTORY",
".",
"name",
"(",
")",
")",
";",
"}",
"return",
"tagMap",
";",
"}"
] |
Parses the input status and returns a tag map.
@param ufsName the name of the ufs, should be {@link UnderFileSystem#getUnderFSType()}
@param status the {@link UfsStatus} to create the tagmap from
@return the tag map object
|
[
"Parses",
"the",
"input",
"status",
"and",
"returns",
"a",
"tag",
"map",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/underfs/Fingerprint.java#L113-L126
|
18,663
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/underfs/Fingerprint.java
|
Fingerprint.isValid
|
public boolean isValid() {
if (mValues.isEmpty()) {
return false;
}
// Check required tags
for (Tag tag : REQUIRED_TAGS) {
if (!mValues.containsKey(tag)) {
return false;
}
}
return true;
}
|
java
|
public boolean isValid() {
if (mValues.isEmpty()) {
return false;
}
// Check required tags
for (Tag tag : REQUIRED_TAGS) {
if (!mValues.containsKey(tag)) {
return false;
}
}
return true;
}
|
[
"public",
"boolean",
"isValid",
"(",
")",
"{",
"if",
"(",
"mValues",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Check required tags",
"for",
"(",
"Tag",
"tag",
":",
"REQUIRED_TAGS",
")",
"{",
"if",
"(",
"!",
"mValues",
".",
"containsKey",
"(",
"tag",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Checks if the fingerprint object was generated from an INVALID_UFS_FINGERPRINT.
@return returns true if the fingerprint is valid
|
[
"Checks",
"if",
"the",
"fingerprint",
"object",
"was",
"generated",
"from",
"an",
"INVALID_UFS_FINGERPRINT",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/underfs/Fingerprint.java#L165-L178
|
18,664
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/underfs/Fingerprint.java
|
Fingerprint.matchMetadata
|
public boolean matchMetadata(Fingerprint fp) {
for (Tag tag : METADATA_TAGS) {
if (!getTag(tag).equals(fp.getTag(tag))) {
return false;
}
}
return true;
}
|
java
|
public boolean matchMetadata(Fingerprint fp) {
for (Tag tag : METADATA_TAGS) {
if (!getTag(tag).equals(fp.getTag(tag))) {
return false;
}
}
return true;
}
|
[
"public",
"boolean",
"matchMetadata",
"(",
"Fingerprint",
"fp",
")",
"{",
"for",
"(",
"Tag",
"tag",
":",
"METADATA_TAGS",
")",
"{",
"if",
"(",
"!",
"getTag",
"(",
"tag",
")",
".",
"equals",
"(",
"fp",
".",
"getTag",
"(",
"tag",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Returns true if the serialized fingerprint matches the fingerprint in metadata.
@param fp a parsed fingerprint object
@return true if the given fingerprint matches the current fingerprint in metadata
|
[
"Returns",
"true",
"if",
"the",
"serialized",
"fingerprint",
"matches",
"the",
"fingerprint",
"in",
"metadata",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/underfs/Fingerprint.java#L207-L214
|
18,665
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/underfs/Fingerprint.java
|
Fingerprint.matchContent
|
public boolean matchContent(Fingerprint fp) {
for (Tag tag : CONTENT_TAGS) {
if (!getTag(tag).equals(fp.getTag(tag))) {
return false;
}
}
return true;
}
|
java
|
public boolean matchContent(Fingerprint fp) {
for (Tag tag : CONTENT_TAGS) {
if (!getTag(tag).equals(fp.getTag(tag))) {
return false;
}
}
return true;
}
|
[
"public",
"boolean",
"matchContent",
"(",
"Fingerprint",
"fp",
")",
"{",
"for",
"(",
"Tag",
"tag",
":",
"CONTENT_TAGS",
")",
"{",
"if",
"(",
"!",
"getTag",
"(",
"tag",
")",
".",
"equals",
"(",
"fp",
".",
"getTag",
"(",
"tag",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Returns true if the serialized fingerprint matches the fingerprint in the content part.
@param fp a parsed fingerprint object
@return true if the given fingerprint matches the current fingerprint's content
|
[
"Returns",
"true",
"if",
"the",
"serialized",
"fingerprint",
"matches",
"the",
"fingerprint",
"in",
"the",
"content",
"part",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/underfs/Fingerprint.java#L222-L229
|
18,666
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/underfs/Fingerprint.java
|
Fingerprint.putTag
|
public void putTag(Tag tag, String value) {
if (value != null) {
mValues.put(tag, sanitizeString(value));
}
}
|
java
|
public void putTag(Tag tag, String value) {
if (value != null) {
mValues.put(tag, sanitizeString(value));
}
}
|
[
"public",
"void",
"putTag",
"(",
"Tag",
"tag",
",",
"String",
"value",
")",
"{",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"mValues",
".",
"put",
"(",
"tag",
",",
"sanitizeString",
"(",
"value",
")",
")",
";",
"}",
"}"
] |
Updates a specific tag in the fingerprint. If the new value is null, the fingerprint is kept
unchanged.
@param tag the tag to update
@param value the new value of the tag
|
[
"Updates",
"a",
"specific",
"tag",
"in",
"the",
"fingerprint",
".",
"If",
"the",
"new",
"value",
"is",
"null",
"the",
"fingerprint",
"is",
"kept",
"unchanged",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/underfs/Fingerprint.java#L238-L242
|
18,667
|
Alluxio/alluxio
|
underfs/s3a/src/main/java/alluxio/underfs/s3a/S3AInputStream.java
|
S3AInputStream.openStream
|
private void openStream() throws IOException {
if (mIn != null) { // stream is already open
return;
}
GetObjectRequest getReq = new GetObjectRequest(mBucketName, mKey);
// If the position is 0, setting range is redundant and causes an error if the file is 0 length
if (mPos > 0) {
getReq.setRange(mPos);
}
AmazonS3Exception lastException = null;
while (mRetryPolicy.attempt()) {
try {
mIn = mClient.getObject(getReq).getObjectContent();
return;
} catch (AmazonS3Exception e) {
LOG.warn("Attempt {} to open key {} in bucket {} failed with exception : {}",
mRetryPolicy.getAttemptCount(), mKey, mBucketName, e.toString());
if (e.getStatusCode() != HttpStatus.SC_NOT_FOUND) {
throw new IOException(e);
}
// Key does not exist
lastException = e;
}
}
// Failed after retrying key does not exist
throw new IOException(lastException);
}
|
java
|
private void openStream() throws IOException {
if (mIn != null) { // stream is already open
return;
}
GetObjectRequest getReq = new GetObjectRequest(mBucketName, mKey);
// If the position is 0, setting range is redundant and causes an error if the file is 0 length
if (mPos > 0) {
getReq.setRange(mPos);
}
AmazonS3Exception lastException = null;
while (mRetryPolicy.attempt()) {
try {
mIn = mClient.getObject(getReq).getObjectContent();
return;
} catch (AmazonS3Exception e) {
LOG.warn("Attempt {} to open key {} in bucket {} failed with exception : {}",
mRetryPolicy.getAttemptCount(), mKey, mBucketName, e.toString());
if (e.getStatusCode() != HttpStatus.SC_NOT_FOUND) {
throw new IOException(e);
}
// Key does not exist
lastException = e;
}
}
// Failed after retrying key does not exist
throw new IOException(lastException);
}
|
[
"private",
"void",
"openStream",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mIn",
"!=",
"null",
")",
"{",
"// stream is already open",
"return",
";",
"}",
"GetObjectRequest",
"getReq",
"=",
"new",
"GetObjectRequest",
"(",
"mBucketName",
",",
"mKey",
")",
";",
"// If the position is 0, setting range is redundant and causes an error if the file is 0 length",
"if",
"(",
"mPos",
">",
"0",
")",
"{",
"getReq",
".",
"setRange",
"(",
"mPos",
")",
";",
"}",
"AmazonS3Exception",
"lastException",
"=",
"null",
";",
"while",
"(",
"mRetryPolicy",
".",
"attempt",
"(",
")",
")",
"{",
"try",
"{",
"mIn",
"=",
"mClient",
".",
"getObject",
"(",
"getReq",
")",
".",
"getObjectContent",
"(",
")",
";",
"return",
";",
"}",
"catch",
"(",
"AmazonS3Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Attempt {} to open key {} in bucket {} failed with exception : {}\"",
",",
"mRetryPolicy",
".",
"getAttemptCount",
"(",
")",
",",
"mKey",
",",
"mBucketName",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"e",
".",
"getStatusCode",
"(",
")",
"!=",
"HttpStatus",
".",
"SC_NOT_FOUND",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
")",
";",
"}",
"// Key does not exist",
"lastException",
"=",
"e",
";",
"}",
"}",
"// Failed after retrying key does not exist",
"throw",
"new",
"IOException",
"(",
"lastException",
")",
";",
"}"
] |
Opens a new stream at mPos if the wrapped stream mIn is null.
|
[
"Opens",
"a",
"new",
"stream",
"at",
"mPos",
"if",
"the",
"wrapped",
"stream",
"mIn",
"is",
"null",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/underfs/s3a/src/main/java/alluxio/underfs/s3a/S3AInputStream.java#L136-L162
|
18,668
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/DirectedAcyclicGraphNode.java
|
DirectedAcyclicGraphNode.removeChild
|
public void removeChild(DirectedAcyclicGraphNode<T> child) {
Preconditions.checkState(mChildren.contains(child));
mChildren.remove(child);
}
|
java
|
public void removeChild(DirectedAcyclicGraphNode<T> child) {
Preconditions.checkState(mChildren.contains(child));
mChildren.remove(child);
}
|
[
"public",
"void",
"removeChild",
"(",
"DirectedAcyclicGraphNode",
"<",
"T",
">",
"child",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"mChildren",
".",
"contains",
"(",
"child",
")",
")",
";",
"mChildren",
".",
"remove",
"(",
"child",
")",
";",
"}"
] |
Removes a child node from the node.
@param child the child node to be removed
|
[
"Removes",
"a",
"child",
"node",
"from",
"the",
"node",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/DirectedAcyclicGraphNode.java#L106-L109
|
18,669
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/security/authorization/AccessControlList.java
|
AccessControlList.setEntry
|
public void setEntry(AclEntry entry) {
switch (entry.getType()) {
case NAMED_USER: // fall through
case NAMED_GROUP: // fall through
case MASK:
if (mExtendedEntries == null) {
mExtendedEntries = new ExtendedACLEntries();
}
mExtendedEntries.setEntry(entry);
return;
case OWNING_USER:
Mode modeOwner = new Mode(mMode);
modeOwner.setOwnerBits(entry.getActions().toModeBits());
mMode = modeOwner.toShort();
return;
case OWNING_GROUP:
Mode modeGroup = new Mode(mMode);
modeGroup.setGroupBits(entry.getActions().toModeBits());
mMode = modeGroup.toShort();
return;
case OTHER:
Mode modeOther = new Mode(mMode);
modeOther.setOtherBits(entry.getActions().toModeBits());
mMode = modeOther.toShort();
return;
default:
throw new IllegalStateException("Unknown ACL entry type: " + entry.getType());
}
}
|
java
|
public void setEntry(AclEntry entry) {
switch (entry.getType()) {
case NAMED_USER: // fall through
case NAMED_GROUP: // fall through
case MASK:
if (mExtendedEntries == null) {
mExtendedEntries = new ExtendedACLEntries();
}
mExtendedEntries.setEntry(entry);
return;
case OWNING_USER:
Mode modeOwner = new Mode(mMode);
modeOwner.setOwnerBits(entry.getActions().toModeBits());
mMode = modeOwner.toShort();
return;
case OWNING_GROUP:
Mode modeGroup = new Mode(mMode);
modeGroup.setGroupBits(entry.getActions().toModeBits());
mMode = modeGroup.toShort();
return;
case OTHER:
Mode modeOther = new Mode(mMode);
modeOther.setOtherBits(entry.getActions().toModeBits());
mMode = modeOther.toShort();
return;
default:
throw new IllegalStateException("Unknown ACL entry type: " + entry.getType());
}
}
|
[
"public",
"void",
"setEntry",
"(",
"AclEntry",
"entry",
")",
"{",
"switch",
"(",
"entry",
".",
"getType",
"(",
")",
")",
"{",
"case",
"NAMED_USER",
":",
"// fall through",
"case",
"NAMED_GROUP",
":",
"// fall through",
"case",
"MASK",
":",
"if",
"(",
"mExtendedEntries",
"==",
"null",
")",
"{",
"mExtendedEntries",
"=",
"new",
"ExtendedACLEntries",
"(",
")",
";",
"}",
"mExtendedEntries",
".",
"setEntry",
"(",
"entry",
")",
";",
"return",
";",
"case",
"OWNING_USER",
":",
"Mode",
"modeOwner",
"=",
"new",
"Mode",
"(",
"mMode",
")",
";",
"modeOwner",
".",
"setOwnerBits",
"(",
"entry",
".",
"getActions",
"(",
")",
".",
"toModeBits",
"(",
")",
")",
";",
"mMode",
"=",
"modeOwner",
".",
"toShort",
"(",
")",
";",
"return",
";",
"case",
"OWNING_GROUP",
":",
"Mode",
"modeGroup",
"=",
"new",
"Mode",
"(",
"mMode",
")",
";",
"modeGroup",
".",
"setGroupBits",
"(",
"entry",
".",
"getActions",
"(",
")",
".",
"toModeBits",
"(",
")",
")",
";",
"mMode",
"=",
"modeGroup",
".",
"toShort",
"(",
")",
";",
"return",
";",
"case",
"OTHER",
":",
"Mode",
"modeOther",
"=",
"new",
"Mode",
"(",
"mMode",
")",
";",
"modeOther",
".",
"setOtherBits",
"(",
"entry",
".",
"getActions",
"(",
")",
".",
"toModeBits",
"(",
")",
")",
";",
"mMode",
"=",
"modeOther",
".",
"toShort",
"(",
")",
";",
"return",
";",
"default",
":",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unknown ACL entry type: \"",
"+",
"entry",
".",
"getType",
"(",
")",
")",
";",
"}",
"}"
] |
Sets an entry into the access control list.
If an entry with the same type and subject already exists, overwrites the existing entry;
Otherwise, adds this new entry.
After we modify entries for NAMED_GROUP, OWNING_GROUP, NAMED_USER, we need to update the mask.
@param entry the entry to be added or updated
|
[
"Sets",
"an",
"entry",
"into",
"the",
"access",
"control",
"list",
".",
"If",
"an",
"entry",
"with",
"the",
"same",
"type",
"and",
"subject",
"already",
"exists",
"overwrites",
"the",
"existing",
"entry",
";",
"Otherwise",
"adds",
"this",
"new",
"entry",
".",
"After",
"we",
"modify",
"entries",
"for",
"NAMED_GROUP",
"OWNING_GROUP",
"NAMED_USER",
"we",
"need",
"to",
"update",
"the",
"mask",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/security/authorization/AccessControlList.java#L260-L288
|
18,670
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/security/authorization/AccessControlList.java
|
AccessControlList.checkPermission
|
public boolean checkPermission(String user, List<String> groups, AclAction action) {
return getPermission(user, groups).contains(action);
}
|
java
|
public boolean checkPermission(String user, List<String> groups, AclAction action) {
return getPermission(user, groups).contains(action);
}
|
[
"public",
"boolean",
"checkPermission",
"(",
"String",
"user",
",",
"List",
"<",
"String",
">",
"groups",
",",
"AclAction",
"action",
")",
"{",
"return",
"getPermission",
"(",
"user",
",",
"groups",
")",
".",
"contains",
"(",
"action",
")",
";",
"}"
] |
Checks whether the user has the permission to perform the action.
1. If the user is the owner, then the owner entry determines the permission;
2. Else if the user matches the name of one of the named user entries, this entry determines
the permission;
3. Else if one of the groups is the owning group and the owning group entry contains the
requested permission, the permission is granted;
4. Else if one of the groups matches the name of one of the named group entries and this entry
contains the requested permission, the permission is granted;
5. Else if one of the groups is the owning group or matches the name of one of the named group
entries, but neither the owning group entry nor any of the matching named group entries
contains the requested permission, the permission is denied;
6. Otherwise, the other entry determines the permission.
@param user the user
@param groups the groups the user belongs to
@param action the action
@return whether user has the permission to perform the action
|
[
"Checks",
"whether",
"the",
"user",
"has",
"the",
"permission",
"to",
"perform",
"the",
"action",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/security/authorization/AccessControlList.java#L310-L312
|
18,671
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/security/authorization/AccessControlList.java
|
AccessControlList.getPermission
|
public AclActions getPermission(String user, List<String> groups) {
if (user.equals(mOwningUser)) {
return new AclActions(getOwningUserActions());
}
if (hasExtended()) {
AclActions actions = mExtendedEntries.getNamedUser(user);
if (actions != null) {
AclActions result = new AclActions(actions);
result.mask(mExtendedEntries.mMaskActions);
return result;
}
}
boolean isGroupKnown = false;
AclActions groupActions = new AclActions();
if (groups.contains(mOwningGroup)) {
isGroupKnown = true;
groupActions.merge(getOwningGroupActions());
}
if (hasExtended()) {
for (String group : groups) {
AclActions actions = mExtendedEntries.getNamedGroup(group);
if (actions != null) {
isGroupKnown = true;
groupActions.merge(actions);
}
}
}
if (isGroupKnown) {
if (hasExtended()) {
groupActions.mask(mExtendedEntries.mMaskActions);
}
return groupActions;
}
return getOtherActions();
}
|
java
|
public AclActions getPermission(String user, List<String> groups) {
if (user.equals(mOwningUser)) {
return new AclActions(getOwningUserActions());
}
if (hasExtended()) {
AclActions actions = mExtendedEntries.getNamedUser(user);
if (actions != null) {
AclActions result = new AclActions(actions);
result.mask(mExtendedEntries.mMaskActions);
return result;
}
}
boolean isGroupKnown = false;
AclActions groupActions = new AclActions();
if (groups.contains(mOwningGroup)) {
isGroupKnown = true;
groupActions.merge(getOwningGroupActions());
}
if (hasExtended()) {
for (String group : groups) {
AclActions actions = mExtendedEntries.getNamedGroup(group);
if (actions != null) {
isGroupKnown = true;
groupActions.merge(actions);
}
}
}
if (isGroupKnown) {
if (hasExtended()) {
groupActions.mask(mExtendedEntries.mMaskActions);
}
return groupActions;
}
return getOtherActions();
}
|
[
"public",
"AclActions",
"getPermission",
"(",
"String",
"user",
",",
"List",
"<",
"String",
">",
"groups",
")",
"{",
"if",
"(",
"user",
".",
"equals",
"(",
"mOwningUser",
")",
")",
"{",
"return",
"new",
"AclActions",
"(",
"getOwningUserActions",
"(",
")",
")",
";",
"}",
"if",
"(",
"hasExtended",
"(",
")",
")",
"{",
"AclActions",
"actions",
"=",
"mExtendedEntries",
".",
"getNamedUser",
"(",
"user",
")",
";",
"if",
"(",
"actions",
"!=",
"null",
")",
"{",
"AclActions",
"result",
"=",
"new",
"AclActions",
"(",
"actions",
")",
";",
"result",
".",
"mask",
"(",
"mExtendedEntries",
".",
"mMaskActions",
")",
";",
"return",
"result",
";",
"}",
"}",
"boolean",
"isGroupKnown",
"=",
"false",
";",
"AclActions",
"groupActions",
"=",
"new",
"AclActions",
"(",
")",
";",
"if",
"(",
"groups",
".",
"contains",
"(",
"mOwningGroup",
")",
")",
"{",
"isGroupKnown",
"=",
"true",
";",
"groupActions",
".",
"merge",
"(",
"getOwningGroupActions",
"(",
")",
")",
";",
"}",
"if",
"(",
"hasExtended",
"(",
")",
")",
"{",
"for",
"(",
"String",
"group",
":",
"groups",
")",
"{",
"AclActions",
"actions",
"=",
"mExtendedEntries",
".",
"getNamedGroup",
"(",
"group",
")",
";",
"if",
"(",
"actions",
"!=",
"null",
")",
"{",
"isGroupKnown",
"=",
"true",
";",
"groupActions",
".",
"merge",
"(",
"actions",
")",
";",
"}",
"}",
"}",
"if",
"(",
"isGroupKnown",
")",
"{",
"if",
"(",
"hasExtended",
"(",
")",
")",
"{",
"groupActions",
".",
"mask",
"(",
"mExtendedEntries",
".",
"mMaskActions",
")",
";",
"}",
"return",
"groupActions",
";",
"}",
"return",
"getOtherActions",
"(",
")",
";",
"}"
] |
Gets the permitted actions for a user.
When AccessControlList is not modified after calling getPermission,
for each action returned by this method, checkPermission(user, groups, action) is true,
for other actions, checkPermission(user, groups, action) is false.
1. If the user is the owner, then return the permission in the owner entry;
2. Else if the user matches the name of one of the named user entries, then return the AND
result of the permission in this entry and the mask ;
3. Else if at least one of the groups is the owning group or matches the name of one of the
named group entries, then for the named group entries that match a member of groups, merge
the permissions in these entries and return the merged permission ANDed with the mask;
4. Otherwise, return the permission in the other entry.
@param user the user
@param groups the groups the user belongs to
@return the permitted actions
|
[
"Gets",
"the",
"permitted",
"actions",
"for",
"a",
"user",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/security/authorization/AccessControlList.java#L333-L369
|
18,672
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/security/authorization/AccessControlList.java
|
AccessControlList.fromStringEntries
|
public static AccessControlList fromStringEntries(String owner, String owningGroup,
List<String> stringEntries) {
AccessControlList acl;
if (stringEntries.size() > 0) {
AclEntry aclEntry = AclEntry.fromCliString(stringEntries.get(0));
if (aclEntry.isDefault()) {
acl = new DefaultAccessControlList();
} else {
acl = new AccessControlList();
}
} else {
// when the stringEntries size is 0, it can only be a DefaultAccessControlList
acl = new DefaultAccessControlList();
}
acl.setOwningUser(owner);
acl.setOwningGroup(owningGroup);
for (String stringEntry : stringEntries) {
AclEntry aclEntry = AclEntry.fromCliString(stringEntry);
acl.setEntry(aclEntry);
}
return acl;
}
|
java
|
public static AccessControlList fromStringEntries(String owner, String owningGroup,
List<String> stringEntries) {
AccessControlList acl;
if (stringEntries.size() > 0) {
AclEntry aclEntry = AclEntry.fromCliString(stringEntries.get(0));
if (aclEntry.isDefault()) {
acl = new DefaultAccessControlList();
} else {
acl = new AccessControlList();
}
} else {
// when the stringEntries size is 0, it can only be a DefaultAccessControlList
acl = new DefaultAccessControlList();
}
acl.setOwningUser(owner);
acl.setOwningGroup(owningGroup);
for (String stringEntry : stringEntries) {
AclEntry aclEntry = AclEntry.fromCliString(stringEntry);
acl.setEntry(aclEntry);
}
return acl;
}
|
[
"public",
"static",
"AccessControlList",
"fromStringEntries",
"(",
"String",
"owner",
",",
"String",
"owningGroup",
",",
"List",
"<",
"String",
">",
"stringEntries",
")",
"{",
"AccessControlList",
"acl",
";",
"if",
"(",
"stringEntries",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"AclEntry",
"aclEntry",
"=",
"AclEntry",
".",
"fromCliString",
"(",
"stringEntries",
".",
"get",
"(",
"0",
")",
")",
";",
"if",
"(",
"aclEntry",
".",
"isDefault",
"(",
")",
")",
"{",
"acl",
"=",
"new",
"DefaultAccessControlList",
"(",
")",
";",
"}",
"else",
"{",
"acl",
"=",
"new",
"AccessControlList",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// when the stringEntries size is 0, it can only be a DefaultAccessControlList",
"acl",
"=",
"new",
"DefaultAccessControlList",
"(",
")",
";",
"}",
"acl",
".",
"setOwningUser",
"(",
"owner",
")",
";",
"acl",
".",
"setOwningGroup",
"(",
"owningGroup",
")",
";",
"for",
"(",
"String",
"stringEntry",
":",
"stringEntries",
")",
"{",
"AclEntry",
"aclEntry",
"=",
"AclEntry",
".",
"fromCliString",
"(",
"stringEntry",
")",
";",
"acl",
".",
"setEntry",
"(",
"aclEntry",
")",
";",
"}",
"return",
"acl",
";",
"}"
] |
Converts a list of string entries into an AccessControlList or a DefaultAccessControlList.
It assumes the stringEntries contain all default entries or normal entries.
@param owner the owner
@param owningGroup the owning group
@param stringEntries the list of string representations of the entries
@return the {@link AccessControlList} instance
|
[
"Converts",
"a",
"list",
"of",
"string",
"entries",
"into",
"an",
"AccessControlList",
"or",
"a",
"DefaultAccessControlList",
".",
"It",
"assumes",
"the",
"stringEntries",
"contain",
"all",
"default",
"entries",
"or",
"normal",
"entries",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/security/authorization/AccessControlList.java#L412-L434
|
18,673
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/IndexedSet.java
|
IndexedSet.contains
|
public <V> boolean contains(IndexDefinition<T, V> indexDefinition, V value) {
FieldIndex<T, V> index = (FieldIndex<T, V>) mIndices.get(indexDefinition);
if (index == null) {
throw new IllegalStateException("the given index isn't defined for this IndexedSet");
}
return index.containsField(value);
}
|
java
|
public <V> boolean contains(IndexDefinition<T, V> indexDefinition, V value) {
FieldIndex<T, V> index = (FieldIndex<T, V>) mIndices.get(indexDefinition);
if (index == null) {
throw new IllegalStateException("the given index isn't defined for this IndexedSet");
}
return index.containsField(value);
}
|
[
"public",
"<",
"V",
">",
"boolean",
"contains",
"(",
"IndexDefinition",
"<",
"T",
",",
"V",
">",
"indexDefinition",
",",
"V",
"value",
")",
"{",
"FieldIndex",
"<",
"T",
",",
"V",
">",
"index",
"=",
"(",
"FieldIndex",
"<",
"T",
",",
"V",
">",
")",
"mIndices",
".",
"get",
"(",
"indexDefinition",
")",
";",
"if",
"(",
"index",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"the given index isn't defined for this IndexedSet\"",
")",
";",
"}",
"return",
"index",
".",
"containsField",
"(",
"value",
")",
";",
"}"
] |
Whether there is an object with the specified index field value in the set.
@param indexDefinition the field index definition
@param value the field value
@param <V> the field type
@return true if there is one such object, otherwise false
|
[
"Whether",
"there",
"is",
"an",
"object",
"with",
"the",
"specified",
"index",
"field",
"value",
"in",
"the",
"set",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/IndexedSet.java#L247-L253
|
18,674
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/IndexedSet.java
|
IndexedSet.getByField
|
public <V> Set<T> getByField(IndexDefinition<T, V> indexDefinition, V value) {
FieldIndex<T, V> index = (FieldIndex<T, V>) mIndices.get(indexDefinition);
if (index == null) {
throw new IllegalStateException("the given index isn't defined for this IndexedSet");
}
return index.getByField(value);
}
|
java
|
public <V> Set<T> getByField(IndexDefinition<T, V> indexDefinition, V value) {
FieldIndex<T, V> index = (FieldIndex<T, V>) mIndices.get(indexDefinition);
if (index == null) {
throw new IllegalStateException("the given index isn't defined for this IndexedSet");
}
return index.getByField(value);
}
|
[
"public",
"<",
"V",
">",
"Set",
"<",
"T",
">",
"getByField",
"(",
"IndexDefinition",
"<",
"T",
",",
"V",
">",
"indexDefinition",
",",
"V",
"value",
")",
"{",
"FieldIndex",
"<",
"T",
",",
"V",
">",
"index",
"=",
"(",
"FieldIndex",
"<",
"T",
",",
"V",
">",
")",
"mIndices",
".",
"get",
"(",
"indexDefinition",
")",
";",
"if",
"(",
"index",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"the given index isn't defined for this IndexedSet\"",
")",
";",
"}",
"return",
"index",
".",
"getByField",
"(",
"value",
")",
";",
"}"
] |
Gets a subset of objects with the specified field value. If there is no object with the
specified field value, a newly created empty set is returned.
@param indexDefinition the field index definition
@param value the field value to be satisfied
@param <V> the field type
@return the set of objects or an empty set if no such object exists
|
[
"Gets",
"a",
"subset",
"of",
"objects",
"with",
"the",
"specified",
"field",
"value",
".",
"If",
"there",
"is",
"no",
"object",
"with",
"the",
"specified",
"field",
"value",
"a",
"newly",
"created",
"empty",
"set",
"is",
"returned",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/IndexedSet.java#L264-L270
|
18,675
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/IndexedSet.java
|
IndexedSet.getFirstByField
|
public <V> T getFirstByField(IndexDefinition<T, V> indexDefinition, V value) {
FieldIndex<T, V> index = (FieldIndex<T, V>) mIndices.get(indexDefinition);
if (index == null) {
throw new IllegalStateException("the given index isn't defined for this IndexedSet");
}
return index.getFirst(value);
}
|
java
|
public <V> T getFirstByField(IndexDefinition<T, V> indexDefinition, V value) {
FieldIndex<T, V> index = (FieldIndex<T, V>) mIndices.get(indexDefinition);
if (index == null) {
throw new IllegalStateException("the given index isn't defined for this IndexedSet");
}
return index.getFirst(value);
}
|
[
"public",
"<",
"V",
">",
"T",
"getFirstByField",
"(",
"IndexDefinition",
"<",
"T",
",",
"V",
">",
"indexDefinition",
",",
"V",
"value",
")",
"{",
"FieldIndex",
"<",
"T",
",",
"V",
">",
"index",
"=",
"(",
"FieldIndex",
"<",
"T",
",",
"V",
">",
")",
"mIndices",
".",
"get",
"(",
"indexDefinition",
")",
";",
"if",
"(",
"index",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"the given index isn't defined for this IndexedSet\"",
")",
";",
"}",
"return",
"index",
".",
"getFirst",
"(",
"value",
")",
";",
"}"
] |
Gets the object from the set of objects with the specified field value.
@param indexDefinition the field index definition
@param value the field value
@param <V> the field type
@return the object or null if there is no such object
|
[
"Gets",
"the",
"object",
"from",
"the",
"set",
"of",
"objects",
"with",
"the",
"specified",
"field",
"value",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/IndexedSet.java#L280-L286
|
18,676
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/IndexedSet.java
|
IndexedSet.remove
|
@Override
public boolean remove(Object object) {
if (object == null) {
return false;
}
// Locking this object protects against removing the exact object that might be in the
// process of being added, but does not protect against removing a distinct, but equivalent
// object.
synchronized (object) {
if (mPrimaryIndex.containsObject((T) object)) {
// This isn't technically typesafe. However, given that success is true, it's very unlikely
// that the object passed to remove is not of type <T>.
@SuppressWarnings("unchecked")
T tObj = (T) object;
removeFromIndices(tObj);
return true;
} else {
return false;
}
}
}
|
java
|
@Override
public boolean remove(Object object) {
if (object == null) {
return false;
}
// Locking this object protects against removing the exact object that might be in the
// process of being added, but does not protect against removing a distinct, but equivalent
// object.
synchronized (object) {
if (mPrimaryIndex.containsObject((T) object)) {
// This isn't technically typesafe. However, given that success is true, it's very unlikely
// that the object passed to remove is not of type <T>.
@SuppressWarnings("unchecked")
T tObj = (T) object;
removeFromIndices(tObj);
return true;
} else {
return false;
}
}
}
|
[
"@",
"Override",
"public",
"boolean",
"remove",
"(",
"Object",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"// Locking this object protects against removing the exact object that might be in the",
"// process of being added, but does not protect against removing a distinct, but equivalent",
"// object.",
"synchronized",
"(",
"object",
")",
"{",
"if",
"(",
"mPrimaryIndex",
".",
"containsObject",
"(",
"(",
"T",
")",
"object",
")",
")",
"{",
"// This isn't technically typesafe. However, given that success is true, it's very unlikely",
"// that the object passed to remove is not of type <T>.",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"T",
"tObj",
"=",
"(",
"T",
")",
"object",
";",
"removeFromIndices",
"(",
"tObj",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"}"
] |
Removes an object from the set.
@param object the object to remove
@return true if the object is in the set and removed successfully, otherwise false
|
[
"Removes",
"an",
"object",
"from",
"the",
"set",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/IndexedSet.java#L294-L314
|
18,677
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/IndexedSet.java
|
IndexedSet.removeFromIndices
|
private void removeFromIndices(T object) {
for (FieldIndex<T, ?> fieldValue : mIndices.values()) {
fieldValue.remove(object);
}
}
|
java
|
private void removeFromIndices(T object) {
for (FieldIndex<T, ?> fieldValue : mIndices.values()) {
fieldValue.remove(object);
}
}
|
[
"private",
"void",
"removeFromIndices",
"(",
"T",
"object",
")",
"{",
"for",
"(",
"FieldIndex",
"<",
"T",
",",
"?",
">",
"fieldValue",
":",
"mIndices",
".",
"values",
"(",
")",
")",
"{",
"fieldValue",
".",
"remove",
"(",
"object",
")",
";",
"}",
"}"
] |
Helper method that removes an object from the indices.
@param object the object to be removed
|
[
"Helper",
"method",
"that",
"removes",
"an",
"object",
"from",
"the",
"indices",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/IndexedSet.java#L321-L325
|
18,678
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/collections/IndexedSet.java
|
IndexedSet.removeByField
|
public <V> int removeByField(IndexDefinition<T, V> indexDefinition, V value) {
Set<T> toRemove = getByField(indexDefinition, value);
int removed = 0;
for (T o : toRemove) {
if (remove(o)) {
removed++;
}
}
return removed;
}
|
java
|
public <V> int removeByField(IndexDefinition<T, V> indexDefinition, V value) {
Set<T> toRemove = getByField(indexDefinition, value);
int removed = 0;
for (T o : toRemove) {
if (remove(o)) {
removed++;
}
}
return removed;
}
|
[
"public",
"<",
"V",
">",
"int",
"removeByField",
"(",
"IndexDefinition",
"<",
"T",
",",
"V",
">",
"indexDefinition",
",",
"V",
"value",
")",
"{",
"Set",
"<",
"T",
">",
"toRemove",
"=",
"getByField",
"(",
"indexDefinition",
",",
"value",
")",
";",
"int",
"removed",
"=",
"0",
";",
"for",
"(",
"T",
"o",
":",
"toRemove",
")",
"{",
"if",
"(",
"remove",
"(",
"o",
")",
")",
"{",
"removed",
"++",
";",
"}",
"}",
"return",
"removed",
";",
"}"
] |
Removes the subset of objects with the specified index field value.
@param indexDefinition the field index
@param value the field value
@param <V> the field type
@return the number of objects removed
|
[
"Removes",
"the",
"subset",
"of",
"objects",
"with",
"the",
"specified",
"index",
"field",
"value",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/collections/IndexedSet.java#L335-L345
|
18,679
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/ClientContext.java
|
ClientContext.updateConfigurationDefaults
|
@VisibleForTesting
public synchronized void updateConfigurationDefaults(InetSocketAddress address)
throws AlluxioStatusException {
Pair<AlluxioConfiguration, PathConfiguration> conf =
ConfigurationUtils.loadClusterAndPathDefaults(address, mConf, mPathConf);
mConf = conf.getFirst();
mPathConf = conf.getSecond();
}
|
java
|
@VisibleForTesting
public synchronized void updateConfigurationDefaults(InetSocketAddress address)
throws AlluxioStatusException {
Pair<AlluxioConfiguration, PathConfiguration> conf =
ConfigurationUtils.loadClusterAndPathDefaults(address, mConf, mPathConf);
mConf = conf.getFirst();
mPathConf = conf.getSecond();
}
|
[
"@",
"VisibleForTesting",
"public",
"synchronized",
"void",
"updateConfigurationDefaults",
"(",
"InetSocketAddress",
"address",
")",
"throws",
"AlluxioStatusException",
"{",
"Pair",
"<",
"AlluxioConfiguration",
",",
"PathConfiguration",
">",
"conf",
"=",
"ConfigurationUtils",
".",
"loadClusterAndPathDefaults",
"(",
"address",
",",
"mConf",
",",
"mPathConf",
")",
";",
"mConf",
"=",
"conf",
".",
"getFirst",
"(",
")",
";",
"mPathConf",
"=",
"conf",
".",
"getSecond",
"(",
")",
";",
"}"
] |
This method will attempt to load the cluster and path level configuration defaults and update
the configuration if necessary.
This method should be synchronized so that concurrent calls to it don't continually overwrite
the previous configuration. The cluster defaults should only ever need to be updated once
per {@link ClientContext} reference.
@param address the address to load cluster defaults from
@throws AlluxioStatusException
|
[
"This",
"method",
"will",
"attempt",
"to",
"load",
"the",
"cluster",
"and",
"path",
"level",
"configuration",
"defaults",
"and",
"update",
"the",
"configuration",
"if",
"necessary",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/ClientContext.java#L111-L118
|
18,680
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.waitForAndKillPrimaryMaster
|
public synchronized int waitForAndKillPrimaryMaster(int timeoutMs)
throws TimeoutException, InterruptedException {
int index = getPrimaryMasterIndex(timeoutMs);
mMasters.get(index).close();
return index;
}
|
java
|
public synchronized int waitForAndKillPrimaryMaster(int timeoutMs)
throws TimeoutException, InterruptedException {
int index = getPrimaryMasterIndex(timeoutMs);
mMasters.get(index).close();
return index;
}
|
[
"public",
"synchronized",
"int",
"waitForAndKillPrimaryMaster",
"(",
"int",
"timeoutMs",
")",
"throws",
"TimeoutException",
",",
"InterruptedException",
"{",
"int",
"index",
"=",
"getPrimaryMasterIndex",
"(",
"timeoutMs",
")",
";",
"mMasters",
".",
"get",
"(",
"index",
")",
".",
"close",
"(",
")",
";",
"return",
"index",
";",
"}"
] |
Kills the primary master.
If no master is currently primary, this method blocks until a primary has been elected, then
kills it.
@param timeoutMs maximum amount of time to wait, in milliseconds
@return the ID of the killed master
|
[
"Kills",
"the",
"primary",
"master",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L248-L253
|
18,681
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.getPrimaryMasterIndex
|
public synchronized int getPrimaryMasterIndex(int timeoutMs)
throws TimeoutException, InterruptedException {
final FileSystem fs = getFileSystemClient();
final MasterInquireClient inquireClient = getMasterInquireClient();
CommonUtils.waitFor("a primary master to be serving", () -> {
try {
// Make sure the leader is serving.
fs.getStatus(new AlluxioURI("/"));
return true;
} catch (UnavailableException e) {
return false;
} catch (Exception e) {
throw new RuntimeException(e);
}
}, WaitForOptions.defaults().setTimeoutMs(timeoutMs));
int primaryRpcPort;
try {
primaryRpcPort = inquireClient.getPrimaryRpcAddress().getPort();
} catch (UnavailableException e) {
throw new RuntimeException(e);
}
// Returns the master whose RPC port matches the primary RPC port.
for (int i = 0; i < mMasterAddresses.size(); i++) {
if (mMasterAddresses.get(i).getRpcPort() == primaryRpcPort) {
return i;
}
}
throw new RuntimeException(
String.format("No master found with RPC port %d. Master addresses: %s", primaryRpcPort,
mMasterAddresses));
}
|
java
|
public synchronized int getPrimaryMasterIndex(int timeoutMs)
throws TimeoutException, InterruptedException {
final FileSystem fs = getFileSystemClient();
final MasterInquireClient inquireClient = getMasterInquireClient();
CommonUtils.waitFor("a primary master to be serving", () -> {
try {
// Make sure the leader is serving.
fs.getStatus(new AlluxioURI("/"));
return true;
} catch (UnavailableException e) {
return false;
} catch (Exception e) {
throw new RuntimeException(e);
}
}, WaitForOptions.defaults().setTimeoutMs(timeoutMs));
int primaryRpcPort;
try {
primaryRpcPort = inquireClient.getPrimaryRpcAddress().getPort();
} catch (UnavailableException e) {
throw new RuntimeException(e);
}
// Returns the master whose RPC port matches the primary RPC port.
for (int i = 0; i < mMasterAddresses.size(); i++) {
if (mMasterAddresses.get(i).getRpcPort() == primaryRpcPort) {
return i;
}
}
throw new RuntimeException(
String.format("No master found with RPC port %d. Master addresses: %s", primaryRpcPort,
mMasterAddresses));
}
|
[
"public",
"synchronized",
"int",
"getPrimaryMasterIndex",
"(",
"int",
"timeoutMs",
")",
"throws",
"TimeoutException",
",",
"InterruptedException",
"{",
"final",
"FileSystem",
"fs",
"=",
"getFileSystemClient",
"(",
")",
";",
"final",
"MasterInquireClient",
"inquireClient",
"=",
"getMasterInquireClient",
"(",
")",
";",
"CommonUtils",
".",
"waitFor",
"(",
"\"a primary master to be serving\"",
",",
"(",
")",
"->",
"{",
"try",
"{",
"// Make sure the leader is serving.",
"fs",
".",
"getStatus",
"(",
"new",
"AlluxioURI",
"(",
"\"/\"",
")",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"UnavailableException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
",",
"WaitForOptions",
".",
"defaults",
"(",
")",
".",
"setTimeoutMs",
"(",
"timeoutMs",
")",
")",
";",
"int",
"primaryRpcPort",
";",
"try",
"{",
"primaryRpcPort",
"=",
"inquireClient",
".",
"getPrimaryRpcAddress",
"(",
")",
".",
"getPort",
"(",
")",
";",
"}",
"catch",
"(",
"UnavailableException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"// Returns the master whose RPC port matches the primary RPC port.",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mMasterAddresses",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"mMasterAddresses",
".",
"get",
"(",
"i",
")",
".",
"getRpcPort",
"(",
")",
"==",
"primaryRpcPort",
")",
"{",
"return",
"i",
";",
"}",
"}",
"throw",
"new",
"RuntimeException",
"(",
"String",
".",
"format",
"(",
"\"No master found with RPC port %d. Master addresses: %s\"",
",",
"primaryRpcPort",
",",
"mMasterAddresses",
")",
")",
";",
"}"
] |
Gets the index of the primary master.
@param timeoutMs maximum amount of time to wait, in milliseconds
@return the index of the primary master
|
[
"Gets",
"the",
"index",
"of",
"the",
"primary",
"master",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L261-L291
|
18,682
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.waitForAllNodesRegistered
|
public synchronized void waitForAllNodesRegistered(int timeoutMs)
throws TimeoutException, InterruptedException {
MetaMasterClient metaMasterClient = getMetaMasterClient();
CommonUtils.waitFor("all nodes registered", () -> {
try {
MasterInfo masterInfo = metaMasterClient.getMasterInfo(Collections.emptySet());
int liveNodeNum = masterInfo.getMasterAddressesList().size()
+ masterInfo.getWorkerAddressesList().size();
if (liveNodeNum == (mNumMasters + mNumWorkers)) {
return true;
} else {
LOG.info("Master addresses: {}. Worker addresses: {}",
masterInfo.getMasterAddressesList(), masterInfo.getWorkerAddressesList());
return false;
}
} catch (UnavailableException e) {
return false;
} catch (Exception e) {
throw new RuntimeException(e);
}
}, WaitForOptions.defaults().setInterval(200).setTimeoutMs(timeoutMs));
}
|
java
|
public synchronized void waitForAllNodesRegistered(int timeoutMs)
throws TimeoutException, InterruptedException {
MetaMasterClient metaMasterClient = getMetaMasterClient();
CommonUtils.waitFor("all nodes registered", () -> {
try {
MasterInfo masterInfo = metaMasterClient.getMasterInfo(Collections.emptySet());
int liveNodeNum = masterInfo.getMasterAddressesList().size()
+ masterInfo.getWorkerAddressesList().size();
if (liveNodeNum == (mNumMasters + mNumWorkers)) {
return true;
} else {
LOG.info("Master addresses: {}. Worker addresses: {}",
masterInfo.getMasterAddressesList(), masterInfo.getWorkerAddressesList());
return false;
}
} catch (UnavailableException e) {
return false;
} catch (Exception e) {
throw new RuntimeException(e);
}
}, WaitForOptions.defaults().setInterval(200).setTimeoutMs(timeoutMs));
}
|
[
"public",
"synchronized",
"void",
"waitForAllNodesRegistered",
"(",
"int",
"timeoutMs",
")",
"throws",
"TimeoutException",
",",
"InterruptedException",
"{",
"MetaMasterClient",
"metaMasterClient",
"=",
"getMetaMasterClient",
"(",
")",
";",
"CommonUtils",
".",
"waitFor",
"(",
"\"all nodes registered\"",
",",
"(",
")",
"->",
"{",
"try",
"{",
"MasterInfo",
"masterInfo",
"=",
"metaMasterClient",
".",
"getMasterInfo",
"(",
"Collections",
".",
"emptySet",
"(",
")",
")",
";",
"int",
"liveNodeNum",
"=",
"masterInfo",
".",
"getMasterAddressesList",
"(",
")",
".",
"size",
"(",
")",
"+",
"masterInfo",
".",
"getWorkerAddressesList",
"(",
")",
".",
"size",
"(",
")",
";",
"if",
"(",
"liveNodeNum",
"==",
"(",
"mNumMasters",
"+",
"mNumWorkers",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"LOG",
".",
"info",
"(",
"\"Master addresses: {}. Worker addresses: {}\"",
",",
"masterInfo",
".",
"getMasterAddressesList",
"(",
")",
",",
"masterInfo",
".",
"getWorkerAddressesList",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"}",
"catch",
"(",
"UnavailableException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
",",
"WaitForOptions",
".",
"defaults",
"(",
")",
".",
"setInterval",
"(",
"200",
")",
".",
"setTimeoutMs",
"(",
"timeoutMs",
")",
")",
";",
"}"
] |
Waits for all nodes to be registered.
@param timeoutMs maximum amount of time to wait, in milliseconds
|
[
"Waits",
"for",
"all",
"nodes",
"to",
"be",
"registered",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L298-L319
|
18,683
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.saveWorkdir
|
public synchronized void saveWorkdir() throws IOException {
Preconditions.checkState(mState == State.STARTED,
"cluster must be started before you can save its work directory");
ARTIFACTS_DIR.mkdirs();
File tarball = new File(mWorkDir.getParentFile(), mWorkDir.getName() + ".tar.gz");
// Tar up the work directory.
ProcessBuilder pb =
new ProcessBuilder("tar", "-czf", tarball.getName(), mWorkDir.getName());
pb.directory(mWorkDir.getParentFile());
pb.redirectOutput(Redirect.appendTo(TESTS_LOG));
pb.redirectError(Redirect.appendTo(TESTS_LOG));
Process p = pb.start();
try {
p.waitFor();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
// Move tarball to artifacts directory.
File finalTarball = new File(ARTIFACTS_DIR, tarball.getName());
FileUtils.moveFile(tarball, finalTarball);
LOG.info("Saved cluster {} to {}", mClusterName, finalTarball.getAbsolutePath());
}
|
java
|
public synchronized void saveWorkdir() throws IOException {
Preconditions.checkState(mState == State.STARTED,
"cluster must be started before you can save its work directory");
ARTIFACTS_DIR.mkdirs();
File tarball = new File(mWorkDir.getParentFile(), mWorkDir.getName() + ".tar.gz");
// Tar up the work directory.
ProcessBuilder pb =
new ProcessBuilder("tar", "-czf", tarball.getName(), mWorkDir.getName());
pb.directory(mWorkDir.getParentFile());
pb.redirectOutput(Redirect.appendTo(TESTS_LOG));
pb.redirectError(Redirect.appendTo(TESTS_LOG));
Process p = pb.start();
try {
p.waitFor();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
// Move tarball to artifacts directory.
File finalTarball = new File(ARTIFACTS_DIR, tarball.getName());
FileUtils.moveFile(tarball, finalTarball);
LOG.info("Saved cluster {} to {}", mClusterName, finalTarball.getAbsolutePath());
}
|
[
"public",
"synchronized",
"void",
"saveWorkdir",
"(",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkState",
"(",
"mState",
"==",
"State",
".",
"STARTED",
",",
"\"cluster must be started before you can save its work directory\"",
")",
";",
"ARTIFACTS_DIR",
".",
"mkdirs",
"(",
")",
";",
"File",
"tarball",
"=",
"new",
"File",
"(",
"mWorkDir",
".",
"getParentFile",
"(",
")",
",",
"mWorkDir",
".",
"getName",
"(",
")",
"+",
"\".tar.gz\"",
")",
";",
"// Tar up the work directory.",
"ProcessBuilder",
"pb",
"=",
"new",
"ProcessBuilder",
"(",
"\"tar\"",
",",
"\"-czf\"",
",",
"tarball",
".",
"getName",
"(",
")",
",",
"mWorkDir",
".",
"getName",
"(",
")",
")",
";",
"pb",
".",
"directory",
"(",
"mWorkDir",
".",
"getParentFile",
"(",
")",
")",
";",
"pb",
".",
"redirectOutput",
"(",
"Redirect",
".",
"appendTo",
"(",
"TESTS_LOG",
")",
")",
";",
"pb",
".",
"redirectError",
"(",
"Redirect",
".",
"appendTo",
"(",
"TESTS_LOG",
")",
")",
";",
"Process",
"p",
"=",
"pb",
".",
"start",
"(",
")",
";",
"try",
"{",
"p",
".",
"waitFor",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"// Move tarball to artifacts directory.",
"File",
"finalTarball",
"=",
"new",
"File",
"(",
"ARTIFACTS_DIR",
",",
"tarball",
".",
"getName",
"(",
")",
")",
";",
"FileUtils",
".",
"moveFile",
"(",
"tarball",
",",
"finalTarball",
")",
";",
"LOG",
".",
"info",
"(",
"\"Saved cluster {} to {}\"",
",",
"mClusterName",
",",
"finalTarball",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}"
] |
Copies the work directory to the artifacts folder.
|
[
"Copies",
"the",
"work",
"directory",
"to",
"the",
"artifacts",
"folder",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L388-L411
|
18,684
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.destroy
|
public synchronized void destroy() throws IOException {
if (mState == State.DESTROYED) {
return;
}
if (!mSuccess) {
saveWorkdir();
}
mCloser.close();
LOG.info("Destroyed cluster {}", mClusterName);
mState = State.DESTROYED;
}
|
java
|
public synchronized void destroy() throws IOException {
if (mState == State.DESTROYED) {
return;
}
if (!mSuccess) {
saveWorkdir();
}
mCloser.close();
LOG.info("Destroyed cluster {}", mClusterName);
mState = State.DESTROYED;
}
|
[
"public",
"synchronized",
"void",
"destroy",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mState",
"==",
"State",
".",
"DESTROYED",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"mSuccess",
")",
"{",
"saveWorkdir",
"(",
")",
";",
"}",
"mCloser",
".",
"close",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Destroyed cluster {}\"",
",",
"mClusterName",
")",
";",
"mState",
"=",
"State",
".",
"DESTROYED",
";",
"}"
] |
Destroys the cluster. It may not be re-started after being destroyed.
|
[
"Destroys",
"the",
"cluster",
".",
"It",
"may",
"not",
"be",
"re",
"-",
"started",
"after",
"being",
"destroyed",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L416-L426
|
18,685
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.startMaster
|
public synchronized void startMaster(int i) throws IOException {
Preconditions.checkState(mState == State.STARTED,
"Must be in a started state to start masters");
mMasters.get(i).start();
}
|
java
|
public synchronized void startMaster(int i) throws IOException {
Preconditions.checkState(mState == State.STARTED,
"Must be in a started state to start masters");
mMasters.get(i).start();
}
|
[
"public",
"synchronized",
"void",
"startMaster",
"(",
"int",
"i",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkState",
"(",
"mState",
"==",
"State",
".",
"STARTED",
",",
"\"Must be in a started state to start masters\"",
")",
";",
"mMasters",
".",
"get",
"(",
"i",
")",
".",
"start",
"(",
")",
";",
"}"
] |
Starts the specified master.
@param i the index of the master to start
|
[
"Starts",
"the",
"specified",
"master",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L440-L444
|
18,686
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.startWorker
|
public synchronized void startWorker(int i) throws IOException {
Preconditions.checkState(mState == State.STARTED,
"Must be in a started state to start workers");
mWorkers.get(i).start();
}
|
java
|
public synchronized void startWorker(int i) throws IOException {
Preconditions.checkState(mState == State.STARTED,
"Must be in a started state to start workers");
mWorkers.get(i).start();
}
|
[
"public",
"synchronized",
"void",
"startWorker",
"(",
"int",
"i",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkState",
"(",
"mState",
"==",
"State",
".",
"STARTED",
",",
"\"Must be in a started state to start workers\"",
")",
";",
"mWorkers",
".",
"get",
"(",
"i",
")",
".",
"start",
"(",
")",
";",
"}"
] |
Starts the specified worker.
@param i the index of the worker to start
|
[
"Starts",
"the",
"specified",
"worker",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L451-L455
|
18,687
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.updateDeployMode
|
public synchronized void updateDeployMode(DeployMode mode) {
mDeployMode = mode;
if (mDeployMode == DeployMode.EMBEDDED) {
// Ensure that the journal properties are set correctly.
for (int i = 0; i < mMasters.size(); i++) {
Master master = mMasters.get(i);
MasterNetAddress address = mMasterAddresses.get(i);
master.updateConf(PropertyKey.MASTER_EMBEDDED_JOURNAL_PORT,
Integer.toString(address.getEmbeddedJournalPort()));
File journalDir = new File(mWorkDir, "journal" + i);
journalDir.mkdirs();
master.updateConf(PropertyKey.MASTER_JOURNAL_FOLDER, journalDir.getAbsolutePath());
}
}
}
|
java
|
public synchronized void updateDeployMode(DeployMode mode) {
mDeployMode = mode;
if (mDeployMode == DeployMode.EMBEDDED) {
// Ensure that the journal properties are set correctly.
for (int i = 0; i < mMasters.size(); i++) {
Master master = mMasters.get(i);
MasterNetAddress address = mMasterAddresses.get(i);
master.updateConf(PropertyKey.MASTER_EMBEDDED_JOURNAL_PORT,
Integer.toString(address.getEmbeddedJournalPort()));
File journalDir = new File(mWorkDir, "journal" + i);
journalDir.mkdirs();
master.updateConf(PropertyKey.MASTER_JOURNAL_FOLDER, journalDir.getAbsolutePath());
}
}
}
|
[
"public",
"synchronized",
"void",
"updateDeployMode",
"(",
"DeployMode",
"mode",
")",
"{",
"mDeployMode",
"=",
"mode",
";",
"if",
"(",
"mDeployMode",
"==",
"DeployMode",
".",
"EMBEDDED",
")",
"{",
"// Ensure that the journal properties are set correctly.",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mMasters",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Master",
"master",
"=",
"mMasters",
".",
"get",
"(",
"i",
")",
";",
"MasterNetAddress",
"address",
"=",
"mMasterAddresses",
".",
"get",
"(",
"i",
")",
";",
"master",
".",
"updateConf",
"(",
"PropertyKey",
".",
"MASTER_EMBEDDED_JOURNAL_PORT",
",",
"Integer",
".",
"toString",
"(",
"address",
".",
"getEmbeddedJournalPort",
"(",
")",
")",
")",
";",
"File",
"journalDir",
"=",
"new",
"File",
"(",
"mWorkDir",
",",
"\"journal\"",
"+",
"i",
")",
";",
"journalDir",
".",
"mkdirs",
"(",
")",
";",
"master",
".",
"updateConf",
"(",
"PropertyKey",
".",
"MASTER_JOURNAL_FOLDER",
",",
"journalDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Updates the cluster's deploy mode.
@param mode the mode to set
|
[
"Updates",
"the",
"cluster",
"s",
"deploy",
"mode",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L487-L502
|
18,688
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.createMaster
|
private synchronized Master createMaster(int i) throws IOException {
Preconditions.checkState(mState == State.STARTED,
"Must be in a started state to create masters");
MasterNetAddress address = mMasterAddresses.get(i);
File confDir = new File(mWorkDir, "conf-master" + i);
File metastoreDir = new File(mWorkDir, "metastore-master" + i);
File logsDir = new File(mWorkDir, "logs-master" + i);
logsDir.mkdirs();
Map<PropertyKey, String> conf = new HashMap<>();
conf.put(PropertyKey.LOGGER_TYPE, "MASTER_LOGGER");
conf.put(PropertyKey.CONF_DIR, confDir.getAbsolutePath());
conf.put(PropertyKey.MASTER_METASTORE_DIR, metastoreDir.getAbsolutePath());
conf.put(PropertyKey.LOGS_DIR, logsDir.getAbsolutePath());
conf.put(PropertyKey.MASTER_HOSTNAME, address.getHostname());
conf.put(PropertyKey.MASTER_RPC_PORT, Integer.toString(address.getRpcPort()));
conf.put(PropertyKey.MASTER_WEB_PORT, Integer.toString(address.getWebPort()));
conf.put(PropertyKey.MASTER_EMBEDDED_JOURNAL_PORT,
Integer.toString(address.getEmbeddedJournalPort()));
if (mDeployMode.equals(DeployMode.EMBEDDED)) {
File journalDir = new File(mWorkDir, "journal" + i);
journalDir.mkdirs();
conf.put(PropertyKey.MASTER_JOURNAL_FOLDER, journalDir.getAbsolutePath());
}
Master master = mCloser.register(new Master(logsDir, conf));
mMasters.add(master);
return master;
}
|
java
|
private synchronized Master createMaster(int i) throws IOException {
Preconditions.checkState(mState == State.STARTED,
"Must be in a started state to create masters");
MasterNetAddress address = mMasterAddresses.get(i);
File confDir = new File(mWorkDir, "conf-master" + i);
File metastoreDir = new File(mWorkDir, "metastore-master" + i);
File logsDir = new File(mWorkDir, "logs-master" + i);
logsDir.mkdirs();
Map<PropertyKey, String> conf = new HashMap<>();
conf.put(PropertyKey.LOGGER_TYPE, "MASTER_LOGGER");
conf.put(PropertyKey.CONF_DIR, confDir.getAbsolutePath());
conf.put(PropertyKey.MASTER_METASTORE_DIR, metastoreDir.getAbsolutePath());
conf.put(PropertyKey.LOGS_DIR, logsDir.getAbsolutePath());
conf.put(PropertyKey.MASTER_HOSTNAME, address.getHostname());
conf.put(PropertyKey.MASTER_RPC_PORT, Integer.toString(address.getRpcPort()));
conf.put(PropertyKey.MASTER_WEB_PORT, Integer.toString(address.getWebPort()));
conf.put(PropertyKey.MASTER_EMBEDDED_JOURNAL_PORT,
Integer.toString(address.getEmbeddedJournalPort()));
if (mDeployMode.equals(DeployMode.EMBEDDED)) {
File journalDir = new File(mWorkDir, "journal" + i);
journalDir.mkdirs();
conf.put(PropertyKey.MASTER_JOURNAL_FOLDER, journalDir.getAbsolutePath());
}
Master master = mCloser.register(new Master(logsDir, conf));
mMasters.add(master);
return master;
}
|
[
"private",
"synchronized",
"Master",
"createMaster",
"(",
"int",
"i",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkState",
"(",
"mState",
"==",
"State",
".",
"STARTED",
",",
"\"Must be in a started state to create masters\"",
")",
";",
"MasterNetAddress",
"address",
"=",
"mMasterAddresses",
".",
"get",
"(",
"i",
")",
";",
"File",
"confDir",
"=",
"new",
"File",
"(",
"mWorkDir",
",",
"\"conf-master\"",
"+",
"i",
")",
";",
"File",
"metastoreDir",
"=",
"new",
"File",
"(",
"mWorkDir",
",",
"\"metastore-master\"",
"+",
"i",
")",
";",
"File",
"logsDir",
"=",
"new",
"File",
"(",
"mWorkDir",
",",
"\"logs-master\"",
"+",
"i",
")",
";",
"logsDir",
".",
"mkdirs",
"(",
")",
";",
"Map",
"<",
"PropertyKey",
",",
"String",
">",
"conf",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"LOGGER_TYPE",
",",
"\"MASTER_LOGGER\"",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"CONF_DIR",
",",
"confDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"MASTER_METASTORE_DIR",
",",
"metastoreDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"LOGS_DIR",
",",
"logsDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"MASTER_HOSTNAME",
",",
"address",
".",
"getHostname",
"(",
")",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"MASTER_RPC_PORT",
",",
"Integer",
".",
"toString",
"(",
"address",
".",
"getRpcPort",
"(",
")",
")",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"MASTER_WEB_PORT",
",",
"Integer",
".",
"toString",
"(",
"address",
".",
"getWebPort",
"(",
")",
")",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"MASTER_EMBEDDED_JOURNAL_PORT",
",",
"Integer",
".",
"toString",
"(",
"address",
".",
"getEmbeddedJournalPort",
"(",
")",
")",
")",
";",
"if",
"(",
"mDeployMode",
".",
"equals",
"(",
"DeployMode",
".",
"EMBEDDED",
")",
")",
"{",
"File",
"journalDir",
"=",
"new",
"File",
"(",
"mWorkDir",
",",
"\"journal\"",
"+",
"i",
")",
";",
"journalDir",
".",
"mkdirs",
"(",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"MASTER_JOURNAL_FOLDER",
",",
"journalDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"Master",
"master",
"=",
"mCloser",
".",
"register",
"(",
"new",
"Master",
"(",
"logsDir",
",",
"conf",
")",
")",
";",
"mMasters",
".",
"add",
"(",
"master",
")",
";",
"return",
"master",
";",
"}"
] |
Creates the specified master without starting it.
@param i the index of the master to create
|
[
"Creates",
"the",
"specified",
"master",
"without",
"starting",
"it",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L545-L571
|
18,689
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.createWorker
|
private synchronized Worker createWorker(int i) throws IOException {
Preconditions.checkState(mState == State.STARTED,
"Must be in a started state to create workers");
File confDir = new File(mWorkDir, "conf-worker" + i);
File logsDir = new File(mWorkDir, "logs-worker" + i);
File ramdisk = new File(mWorkDir, "ramdisk" + i);
logsDir.mkdirs();
ramdisk.mkdirs();
int rpcPort = getNewPort();
int dataPort = getNewPort();
int webPort = getNewPort();
Map<PropertyKey, String> conf = new HashMap<>();
conf.put(PropertyKey.LOGGER_TYPE, "WORKER_LOGGER");
conf.put(PropertyKey.CONF_DIR, confDir.getAbsolutePath());
conf.put(PropertyKey.Template.WORKER_TIERED_STORE_LEVEL_DIRS_PATH.format(0),
ramdisk.getAbsolutePath());
conf.put(PropertyKey.LOGS_DIR, logsDir.getAbsolutePath());
conf.put(PropertyKey.WORKER_RPC_PORT, Integer.toString(rpcPort));
conf.put(PropertyKey.WORKER_WEB_PORT, Integer.toString(webPort));
Worker worker = mCloser.register(new Worker(logsDir, conf));
mWorkers.add(worker);
LOG.info("Created worker with (rpc, data, web) ports ({}, {}, {})", rpcPort, dataPort,
webPort);
return worker;
}
|
java
|
private synchronized Worker createWorker(int i) throws IOException {
Preconditions.checkState(mState == State.STARTED,
"Must be in a started state to create workers");
File confDir = new File(mWorkDir, "conf-worker" + i);
File logsDir = new File(mWorkDir, "logs-worker" + i);
File ramdisk = new File(mWorkDir, "ramdisk" + i);
logsDir.mkdirs();
ramdisk.mkdirs();
int rpcPort = getNewPort();
int dataPort = getNewPort();
int webPort = getNewPort();
Map<PropertyKey, String> conf = new HashMap<>();
conf.put(PropertyKey.LOGGER_TYPE, "WORKER_LOGGER");
conf.put(PropertyKey.CONF_DIR, confDir.getAbsolutePath());
conf.put(PropertyKey.Template.WORKER_TIERED_STORE_LEVEL_DIRS_PATH.format(0),
ramdisk.getAbsolutePath());
conf.put(PropertyKey.LOGS_DIR, logsDir.getAbsolutePath());
conf.put(PropertyKey.WORKER_RPC_PORT, Integer.toString(rpcPort));
conf.put(PropertyKey.WORKER_WEB_PORT, Integer.toString(webPort));
Worker worker = mCloser.register(new Worker(logsDir, conf));
mWorkers.add(worker);
LOG.info("Created worker with (rpc, data, web) ports ({}, {}, {})", rpcPort, dataPort,
webPort);
return worker;
}
|
[
"private",
"synchronized",
"Worker",
"createWorker",
"(",
"int",
"i",
")",
"throws",
"IOException",
"{",
"Preconditions",
".",
"checkState",
"(",
"mState",
"==",
"State",
".",
"STARTED",
",",
"\"Must be in a started state to create workers\"",
")",
";",
"File",
"confDir",
"=",
"new",
"File",
"(",
"mWorkDir",
",",
"\"conf-worker\"",
"+",
"i",
")",
";",
"File",
"logsDir",
"=",
"new",
"File",
"(",
"mWorkDir",
",",
"\"logs-worker\"",
"+",
"i",
")",
";",
"File",
"ramdisk",
"=",
"new",
"File",
"(",
"mWorkDir",
",",
"\"ramdisk\"",
"+",
"i",
")",
";",
"logsDir",
".",
"mkdirs",
"(",
")",
";",
"ramdisk",
".",
"mkdirs",
"(",
")",
";",
"int",
"rpcPort",
"=",
"getNewPort",
"(",
")",
";",
"int",
"dataPort",
"=",
"getNewPort",
"(",
")",
";",
"int",
"webPort",
"=",
"getNewPort",
"(",
")",
";",
"Map",
"<",
"PropertyKey",
",",
"String",
">",
"conf",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"LOGGER_TYPE",
",",
"\"WORKER_LOGGER\"",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"CONF_DIR",
",",
"confDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"Template",
".",
"WORKER_TIERED_STORE_LEVEL_DIRS_PATH",
".",
"format",
"(",
"0",
")",
",",
"ramdisk",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"LOGS_DIR",
",",
"logsDir",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"WORKER_RPC_PORT",
",",
"Integer",
".",
"toString",
"(",
"rpcPort",
")",
")",
";",
"conf",
".",
"put",
"(",
"PropertyKey",
".",
"WORKER_WEB_PORT",
",",
"Integer",
".",
"toString",
"(",
"webPort",
")",
")",
";",
"Worker",
"worker",
"=",
"mCloser",
".",
"register",
"(",
"new",
"Worker",
"(",
"logsDir",
",",
"conf",
")",
")",
";",
"mWorkers",
".",
"add",
"(",
"worker",
")",
";",
"LOG",
".",
"info",
"(",
"\"Created worker with (rpc, data, web) ports ({}, {}, {})\"",
",",
"rpcPort",
",",
"dataPort",
",",
"webPort",
")",
";",
"return",
"worker",
";",
"}"
] |
Creates the specified worker without starting it.
@param i the index of the worker to create
|
[
"Creates",
"the",
"specified",
"worker",
"without",
"starting",
"it",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L578-L604
|
18,690
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.formatJournal
|
public synchronized void formatJournal() throws IOException {
if (mDeployMode == DeployMode.EMBEDDED) {
for (Master master : mMasters) {
File journalDir = new File(master.getConf().get(PropertyKey.MASTER_JOURNAL_FOLDER));
FileUtils.deleteDirectory(journalDir);
journalDir.mkdirs();
}
return;
}
try (Closeable c = new ConfigurationRule(mProperties, ServerConfiguration.global())
.toResource()) {
Format.format(Format.Mode.MASTER, ServerConfiguration.global());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
public synchronized void formatJournal() throws IOException {
if (mDeployMode == DeployMode.EMBEDDED) {
for (Master master : mMasters) {
File journalDir = new File(master.getConf().get(PropertyKey.MASTER_JOURNAL_FOLDER));
FileUtils.deleteDirectory(journalDir);
journalDir.mkdirs();
}
return;
}
try (Closeable c = new ConfigurationRule(mProperties, ServerConfiguration.global())
.toResource()) {
Format.format(Format.Mode.MASTER, ServerConfiguration.global());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"synchronized",
"void",
"formatJournal",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mDeployMode",
"==",
"DeployMode",
".",
"EMBEDDED",
")",
"{",
"for",
"(",
"Master",
"master",
":",
"mMasters",
")",
"{",
"File",
"journalDir",
"=",
"new",
"File",
"(",
"master",
".",
"getConf",
"(",
")",
".",
"get",
"(",
"PropertyKey",
".",
"MASTER_JOURNAL_FOLDER",
")",
")",
";",
"FileUtils",
".",
"deleteDirectory",
"(",
"journalDir",
")",
";",
"journalDir",
".",
"mkdirs",
"(",
")",
";",
"}",
"return",
";",
"}",
"try",
"(",
"Closeable",
"c",
"=",
"new",
"ConfigurationRule",
"(",
"mProperties",
",",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
".",
"toResource",
"(",
")",
")",
"{",
"Format",
".",
"format",
"(",
"Format",
".",
"Mode",
".",
"MASTER",
",",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Formats the cluster journal.
|
[
"Formats",
"the",
"cluster",
"journal",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L609-L624
|
18,691
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.writeConf
|
private void writeConf() throws IOException {
for (int i = 0; i < mNumMasters; i++) {
File confDir = new File(mWorkDir, "conf-master" + i);
writeConfToFile(confDir, mMasterProperties.getOrDefault(i, new HashMap<>()));
}
for (int i = 0; i < mNumWorkers; i++) {
File confDir = new File(mWorkDir, "conf-worker" + i);
writeConfToFile(confDir, mWorkerProperties.getOrDefault(i, new HashMap<>()));
}
}
|
java
|
private void writeConf() throws IOException {
for (int i = 0; i < mNumMasters; i++) {
File confDir = new File(mWorkDir, "conf-master" + i);
writeConfToFile(confDir, mMasterProperties.getOrDefault(i, new HashMap<>()));
}
for (int i = 0; i < mNumWorkers; i++) {
File confDir = new File(mWorkDir, "conf-worker" + i);
writeConfToFile(confDir, mWorkerProperties.getOrDefault(i, new HashMap<>()));
}
}
|
[
"private",
"void",
"writeConf",
"(",
")",
"throws",
"IOException",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mNumMasters",
";",
"i",
"++",
")",
"{",
"File",
"confDir",
"=",
"new",
"File",
"(",
"mWorkDir",
",",
"\"conf-master\"",
"+",
"i",
")",
";",
"writeConfToFile",
"(",
"confDir",
",",
"mMasterProperties",
".",
"getOrDefault",
"(",
"i",
",",
"new",
"HashMap",
"<>",
"(",
")",
")",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mNumWorkers",
";",
"i",
"++",
")",
"{",
"File",
"confDir",
"=",
"new",
"File",
"(",
"mWorkDir",
",",
"\"conf-worker\"",
"+",
"i",
")",
";",
"writeConfToFile",
"(",
"confDir",
",",
"mWorkerProperties",
".",
"getOrDefault",
"(",
"i",
",",
"new",
"HashMap",
"<>",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Writes the contents of properties to the configuration file.
|
[
"Writes",
"the",
"contents",
"of",
"properties",
"to",
"the",
"configuration",
"file",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L660-L669
|
18,692
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java
|
MultiProcessCluster.writeConfToFile
|
private void writeConfToFile(File dir, Map<PropertyKey, String> properties) throws IOException {
// Generates the full set of properties to write
Map<PropertyKey, String> map = new HashMap<>(mProperties);
for (Map.Entry<PropertyKey, String> entry : properties.entrySet()) {
map.put(entry.getKey(), entry.getValue());
}
StringBuilder sb = new StringBuilder();
for (Entry<PropertyKey, String> entry : map.entrySet()) {
sb.append(String.format("%s=%s%n", entry.getKey(), entry.getValue()));
}
dir.mkdirs();
try (FileOutputStream fos
= new FileOutputStream(new File(dir, "alluxio-site.properties"))) {
fos.write(sb.toString().getBytes(Charsets.UTF_8));
}
}
|
java
|
private void writeConfToFile(File dir, Map<PropertyKey, String> properties) throws IOException {
// Generates the full set of properties to write
Map<PropertyKey, String> map = new HashMap<>(mProperties);
for (Map.Entry<PropertyKey, String> entry : properties.entrySet()) {
map.put(entry.getKey(), entry.getValue());
}
StringBuilder sb = new StringBuilder();
for (Entry<PropertyKey, String> entry : map.entrySet()) {
sb.append(String.format("%s=%s%n", entry.getKey(), entry.getValue()));
}
dir.mkdirs();
try (FileOutputStream fos
= new FileOutputStream(new File(dir, "alluxio-site.properties"))) {
fos.write(sb.toString().getBytes(Charsets.UTF_8));
}
}
|
[
"private",
"void",
"writeConfToFile",
"(",
"File",
"dir",
",",
"Map",
"<",
"PropertyKey",
",",
"String",
">",
"properties",
")",
"throws",
"IOException",
"{",
"// Generates the full set of properties to write",
"Map",
"<",
"PropertyKey",
",",
"String",
">",
"map",
"=",
"new",
"HashMap",
"<>",
"(",
"mProperties",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"PropertyKey",
",",
"String",
">",
"entry",
":",
"properties",
".",
"entrySet",
"(",
")",
")",
"{",
"map",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"Entry",
"<",
"PropertyKey",
",",
"String",
">",
"entry",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"sb",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"%s=%s%n\"",
",",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"dir",
".",
"mkdirs",
"(",
")",
";",
"try",
"(",
"FileOutputStream",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"new",
"File",
"(",
"dir",
",",
"\"alluxio-site.properties\"",
")",
")",
")",
"{",
"fos",
".",
"write",
"(",
"sb",
".",
"toString",
"(",
")",
".",
"getBytes",
"(",
"Charsets",
".",
"UTF_8",
")",
")",
";",
"}",
"}"
] |
Creates the conf directory and file.
Writes the properties to the generated file.
@param dir the conf directory to create
@param properties the specific properties of the current node
|
[
"Creates",
"the",
"conf",
"directory",
"and",
"file",
".",
"Writes",
"the",
"properties",
"to",
"the",
"generated",
"file",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java#L686-L703
|
18,693
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/contexts/CreateDirectoryContext.java
|
CreateDirectoryContext.setDefaultAcl
|
public CreateDirectoryContext setDefaultAcl(List<AclEntry> defaultAcl) {
mDefaultAcl = ImmutableList.copyOf(defaultAcl);
return getThis();
}
|
java
|
public CreateDirectoryContext setDefaultAcl(List<AclEntry> defaultAcl) {
mDefaultAcl = ImmutableList.copyOf(defaultAcl);
return getThis();
}
|
[
"public",
"CreateDirectoryContext",
"setDefaultAcl",
"(",
"List",
"<",
"AclEntry",
">",
"defaultAcl",
")",
"{",
"mDefaultAcl",
"=",
"ImmutableList",
".",
"copyOf",
"(",
"defaultAcl",
")",
";",
"return",
"getThis",
"(",
")",
";",
"}"
] |
Sets the default ACL in the context.
@param defaultAcl a list of default ACL Entries
@return the updated context object
|
[
"Sets",
"the",
"default",
"ACL",
"in",
"the",
"context",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/contexts/CreateDirectoryContext.java#L103-L106
|
18,694
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/file/FileOutStream.java
|
FileOutStream.scheduleAsyncPersist
|
protected void scheduleAsyncPersist() throws IOException {
try (CloseableResource<FileSystemMasterClient> masterClient = mContext
.acquireMasterClientResource()) {
ScheduleAsyncPersistencePOptions persistOptions =
FileSystemOptions.scheduleAsyncPersistDefaults(mContext.getPathConf(mUri)).toBuilder()
.setCommonOptions(mOptions.getCommonOptions()).build();
masterClient.get().scheduleAsyncPersist(mUri, persistOptions);
}
}
|
java
|
protected void scheduleAsyncPersist() throws IOException {
try (CloseableResource<FileSystemMasterClient> masterClient = mContext
.acquireMasterClientResource()) {
ScheduleAsyncPersistencePOptions persistOptions =
FileSystemOptions.scheduleAsyncPersistDefaults(mContext.getPathConf(mUri)).toBuilder()
.setCommonOptions(mOptions.getCommonOptions()).build();
masterClient.get().scheduleAsyncPersist(mUri, persistOptions);
}
}
|
[
"protected",
"void",
"scheduleAsyncPersist",
"(",
")",
"throws",
"IOException",
"{",
"try",
"(",
"CloseableResource",
"<",
"FileSystemMasterClient",
">",
"masterClient",
"=",
"mContext",
".",
"acquireMasterClientResource",
"(",
")",
")",
"{",
"ScheduleAsyncPersistencePOptions",
"persistOptions",
"=",
"FileSystemOptions",
".",
"scheduleAsyncPersistDefaults",
"(",
"mContext",
".",
"getPathConf",
"(",
"mUri",
")",
")",
".",
"toBuilder",
"(",
")",
".",
"setCommonOptions",
"(",
"mOptions",
".",
"getCommonOptions",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"masterClient",
".",
"get",
"(",
")",
".",
"scheduleAsyncPersist",
"(",
"mUri",
",",
"persistOptions",
")",
";",
"}",
"}"
] |
Schedules the async persistence of the current file.
|
[
"Schedules",
"the",
"async",
"persistence",
"of",
"the",
"current",
"file",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/file/FileOutStream.java#L307-L315
|
18,695
|
Alluxio/alluxio
|
examples/src/main/java/alluxio/cli/CliUtils.java
|
CliUtils.printPassInfo
|
public static void printPassInfo(boolean pass) {
if (pass) {
System.out.println(Constants.ANSI_GREEN + "Passed the test!" + Constants.ANSI_RESET);
} else {
System.out.println(Constants.ANSI_RED + "Failed the test!" + Constants.ANSI_RESET);
}
}
|
java
|
public static void printPassInfo(boolean pass) {
if (pass) {
System.out.println(Constants.ANSI_GREEN + "Passed the test!" + Constants.ANSI_RESET);
} else {
System.out.println(Constants.ANSI_RED + "Failed the test!" + Constants.ANSI_RESET);
}
}
|
[
"public",
"static",
"void",
"printPassInfo",
"(",
"boolean",
"pass",
")",
"{",
"if",
"(",
"pass",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"Constants",
".",
"ANSI_GREEN",
"+",
"\"Passed the test!\"",
"+",
"Constants",
".",
"ANSI_RESET",
")",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"Constants",
".",
"ANSI_RED",
"+",
"\"Failed the test!\"",
"+",
"Constants",
".",
"ANSI_RESET",
")",
";",
"}",
"}"
] |
Prints information of the test result.
@param pass the test result
|
[
"Prints",
"information",
"of",
"the",
"test",
"result",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/examples/src/main/java/alluxio/cli/CliUtils.java#L34-L40
|
18,696
|
Alluxio/alluxio
|
examples/src/main/java/alluxio/cli/CliUtils.java
|
CliUtils.runExample
|
public static boolean runExample(final Callable<Boolean> example) {
boolean result;
try {
result = example.call();
} catch (Exception e) {
LOG.error("Exception running test: " + example, e);
result = false;
}
CliUtils.printPassInfo(result);
return result;
}
|
java
|
public static boolean runExample(final Callable<Boolean> example) {
boolean result;
try {
result = example.call();
} catch (Exception e) {
LOG.error("Exception running test: " + example, e);
result = false;
}
CliUtils.printPassInfo(result);
return result;
}
|
[
"public",
"static",
"boolean",
"runExample",
"(",
"final",
"Callable",
"<",
"Boolean",
">",
"example",
")",
"{",
"boolean",
"result",
";",
"try",
"{",
"result",
"=",
"example",
".",
"call",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Exception running test: \"",
"+",
"example",
",",
"e",
")",
";",
"result",
"=",
"false",
";",
"}",
"CliUtils",
".",
"printPassInfo",
"(",
"result",
")",
";",
"return",
"result",
";",
"}"
] |
Runs an example.
@param example the example to run
@return whether the example completes
|
[
"Runs",
"an",
"example",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/examples/src/main/java/alluxio/cli/CliUtils.java#L48-L58
|
18,697
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/AlluxioBlockStore.java
|
AlluxioBlockStore.create
|
public static AlluxioBlockStore create(FileSystemContext context) {
return new AlluxioBlockStore(context,
TieredIdentityFactory.localIdentity(context.getClusterConf()));
}
|
java
|
public static AlluxioBlockStore create(FileSystemContext context) {
return new AlluxioBlockStore(context,
TieredIdentityFactory.localIdentity(context.getClusterConf()));
}
|
[
"public",
"static",
"AlluxioBlockStore",
"create",
"(",
"FileSystemContext",
"context",
")",
"{",
"return",
"new",
"AlluxioBlockStore",
"(",
"context",
",",
"TieredIdentityFactory",
".",
"localIdentity",
"(",
"context",
".",
"getClusterConf",
"(",
")",
")",
")",
";",
"}"
] |
Creates an Alluxio block store with default local hostname.
@param context the file system context
@return the {@link AlluxioBlockStore} created
|
[
"Creates",
"an",
"Alluxio",
"block",
"store",
"with",
"default",
"local",
"hostname",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/AlluxioBlockStore.java#L84-L87
|
18,698
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/AlluxioBlockStore.java
|
AlluxioBlockStore.getInfo
|
public BlockInfo getInfo(long blockId) throws IOException {
try (CloseableResource<BlockMasterClient> masterClientResource =
mContext.acquireBlockMasterClientResource()) {
return masterClientResource.get().getBlockInfo(blockId);
}
}
|
java
|
public BlockInfo getInfo(long blockId) throws IOException {
try (CloseableResource<BlockMasterClient> masterClientResource =
mContext.acquireBlockMasterClientResource()) {
return masterClientResource.get().getBlockInfo(blockId);
}
}
|
[
"public",
"BlockInfo",
"getInfo",
"(",
"long",
"blockId",
")",
"throws",
"IOException",
"{",
"try",
"(",
"CloseableResource",
"<",
"BlockMasterClient",
">",
"masterClientResource",
"=",
"mContext",
".",
"acquireBlockMasterClientResource",
"(",
")",
")",
"{",
"return",
"masterClientResource",
".",
"get",
"(",
")",
".",
"getBlockInfo",
"(",
"blockId",
")",
";",
"}",
"}"
] |
Gets the block info of a block, if it exists.
@param blockId the blockId to obtain information about
@return a {@link BlockInfo} containing the metadata of the block
|
[
"Gets",
"the",
"block",
"info",
"of",
"a",
"block",
"if",
"it",
"exists",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/AlluxioBlockStore.java#L110-L115
|
18,699
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/block/AlluxioBlockStore.java
|
AlluxioBlockStore.getInStream
|
public BlockInStream getInStream(long blockId, InStreamOptions options) throws IOException {
return getInStream(blockId, options, ImmutableMap.of());
}
|
java
|
public BlockInStream getInStream(long blockId, InStreamOptions options) throws IOException {
return getInStream(blockId, options, ImmutableMap.of());
}
|
[
"public",
"BlockInStream",
"getInStream",
"(",
"long",
"blockId",
",",
"InStreamOptions",
"options",
")",
"throws",
"IOException",
"{",
"return",
"getInStream",
"(",
"blockId",
",",
"options",
",",
"ImmutableMap",
".",
"of",
"(",
")",
")",
";",
"}"
] |
Gets a stream to read the data of a block. This method is primarily responsible for
determining the data source and type of data source. The latest BlockInfo will be fetched
from the master to ensure the locations are up to date.
@param blockId the id of the block to read
@param options the options associated with the read request
@return a stream which reads from the beginning of the block
|
[
"Gets",
"a",
"stream",
"to",
"read",
"the",
"data",
"of",
"a",
"block",
".",
"This",
"method",
"is",
"primarily",
"responsible",
"for",
"determining",
"the",
"data",
"source",
"and",
"type",
"of",
"data",
"source",
".",
"The",
"latest",
"BlockInfo",
"will",
"be",
"fetched",
"from",
"the",
"master",
"to",
"ensure",
"the",
"locations",
"are",
"up",
"to",
"date",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/block/AlluxioBlockStore.java#L148-L150
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.