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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
19,000
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java
|
NetworkAddressUtils.getLocalHostName
|
public static synchronized String getLocalHostName(int timeoutMs) {
if (sLocalHost != null) {
return sLocalHost;
}
try {
sLocalHost = InetAddress.getByName(getLocalIpAddress(timeoutMs)).getCanonicalHostName();
return sLocalHost;
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
}
|
java
|
public static synchronized String getLocalHostName(int timeoutMs) {
if (sLocalHost != null) {
return sLocalHost;
}
try {
sLocalHost = InetAddress.getByName(getLocalIpAddress(timeoutMs)).getCanonicalHostName();
return sLocalHost;
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"static",
"synchronized",
"String",
"getLocalHostName",
"(",
"int",
"timeoutMs",
")",
"{",
"if",
"(",
"sLocalHost",
"!=",
"null",
")",
"{",
"return",
"sLocalHost",
";",
"}",
"try",
"{",
"sLocalHost",
"=",
"InetAddress",
".",
"getByName",
"(",
"getLocalIpAddress",
"(",
"timeoutMs",
")",
")",
".",
"getCanonicalHostName",
"(",
")",
";",
"return",
"sLocalHost",
";",
"}",
"catch",
"(",
"UnknownHostException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Gets a local host name for the host this JVM is running on.
@param timeoutMs Timeout in milliseconds to use for checking that a possible local host is
reachable
@return the local host name, which is not based on a loopback ip address
|
[
"Gets",
"a",
"local",
"host",
"name",
"for",
"the",
"host",
"this",
"JVM",
"is",
"running",
"on",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java#L410-L421
|
19,001
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java
|
NetworkAddressUtils.getLocalHostMetricName
|
public static synchronized String getLocalHostMetricName(int timeoutMs) {
if (sLocalHostMetricName != null) {
return sLocalHostMetricName;
}
sLocalHostMetricName = getLocalHostName(timeoutMs).replace('.', '_');
return sLocalHostMetricName;
}
|
java
|
public static synchronized String getLocalHostMetricName(int timeoutMs) {
if (sLocalHostMetricName != null) {
return sLocalHostMetricName;
}
sLocalHostMetricName = getLocalHostName(timeoutMs).replace('.', '_');
return sLocalHostMetricName;
}
|
[
"public",
"static",
"synchronized",
"String",
"getLocalHostMetricName",
"(",
"int",
"timeoutMs",
")",
"{",
"if",
"(",
"sLocalHostMetricName",
"!=",
"null",
")",
"{",
"return",
"sLocalHostMetricName",
";",
"}",
"sLocalHostMetricName",
"=",
"getLocalHostName",
"(",
"timeoutMs",
")",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"return",
"sLocalHostMetricName",
";",
"}"
] |
Gets a local hostname for the host this JVM is running on with '.' replaced with '_' for
metrics usage.
@param timeoutMs Timeout in milliseconds to use for checking that a possible local host is
reachable
@return the metrics system friendly local host name
|
[
"Gets",
"a",
"local",
"hostname",
"for",
"the",
"host",
"this",
"JVM",
"is",
"running",
"on",
"with",
".",
"replaced",
"with",
"_",
"for",
"metrics",
"usage",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java#L431-L437
|
19,002
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java
|
NetworkAddressUtils.getLocalIpAddress
|
public static synchronized String getLocalIpAddress(int timeoutMs) {
if (sLocalIP != null) {
return sLocalIP;
}
try {
InetAddress address = InetAddress.getLocalHost();
LOG.debug("address: {} isLoopbackAddress: {}, with host {} {}", address,
address.isLoopbackAddress(), address.getHostAddress(), address.getHostName());
// Make sure that the address is actually reachable since in some network configurations
// it is possible for the InetAddress.getLocalHost() call to return a non-reachable
// address e.g. a broadcast address
if (!isValidAddress(address, timeoutMs)) {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
// Make getNetworkInterfaces have the same order of network interfaces as listed on
// unix-like systems. This optimization can help avoid to get some special addresses, such
// as loopback address"127.0.0.1", virtual bridge address "192.168.122.1" as far as
// possible.
if (!WINDOWS) {
List<NetworkInterface> netIFs = Collections.list(networkInterfaces);
Collections.reverse(netIFs);
networkInterfaces = Collections.enumeration(netIFs);
}
while (networkInterfaces.hasMoreElements()) {
NetworkInterface ni = networkInterfaces.nextElement();
Enumeration<InetAddress> addresses = ni.getInetAddresses();
while (addresses.hasMoreElements()) {
address = addresses.nextElement();
// Address must not be link local or loopback. And it must be reachable
if (isValidAddress(address, timeoutMs)) {
sLocalIP = address.getHostAddress();
return sLocalIP;
}
}
}
LOG.warn("Your hostname, {} resolves to a loopback/non-reachable address: {}, "
+ "but we couldn't find any external IP address!",
InetAddress.getLocalHost().getHostName(), address.getHostAddress());
}
sLocalIP = address.getHostAddress();
return sLocalIP;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
java
|
public static synchronized String getLocalIpAddress(int timeoutMs) {
if (sLocalIP != null) {
return sLocalIP;
}
try {
InetAddress address = InetAddress.getLocalHost();
LOG.debug("address: {} isLoopbackAddress: {}, with host {} {}", address,
address.isLoopbackAddress(), address.getHostAddress(), address.getHostName());
// Make sure that the address is actually reachable since in some network configurations
// it is possible for the InetAddress.getLocalHost() call to return a non-reachable
// address e.g. a broadcast address
if (!isValidAddress(address, timeoutMs)) {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
// Make getNetworkInterfaces have the same order of network interfaces as listed on
// unix-like systems. This optimization can help avoid to get some special addresses, such
// as loopback address"127.0.0.1", virtual bridge address "192.168.122.1" as far as
// possible.
if (!WINDOWS) {
List<NetworkInterface> netIFs = Collections.list(networkInterfaces);
Collections.reverse(netIFs);
networkInterfaces = Collections.enumeration(netIFs);
}
while (networkInterfaces.hasMoreElements()) {
NetworkInterface ni = networkInterfaces.nextElement();
Enumeration<InetAddress> addresses = ni.getInetAddresses();
while (addresses.hasMoreElements()) {
address = addresses.nextElement();
// Address must not be link local or loopback. And it must be reachable
if (isValidAddress(address, timeoutMs)) {
sLocalIP = address.getHostAddress();
return sLocalIP;
}
}
}
LOG.warn("Your hostname, {} resolves to a loopback/non-reachable address: {}, "
+ "but we couldn't find any external IP address!",
InetAddress.getLocalHost().getHostName(), address.getHostAddress());
}
sLocalIP = address.getHostAddress();
return sLocalIP;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"static",
"synchronized",
"String",
"getLocalIpAddress",
"(",
"int",
"timeoutMs",
")",
"{",
"if",
"(",
"sLocalIP",
"!=",
"null",
")",
"{",
"return",
"sLocalIP",
";",
"}",
"try",
"{",
"InetAddress",
"address",
"=",
"InetAddress",
".",
"getLocalHost",
"(",
")",
";",
"LOG",
".",
"debug",
"(",
"\"address: {} isLoopbackAddress: {}, with host {} {}\"",
",",
"address",
",",
"address",
".",
"isLoopbackAddress",
"(",
")",
",",
"address",
".",
"getHostAddress",
"(",
")",
",",
"address",
".",
"getHostName",
"(",
")",
")",
";",
"// Make sure that the address is actually reachable since in some network configurations",
"// it is possible for the InetAddress.getLocalHost() call to return a non-reachable",
"// address e.g. a broadcast address",
"if",
"(",
"!",
"isValidAddress",
"(",
"address",
",",
"timeoutMs",
")",
")",
"{",
"Enumeration",
"<",
"NetworkInterface",
">",
"networkInterfaces",
"=",
"NetworkInterface",
".",
"getNetworkInterfaces",
"(",
")",
";",
"// Make getNetworkInterfaces have the same order of network interfaces as listed on",
"// unix-like systems. This optimization can help avoid to get some special addresses, such",
"// as loopback address\"127.0.0.1\", virtual bridge address \"192.168.122.1\" as far as",
"// possible.",
"if",
"(",
"!",
"WINDOWS",
")",
"{",
"List",
"<",
"NetworkInterface",
">",
"netIFs",
"=",
"Collections",
".",
"list",
"(",
"networkInterfaces",
")",
";",
"Collections",
".",
"reverse",
"(",
"netIFs",
")",
";",
"networkInterfaces",
"=",
"Collections",
".",
"enumeration",
"(",
"netIFs",
")",
";",
"}",
"while",
"(",
"networkInterfaces",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"NetworkInterface",
"ni",
"=",
"networkInterfaces",
".",
"nextElement",
"(",
")",
";",
"Enumeration",
"<",
"InetAddress",
">",
"addresses",
"=",
"ni",
".",
"getInetAddresses",
"(",
")",
";",
"while",
"(",
"addresses",
".",
"hasMoreElements",
"(",
")",
")",
"{",
"address",
"=",
"addresses",
".",
"nextElement",
"(",
")",
";",
"// Address must not be link local or loopback. And it must be reachable",
"if",
"(",
"isValidAddress",
"(",
"address",
",",
"timeoutMs",
")",
")",
"{",
"sLocalIP",
"=",
"address",
".",
"getHostAddress",
"(",
")",
";",
"return",
"sLocalIP",
";",
"}",
"}",
"}",
"LOG",
".",
"warn",
"(",
"\"Your hostname, {} resolves to a loopback/non-reachable address: {}, \"",
"+",
"\"but we couldn't find any external IP address!\"",
",",
"InetAddress",
".",
"getLocalHost",
"(",
")",
".",
"getHostName",
"(",
")",
",",
"address",
".",
"getHostAddress",
"(",
")",
")",
";",
"}",
"sLocalIP",
"=",
"address",
".",
"getHostAddress",
"(",
")",
";",
"return",
"sLocalIP",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Gets a local IP address for the host this JVM is running on.
@param timeoutMs Timeout in milliseconds to use for checking that a possible local IP is
reachable
@return the local ip address, which is not a loopback address and is reachable
|
[
"Gets",
"a",
"local",
"IP",
"address",
"for",
"the",
"host",
"this",
"JVM",
"is",
"running",
"on",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java#L446-L496
|
19,003
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java
|
NetworkAddressUtils.isValidAddress
|
private static boolean isValidAddress(InetAddress address, int timeoutMs) throws IOException {
return !address.isAnyLocalAddress() && !address.isLinkLocalAddress()
&& !address.isLoopbackAddress() && address.isReachable(timeoutMs)
&& (address instanceof Inet4Address);
}
|
java
|
private static boolean isValidAddress(InetAddress address, int timeoutMs) throws IOException {
return !address.isAnyLocalAddress() && !address.isLinkLocalAddress()
&& !address.isLoopbackAddress() && address.isReachable(timeoutMs)
&& (address instanceof Inet4Address);
}
|
[
"private",
"static",
"boolean",
"isValidAddress",
"(",
"InetAddress",
"address",
",",
"int",
"timeoutMs",
")",
"throws",
"IOException",
"{",
"return",
"!",
"address",
".",
"isAnyLocalAddress",
"(",
")",
"&&",
"!",
"address",
".",
"isLinkLocalAddress",
"(",
")",
"&&",
"!",
"address",
".",
"isLoopbackAddress",
"(",
")",
"&&",
"address",
".",
"isReachable",
"(",
"timeoutMs",
")",
"&&",
"(",
"address",
"instanceof",
"Inet4Address",
")",
";",
"}"
] |
Tests if the address is externally resolvable. Address must not be wildcard, link local,
loopback address, non-IPv4, or other unreachable addresses.
@param address The testing address
@param timeoutMs Timeout in milliseconds to use for checking that a possible local IP is
reachable
@return a {@code boolean} indicating if the given address is externally resolvable address
|
[
"Tests",
"if",
"the",
"address",
"is",
"externally",
"resolvable",
".",
"Address",
"must",
"not",
"be",
"wildcard",
"link",
"local",
"loopback",
"address",
"non",
"-",
"IPv4",
"or",
"other",
"unreachable",
"addresses",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java#L525-L529
|
19,004
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java
|
NetworkAddressUtils.resolveIpAddress
|
public static String resolveIpAddress(String hostname) throws UnknownHostException {
Preconditions.checkNotNull(hostname, "hostname");
Preconditions.checkArgument(!hostname.isEmpty(),
"Cannot resolve IP address for empty hostname");
return InetAddress.getByName(hostname).getHostAddress();
}
|
java
|
public static String resolveIpAddress(String hostname) throws UnknownHostException {
Preconditions.checkNotNull(hostname, "hostname");
Preconditions.checkArgument(!hostname.isEmpty(),
"Cannot resolve IP address for empty hostname");
return InetAddress.getByName(hostname).getHostAddress();
}
|
[
"public",
"static",
"String",
"resolveIpAddress",
"(",
"String",
"hostname",
")",
"throws",
"UnknownHostException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"hostname",
",",
"\"hostname\"",
")",
";",
"Preconditions",
".",
"checkArgument",
"(",
"!",
"hostname",
".",
"isEmpty",
"(",
")",
",",
"\"Cannot resolve IP address for empty hostname\"",
")",
";",
"return",
"InetAddress",
".",
"getByName",
"(",
"hostname",
")",
".",
"getHostAddress",
"(",
")",
";",
"}"
] |
Resolves a given hostname IP address.
@param hostname the input hostname, which could be an alias
@return the hostname IP address
@throws UnknownHostException if the given hostname cannot be resolved
|
[
"Resolves",
"a",
"given",
"hostname",
"IP",
"address",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java#L556-L561
|
19,005
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java
|
NetworkAddressUtils.getRpcPortSocketAddress
|
public static InetSocketAddress getRpcPortSocketAddress(WorkerNetAddress netAddress) {
String host = netAddress.getHost();
int port = netAddress.getRpcPort();
return new InetSocketAddress(host, port);
}
|
java
|
public static InetSocketAddress getRpcPortSocketAddress(WorkerNetAddress netAddress) {
String host = netAddress.getHost();
int port = netAddress.getRpcPort();
return new InetSocketAddress(host, port);
}
|
[
"public",
"static",
"InetSocketAddress",
"getRpcPortSocketAddress",
"(",
"WorkerNetAddress",
"netAddress",
")",
"{",
"String",
"host",
"=",
"netAddress",
".",
"getHost",
"(",
")",
";",
"int",
"port",
"=",
"netAddress",
".",
"getRpcPort",
"(",
")",
";",
"return",
"new",
"InetSocketAddress",
"(",
"host",
",",
"port",
")",
";",
"}"
] |
Extracts rpcPort InetSocketAddress from Alluxio representation of network address.
@param netAddress the input network address representation
@return InetSocketAddress
|
[
"Extracts",
"rpcPort",
"InetSocketAddress",
"from",
"Alluxio",
"representation",
"of",
"network",
"address",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java#L611-L615
|
19,006
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java
|
NetworkAddressUtils.getDataPortSocketAddress
|
public static SocketAddress getDataPortSocketAddress(WorkerNetAddress netAddress,
AlluxioConfiguration conf) {
SocketAddress address;
if (NettyUtils.isDomainSocketSupported(netAddress, conf)) {
address = new DomainSocketAddress(netAddress.getDomainSocketPath());
} else {
String host = netAddress.getHost();
int port = netAddress.getDataPort();
address = new InetSocketAddress(host, port);
}
return address;
}
|
java
|
public static SocketAddress getDataPortSocketAddress(WorkerNetAddress netAddress,
AlluxioConfiguration conf) {
SocketAddress address;
if (NettyUtils.isDomainSocketSupported(netAddress, conf)) {
address = new DomainSocketAddress(netAddress.getDomainSocketPath());
} else {
String host = netAddress.getHost();
int port = netAddress.getDataPort();
address = new InetSocketAddress(host, port);
}
return address;
}
|
[
"public",
"static",
"SocketAddress",
"getDataPortSocketAddress",
"(",
"WorkerNetAddress",
"netAddress",
",",
"AlluxioConfiguration",
"conf",
")",
"{",
"SocketAddress",
"address",
";",
"if",
"(",
"NettyUtils",
".",
"isDomainSocketSupported",
"(",
"netAddress",
",",
"conf",
")",
")",
"{",
"address",
"=",
"new",
"DomainSocketAddress",
"(",
"netAddress",
".",
"getDomainSocketPath",
"(",
")",
")",
";",
"}",
"else",
"{",
"String",
"host",
"=",
"netAddress",
".",
"getHost",
"(",
")",
";",
"int",
"port",
"=",
"netAddress",
".",
"getDataPort",
"(",
")",
";",
"address",
"=",
"new",
"InetSocketAddress",
"(",
"host",
",",
"port",
")",
";",
"}",
"return",
"address",
";",
"}"
] |
Extracts dataPort socket address from Alluxio representation of network address.
@param netAddress the input network address representation
@param conf Alluxio configuration
@return the socket address
|
[
"Extracts",
"dataPort",
"socket",
"address",
"from",
"Alluxio",
"representation",
"of",
"network",
"address",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java#L624-L635
|
19,007
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java
|
NetworkAddressUtils.pingService
|
public static void pingService(InetSocketAddress address, alluxio.grpc.ServiceType serviceType,
AlluxioConfiguration conf)
throws AlluxioStatusException {
Preconditions.checkNotNull(address, "address");
Preconditions.checkNotNull(serviceType, "serviceType");
GrpcChannel channel =
GrpcChannelBuilder.newBuilder(new GrpcServerAddress(address), conf).build();
ServiceVersionClientServiceGrpc.ServiceVersionClientServiceBlockingStub versionClient =
ServiceVersionClientServiceGrpc.newBlockingStub(channel);
versionClient.getServiceVersion(
GetServiceVersionPRequest.newBuilder().setServiceType(serviceType).build());
channel.shutdown();
}
|
java
|
public static void pingService(InetSocketAddress address, alluxio.grpc.ServiceType serviceType,
AlluxioConfiguration conf)
throws AlluxioStatusException {
Preconditions.checkNotNull(address, "address");
Preconditions.checkNotNull(serviceType, "serviceType");
GrpcChannel channel =
GrpcChannelBuilder.newBuilder(new GrpcServerAddress(address), conf).build();
ServiceVersionClientServiceGrpc.ServiceVersionClientServiceBlockingStub versionClient =
ServiceVersionClientServiceGrpc.newBlockingStub(channel);
versionClient.getServiceVersion(
GetServiceVersionPRequest.newBuilder().setServiceType(serviceType).build());
channel.shutdown();
}
|
[
"public",
"static",
"void",
"pingService",
"(",
"InetSocketAddress",
"address",
",",
"alluxio",
".",
"grpc",
".",
"ServiceType",
"serviceType",
",",
"AlluxioConfiguration",
"conf",
")",
"throws",
"AlluxioStatusException",
"{",
"Preconditions",
".",
"checkNotNull",
"(",
"address",
",",
"\"address\"",
")",
";",
"Preconditions",
".",
"checkNotNull",
"(",
"serviceType",
",",
"\"serviceType\"",
")",
";",
"GrpcChannel",
"channel",
"=",
"GrpcChannelBuilder",
".",
"newBuilder",
"(",
"new",
"GrpcServerAddress",
"(",
"address",
")",
",",
"conf",
")",
".",
"build",
"(",
")",
";",
"ServiceVersionClientServiceGrpc",
".",
"ServiceVersionClientServiceBlockingStub",
"versionClient",
"=",
"ServiceVersionClientServiceGrpc",
".",
"newBlockingStub",
"(",
"channel",
")",
";",
"versionClient",
".",
"getServiceVersion",
"(",
"GetServiceVersionPRequest",
".",
"newBuilder",
"(",
")",
".",
"setServiceType",
"(",
"serviceType",
")",
".",
"build",
"(",
")",
")",
";",
"channel",
".",
"shutdown",
"(",
")",
";",
"}"
] |
Test if the input address is serving an Alluxio service. This method make use of the
gRPC protocol for performing service communication.
@param address the network address to ping
@param serviceType the Alluxio service type
@param conf Alluxio configuration
@throws UnauthenticatedException If the user is not authenticated
@throws StatusRuntimeException If the host not reachable or does not serve the given service
|
[
"Test",
"if",
"the",
"input",
"address",
"is",
"serving",
"an",
"Alluxio",
"service",
".",
"This",
"method",
"make",
"use",
"of",
"the",
"gRPC",
"protocol",
"for",
"performing",
"service",
"communication",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/network/NetworkAddressUtils.java#L647-L659
|
19,008
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationChecker.java
|
ServerConfigurationChecker.regenerateReport
|
public synchronized void regenerateReport() {
// Generate the configuration map from master and worker configuration records
Map<PropertyKey, Map<Optional<String>, List<String>>> confMap = generateConfMap();
// Update the errors and warnings configuration
Map<Scope, List<InconsistentProperty>> confErrors = new HashMap<>();
Map<Scope, List<InconsistentProperty>> confWarns = new HashMap<>();
for (Map.Entry<PropertyKey, Map<Optional<String>, List<String>>> entry : confMap.entrySet()) {
if (entry.getValue().size() >= 2) {
PropertyKey key = entry.getKey();
InconsistentProperty inconsistentProperty = new InconsistentProperty()
.setName(key.getName()).setValues(entry.getValue());
Scope scope = key.getScope().equals(Scope.ALL) ? Scope.SERVER : key.getScope();
if (entry.getKey().getConsistencyLevel().equals(ConsistencyCheckLevel.ENFORCE)) {
confErrors.putIfAbsent(scope, new ArrayList<>());
confErrors.get(scope).add(inconsistentProperty);
} else {
confWarns.putIfAbsent(scope, new ArrayList<>());
confWarns.get(scope).add(inconsistentProperty);
}
}
}
// Update configuration status
ConfigStatus status = confErrors.values().stream().anyMatch(a -> a.size() > 0)
? ConfigStatus.FAILED : confWarns.values().stream().anyMatch(a -> a.size() > 0)
? ConfigStatus.WARN : ConfigStatus.PASSED;
if (!status.equals(mConfigCheckReport.getConfigStatus())) {
logConfigReport();
}
mConfigCheckReport = new ConfigCheckReport(confErrors, confWarns, status);
}
|
java
|
public synchronized void regenerateReport() {
// Generate the configuration map from master and worker configuration records
Map<PropertyKey, Map<Optional<String>, List<String>>> confMap = generateConfMap();
// Update the errors and warnings configuration
Map<Scope, List<InconsistentProperty>> confErrors = new HashMap<>();
Map<Scope, List<InconsistentProperty>> confWarns = new HashMap<>();
for (Map.Entry<PropertyKey, Map<Optional<String>, List<String>>> entry : confMap.entrySet()) {
if (entry.getValue().size() >= 2) {
PropertyKey key = entry.getKey();
InconsistentProperty inconsistentProperty = new InconsistentProperty()
.setName(key.getName()).setValues(entry.getValue());
Scope scope = key.getScope().equals(Scope.ALL) ? Scope.SERVER : key.getScope();
if (entry.getKey().getConsistencyLevel().equals(ConsistencyCheckLevel.ENFORCE)) {
confErrors.putIfAbsent(scope, new ArrayList<>());
confErrors.get(scope).add(inconsistentProperty);
} else {
confWarns.putIfAbsent(scope, new ArrayList<>());
confWarns.get(scope).add(inconsistentProperty);
}
}
}
// Update configuration status
ConfigStatus status = confErrors.values().stream().anyMatch(a -> a.size() > 0)
? ConfigStatus.FAILED : confWarns.values().stream().anyMatch(a -> a.size() > 0)
? ConfigStatus.WARN : ConfigStatus.PASSED;
if (!status.equals(mConfigCheckReport.getConfigStatus())) {
logConfigReport();
}
mConfigCheckReport = new ConfigCheckReport(confErrors, confWarns, status);
}
|
[
"public",
"synchronized",
"void",
"regenerateReport",
"(",
")",
"{",
"// Generate the configuration map from master and worker configuration records",
"Map",
"<",
"PropertyKey",
",",
"Map",
"<",
"Optional",
"<",
"String",
">",
",",
"List",
"<",
"String",
">",
">",
">",
"confMap",
"=",
"generateConfMap",
"(",
")",
";",
"// Update the errors and warnings configuration",
"Map",
"<",
"Scope",
",",
"List",
"<",
"InconsistentProperty",
">",
">",
"confErrors",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"Map",
"<",
"Scope",
",",
"List",
"<",
"InconsistentProperty",
">",
">",
"confWarns",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"PropertyKey",
",",
"Map",
"<",
"Optional",
"<",
"String",
">",
",",
"List",
"<",
"String",
">",
">",
">",
"entry",
":",
"confMap",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"size",
"(",
")",
">=",
"2",
")",
"{",
"PropertyKey",
"key",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"InconsistentProperty",
"inconsistentProperty",
"=",
"new",
"InconsistentProperty",
"(",
")",
".",
"setName",
"(",
"key",
".",
"getName",
"(",
")",
")",
".",
"setValues",
"(",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"Scope",
"scope",
"=",
"key",
".",
"getScope",
"(",
")",
".",
"equals",
"(",
"Scope",
".",
"ALL",
")",
"?",
"Scope",
".",
"SERVER",
":",
"key",
".",
"getScope",
"(",
")",
";",
"if",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"getConsistencyLevel",
"(",
")",
".",
"equals",
"(",
"ConsistencyCheckLevel",
".",
"ENFORCE",
")",
")",
"{",
"confErrors",
".",
"putIfAbsent",
"(",
"scope",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"confErrors",
".",
"get",
"(",
"scope",
")",
".",
"add",
"(",
"inconsistentProperty",
")",
";",
"}",
"else",
"{",
"confWarns",
".",
"putIfAbsent",
"(",
"scope",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"confWarns",
".",
"get",
"(",
"scope",
")",
".",
"add",
"(",
"inconsistentProperty",
")",
";",
"}",
"}",
"}",
"// Update configuration status",
"ConfigStatus",
"status",
"=",
"confErrors",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"a",
"->",
"a",
".",
"size",
"(",
")",
">",
"0",
")",
"?",
"ConfigStatus",
".",
"FAILED",
":",
"confWarns",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"anyMatch",
"(",
"a",
"->",
"a",
".",
"size",
"(",
")",
">",
"0",
")",
"?",
"ConfigStatus",
".",
"WARN",
":",
"ConfigStatus",
".",
"PASSED",
";",
"if",
"(",
"!",
"status",
".",
"equals",
"(",
"mConfigCheckReport",
".",
"getConfigStatus",
"(",
")",
")",
")",
"{",
"logConfigReport",
"(",
")",
";",
"}",
"mConfigCheckReport",
"=",
"new",
"ConfigCheckReport",
"(",
"confErrors",
",",
"confWarns",
",",
"status",
")",
";",
"}"
] |
Checks the server-side configurations and records the check results.
|
[
"Checks",
"the",
"server",
"-",
"side",
"configurations",
"and",
"records",
"the",
"check",
"results",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationChecker.java#L72-L106
|
19,009
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationChecker.java
|
ServerConfigurationChecker.logConfigReport
|
public synchronized void logConfigReport() {
ConfigStatus reportStatus = mConfigCheckReport.getConfigStatus();
if (reportStatus.equals(ConfigStatus.PASSED)) {
LOG.info(CONSISTENT_CONFIGURATION_INFO);
} else if (reportStatus.equals(ConfigStatus.WARN)) {
LOG.warn("{}\nWarnings: {}", INCONSISTENT_CONFIGURATION_INFO,
mConfigCheckReport.getConfigWarns().values().stream()
.map(Object::toString).limit(LOG_CONF_SIZE).collect(Collectors.joining(", ")));
} else {
LOG.error("{}\nErrors: {}\nWarnings: {}", INCONSISTENT_CONFIGURATION_INFO,
mConfigCheckReport.getConfigErrors().values().stream()
.map(Object::toString).limit(LOG_CONF_SIZE).collect(Collectors.joining(", ")),
mConfigCheckReport.getConfigWarns().values().stream()
.map(Object::toString).limit(LOG_CONF_SIZE).collect(Collectors.joining(", ")));
}
}
|
java
|
public synchronized void logConfigReport() {
ConfigStatus reportStatus = mConfigCheckReport.getConfigStatus();
if (reportStatus.equals(ConfigStatus.PASSED)) {
LOG.info(CONSISTENT_CONFIGURATION_INFO);
} else if (reportStatus.equals(ConfigStatus.WARN)) {
LOG.warn("{}\nWarnings: {}", INCONSISTENT_CONFIGURATION_INFO,
mConfigCheckReport.getConfigWarns().values().stream()
.map(Object::toString).limit(LOG_CONF_SIZE).collect(Collectors.joining(", ")));
} else {
LOG.error("{}\nErrors: {}\nWarnings: {}", INCONSISTENT_CONFIGURATION_INFO,
mConfigCheckReport.getConfigErrors().values().stream()
.map(Object::toString).limit(LOG_CONF_SIZE).collect(Collectors.joining(", ")),
mConfigCheckReport.getConfigWarns().values().stream()
.map(Object::toString).limit(LOG_CONF_SIZE).collect(Collectors.joining(", ")));
}
}
|
[
"public",
"synchronized",
"void",
"logConfigReport",
"(",
")",
"{",
"ConfigStatus",
"reportStatus",
"=",
"mConfigCheckReport",
".",
"getConfigStatus",
"(",
")",
";",
"if",
"(",
"reportStatus",
".",
"equals",
"(",
"ConfigStatus",
".",
"PASSED",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"CONSISTENT_CONFIGURATION_INFO",
")",
";",
"}",
"else",
"if",
"(",
"reportStatus",
".",
"equals",
"(",
"ConfigStatus",
".",
"WARN",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"{}\\nWarnings: {}\"",
",",
"INCONSISTENT_CONFIGURATION_INFO",
",",
"mConfigCheckReport",
".",
"getConfigWarns",
"(",
")",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Object",
"::",
"toString",
")",
".",
"limit",
"(",
"LOG_CONF_SIZE",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\", \"",
")",
")",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"error",
"(",
"\"{}\\nErrors: {}\\nWarnings: {}\"",
",",
"INCONSISTENT_CONFIGURATION_INFO",
",",
"mConfigCheckReport",
".",
"getConfigErrors",
"(",
")",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Object",
"::",
"toString",
")",
".",
"limit",
"(",
"LOG_CONF_SIZE",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\", \"",
")",
")",
",",
"mConfigCheckReport",
".",
"getConfigWarns",
"(",
")",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Object",
"::",
"toString",
")",
".",
"limit",
"(",
"LOG_CONF_SIZE",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\", \"",
")",
")",
")",
";",
"}",
"}"
] |
Logs the configuration check report information.
|
[
"Logs",
"the",
"configuration",
"check",
"report",
"information",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationChecker.java#L128-L143
|
19,010
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationChecker.java
|
ServerConfigurationChecker.fillConfMap
|
private void fillConfMap(Map<PropertyKey, Map<Optional<String>, List<String>>> targetMap,
Map<Address, List<ConfigRecord>> recordMap) {
for (Map.Entry<Address, List<ConfigRecord>> record : recordMap.entrySet()) {
Address address = record.getKey();
String addressStr = String.format("%s:%s", address.getHost(), address.getRpcPort());
for (ConfigRecord conf : record.getValue()) {
PropertyKey key = conf.getKey();
if (key.getConsistencyLevel() == ConsistencyCheckLevel.IGNORE) {
continue;
}
Optional<String> value = conf.getValue();
targetMap.putIfAbsent(key, new HashMap<>());
Map<Optional<String>, List<String>> values = targetMap.get(key);
values.putIfAbsent(value, new ArrayList<>());
values.get(value).add(addressStr);
}
}
}
|
java
|
private void fillConfMap(Map<PropertyKey, Map<Optional<String>, List<String>>> targetMap,
Map<Address, List<ConfigRecord>> recordMap) {
for (Map.Entry<Address, List<ConfigRecord>> record : recordMap.entrySet()) {
Address address = record.getKey();
String addressStr = String.format("%s:%s", address.getHost(), address.getRpcPort());
for (ConfigRecord conf : record.getValue()) {
PropertyKey key = conf.getKey();
if (key.getConsistencyLevel() == ConsistencyCheckLevel.IGNORE) {
continue;
}
Optional<String> value = conf.getValue();
targetMap.putIfAbsent(key, new HashMap<>());
Map<Optional<String>, List<String>> values = targetMap.get(key);
values.putIfAbsent(value, new ArrayList<>());
values.get(value).add(addressStr);
}
}
}
|
[
"private",
"void",
"fillConfMap",
"(",
"Map",
"<",
"PropertyKey",
",",
"Map",
"<",
"Optional",
"<",
"String",
">",
",",
"List",
"<",
"String",
">",
">",
">",
"targetMap",
",",
"Map",
"<",
"Address",
",",
"List",
"<",
"ConfigRecord",
">",
">",
"recordMap",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Address",
",",
"List",
"<",
"ConfigRecord",
">",
">",
"record",
":",
"recordMap",
".",
"entrySet",
"(",
")",
")",
"{",
"Address",
"address",
"=",
"record",
".",
"getKey",
"(",
")",
";",
"String",
"addressStr",
"=",
"String",
".",
"format",
"(",
"\"%s:%s\"",
",",
"address",
".",
"getHost",
"(",
")",
",",
"address",
".",
"getRpcPort",
"(",
")",
")",
";",
"for",
"(",
"ConfigRecord",
"conf",
":",
"record",
".",
"getValue",
"(",
")",
")",
"{",
"PropertyKey",
"key",
"=",
"conf",
".",
"getKey",
"(",
")",
";",
"if",
"(",
"key",
".",
"getConsistencyLevel",
"(",
")",
"==",
"ConsistencyCheckLevel",
".",
"IGNORE",
")",
"{",
"continue",
";",
"}",
"Optional",
"<",
"String",
">",
"value",
"=",
"conf",
".",
"getValue",
"(",
")",
";",
"targetMap",
".",
"putIfAbsent",
"(",
"key",
",",
"new",
"HashMap",
"<>",
"(",
")",
")",
";",
"Map",
"<",
"Optional",
"<",
"String",
">",
",",
"List",
"<",
"String",
">",
">",
"values",
"=",
"targetMap",
".",
"get",
"(",
"key",
")",
";",
"values",
".",
"putIfAbsent",
"(",
"value",
",",
"new",
"ArrayList",
"<>",
"(",
")",
")",
";",
"values",
".",
"get",
"(",
"value",
")",
".",
"add",
"(",
"addressStr",
")",
";",
"}",
"}",
"}"
] |
Fills the configuration map.
@param targetMap the map to fill
@param recordMap the map to get data from
|
[
"Fills",
"the",
"configuration",
"map",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/checkconf/ServerConfigurationChecker.java#L164-L181
|
19,011
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/file/FileInStream.java
|
FileInStream.updateStream
|
private void updateStream() throws IOException {
if (mBlockInStream != null && mBlockInStream.remaining() > 0) { // can still read from stream
return;
}
if (mBlockInStream != null && mBlockInStream.remaining() == 0) { // current stream is done
closeBlockInStream(mBlockInStream);
}
/* Create a new stream to read from mPosition. */
// Calculate block id.
long blockId = mStatus.getBlockIds().get(Math.toIntExact(mPosition / mBlockSize));
// Create stream
mBlockInStream = mBlockStore.getInStream(blockId, mOptions, mFailedWorkers);
// Set the stream to the correct position.
long offset = mPosition % mBlockSize;
mBlockInStream.seek(offset);
}
|
java
|
private void updateStream() throws IOException {
if (mBlockInStream != null && mBlockInStream.remaining() > 0) { // can still read from stream
return;
}
if (mBlockInStream != null && mBlockInStream.remaining() == 0) { // current stream is done
closeBlockInStream(mBlockInStream);
}
/* Create a new stream to read from mPosition. */
// Calculate block id.
long blockId = mStatus.getBlockIds().get(Math.toIntExact(mPosition / mBlockSize));
// Create stream
mBlockInStream = mBlockStore.getInStream(blockId, mOptions, mFailedWorkers);
// Set the stream to the correct position.
long offset = mPosition % mBlockSize;
mBlockInStream.seek(offset);
}
|
[
"private",
"void",
"updateStream",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mBlockInStream",
"!=",
"null",
"&&",
"mBlockInStream",
".",
"remaining",
"(",
")",
">",
"0",
")",
"{",
"// can still read from stream",
"return",
";",
"}",
"if",
"(",
"mBlockInStream",
"!=",
"null",
"&&",
"mBlockInStream",
".",
"remaining",
"(",
")",
"==",
"0",
")",
"{",
"// current stream is done",
"closeBlockInStream",
"(",
"mBlockInStream",
")",
";",
"}",
"/* Create a new stream to read from mPosition. */",
"// Calculate block id.",
"long",
"blockId",
"=",
"mStatus",
".",
"getBlockIds",
"(",
")",
".",
"get",
"(",
"Math",
".",
"toIntExact",
"(",
"mPosition",
"/",
"mBlockSize",
")",
")",
";",
"// Create stream",
"mBlockInStream",
"=",
"mBlockStore",
".",
"getInStream",
"(",
"blockId",
",",
"mOptions",
",",
"mFailedWorkers",
")",
";",
"// Set the stream to the correct position.",
"long",
"offset",
"=",
"mPosition",
"%",
"mBlockSize",
";",
"mBlockInStream",
".",
"seek",
"(",
"offset",
")",
";",
"}"
] |
Initializes the underlying block stream if necessary. This method must be called before
reading from mBlockInStream.
|
[
"Initializes",
"the",
"underlying",
"block",
"stream",
"if",
"necessary",
".",
"This",
"method",
"must",
"be",
"called",
"before",
"reading",
"from",
"mBlockInStream",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/file/FileInStream.java#L298-L315
|
19,012
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/file/FileInStream.java
|
FileInStream.triggerAsyncCaching
|
private void triggerAsyncCaching(BlockInStream stream) throws IOException {
boolean cache = ReadType.fromProto(mOptions.getOptions().getReadType()).isCache();
boolean overReplicated = mStatus.getReplicationMax() > 0
&& mStatus.getFileBlockInfos().get((int) (getPos() / mBlockSize))
.getBlockInfo().getLocations().size() >= mStatus.getReplicationMax();
cache = cache && !overReplicated;
// Get relevant information from the stream.
WorkerNetAddress dataSource = stream.getAddress();
long blockId = stream.getId();
if (cache && (mLastBlockIdCached != blockId)) {
WorkerNetAddress worker;
if (mPassiveCachingEnabled && mContext.hasLocalWorker()) { // send request to local worker
worker = mContext.getLocalWorker();
} else { // send request to data source
worker = dataSource;
}
try {
// Construct the async cache request
long blockLength = mOptions.getBlockInfo(blockId).getLength();
AsyncCacheRequest request =
AsyncCacheRequest.newBuilder().setBlockId(blockId).setLength(blockLength)
.setOpenUfsBlockOptions(mOptions.getOpenUfsBlockOptions(blockId))
.setSourceHost(dataSource.getHost()).setSourcePort(dataSource.getDataPort())
.build();
BlockWorkerClient blockWorker = mContext.acquireBlockWorkerClient(worker);
try {
blockWorker.asyncCache(request);
mLastBlockIdCached = blockId;
} finally {
mContext.releaseBlockWorkerClient(worker, blockWorker);
}
} catch (Exception e) {
LOG.warn("Failed to complete async cache request for block {} at worker {}: {}", blockId,
worker, e.getMessage());
}
}
}
|
java
|
private void triggerAsyncCaching(BlockInStream stream) throws IOException {
boolean cache = ReadType.fromProto(mOptions.getOptions().getReadType()).isCache();
boolean overReplicated = mStatus.getReplicationMax() > 0
&& mStatus.getFileBlockInfos().get((int) (getPos() / mBlockSize))
.getBlockInfo().getLocations().size() >= mStatus.getReplicationMax();
cache = cache && !overReplicated;
// Get relevant information from the stream.
WorkerNetAddress dataSource = stream.getAddress();
long blockId = stream.getId();
if (cache && (mLastBlockIdCached != blockId)) {
WorkerNetAddress worker;
if (mPassiveCachingEnabled && mContext.hasLocalWorker()) { // send request to local worker
worker = mContext.getLocalWorker();
} else { // send request to data source
worker = dataSource;
}
try {
// Construct the async cache request
long blockLength = mOptions.getBlockInfo(blockId).getLength();
AsyncCacheRequest request =
AsyncCacheRequest.newBuilder().setBlockId(blockId).setLength(blockLength)
.setOpenUfsBlockOptions(mOptions.getOpenUfsBlockOptions(blockId))
.setSourceHost(dataSource.getHost()).setSourcePort(dataSource.getDataPort())
.build();
BlockWorkerClient blockWorker = mContext.acquireBlockWorkerClient(worker);
try {
blockWorker.asyncCache(request);
mLastBlockIdCached = blockId;
} finally {
mContext.releaseBlockWorkerClient(worker, blockWorker);
}
} catch (Exception e) {
LOG.warn("Failed to complete async cache request for block {} at worker {}: {}", blockId,
worker, e.getMessage());
}
}
}
|
[
"private",
"void",
"triggerAsyncCaching",
"(",
"BlockInStream",
"stream",
")",
"throws",
"IOException",
"{",
"boolean",
"cache",
"=",
"ReadType",
".",
"fromProto",
"(",
"mOptions",
".",
"getOptions",
"(",
")",
".",
"getReadType",
"(",
")",
")",
".",
"isCache",
"(",
")",
";",
"boolean",
"overReplicated",
"=",
"mStatus",
".",
"getReplicationMax",
"(",
")",
">",
"0",
"&&",
"mStatus",
".",
"getFileBlockInfos",
"(",
")",
".",
"get",
"(",
"(",
"int",
")",
"(",
"getPos",
"(",
")",
"/",
"mBlockSize",
")",
")",
".",
"getBlockInfo",
"(",
")",
".",
"getLocations",
"(",
")",
".",
"size",
"(",
")",
">=",
"mStatus",
".",
"getReplicationMax",
"(",
")",
";",
"cache",
"=",
"cache",
"&&",
"!",
"overReplicated",
";",
"// Get relevant information from the stream.",
"WorkerNetAddress",
"dataSource",
"=",
"stream",
".",
"getAddress",
"(",
")",
";",
"long",
"blockId",
"=",
"stream",
".",
"getId",
"(",
")",
";",
"if",
"(",
"cache",
"&&",
"(",
"mLastBlockIdCached",
"!=",
"blockId",
")",
")",
"{",
"WorkerNetAddress",
"worker",
";",
"if",
"(",
"mPassiveCachingEnabled",
"&&",
"mContext",
".",
"hasLocalWorker",
"(",
")",
")",
"{",
"// send request to local worker",
"worker",
"=",
"mContext",
".",
"getLocalWorker",
"(",
")",
";",
"}",
"else",
"{",
"// send request to data source",
"worker",
"=",
"dataSource",
";",
"}",
"try",
"{",
"// Construct the async cache request",
"long",
"blockLength",
"=",
"mOptions",
".",
"getBlockInfo",
"(",
"blockId",
")",
".",
"getLength",
"(",
")",
";",
"AsyncCacheRequest",
"request",
"=",
"AsyncCacheRequest",
".",
"newBuilder",
"(",
")",
".",
"setBlockId",
"(",
"blockId",
")",
".",
"setLength",
"(",
"blockLength",
")",
".",
"setOpenUfsBlockOptions",
"(",
"mOptions",
".",
"getOpenUfsBlockOptions",
"(",
"blockId",
")",
")",
".",
"setSourceHost",
"(",
"dataSource",
".",
"getHost",
"(",
")",
")",
".",
"setSourcePort",
"(",
"dataSource",
".",
"getDataPort",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"BlockWorkerClient",
"blockWorker",
"=",
"mContext",
".",
"acquireBlockWorkerClient",
"(",
"worker",
")",
";",
"try",
"{",
"blockWorker",
".",
"asyncCache",
"(",
"request",
")",
";",
"mLastBlockIdCached",
"=",
"blockId",
";",
"}",
"finally",
"{",
"mContext",
".",
"releaseBlockWorkerClient",
"(",
"worker",
",",
"blockWorker",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to complete async cache request for block {} at worker {}: {}\"",
",",
"blockId",
",",
"worker",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Send an async cache request to a worker based on read type and passive cache options.
|
[
"Send",
"an",
"async",
"cache",
"request",
"to",
"a",
"worker",
"based",
"on",
"read",
"type",
"and",
"passive",
"cache",
"options",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/file/FileInStream.java#L333-L369
|
19,013
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/DailyMetadataBackup.java
|
DailyMetadataBackup.getTimeToNextBackup
|
private long getTimeToNextBackup() {
LocalDateTime now = LocalDateTime.now(Clock.systemUTC());
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("H:mm");
LocalTime backupTime = LocalTime.parse(ServerConfiguration
.get(PropertyKey.MASTER_DAILY_BACKUP_TIME), formatter);
LocalDateTime nextBackupTime = now.withHour(backupTime.getHour())
.withMinute(backupTime.getMinute());
if (nextBackupTime.isBefore(now)) {
nextBackupTime = nextBackupTime.plusDays(1);
}
return ChronoUnit.MILLIS.between(now, nextBackupTime);
}
|
java
|
private long getTimeToNextBackup() {
LocalDateTime now = LocalDateTime.now(Clock.systemUTC());
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("H:mm");
LocalTime backupTime = LocalTime.parse(ServerConfiguration
.get(PropertyKey.MASTER_DAILY_BACKUP_TIME), formatter);
LocalDateTime nextBackupTime = now.withHour(backupTime.getHour())
.withMinute(backupTime.getMinute());
if (nextBackupTime.isBefore(now)) {
nextBackupTime = nextBackupTime.plusDays(1);
}
return ChronoUnit.MILLIS.between(now, nextBackupTime);
}
|
[
"private",
"long",
"getTimeToNextBackup",
"(",
")",
"{",
"LocalDateTime",
"now",
"=",
"LocalDateTime",
".",
"now",
"(",
"Clock",
".",
"systemUTC",
"(",
")",
")",
";",
"DateTimeFormatter",
"formatter",
"=",
"DateTimeFormatter",
".",
"ofPattern",
"(",
"\"H:mm\"",
")",
";",
"LocalTime",
"backupTime",
"=",
"LocalTime",
".",
"parse",
"(",
"ServerConfiguration",
".",
"get",
"(",
"PropertyKey",
".",
"MASTER_DAILY_BACKUP_TIME",
")",
",",
"formatter",
")",
";",
"LocalDateTime",
"nextBackupTime",
"=",
"now",
".",
"withHour",
"(",
"backupTime",
".",
"getHour",
"(",
")",
")",
".",
"withMinute",
"(",
"backupTime",
".",
"getMinute",
"(",
")",
")",
";",
"if",
"(",
"nextBackupTime",
".",
"isBefore",
"(",
"now",
")",
")",
"{",
"nextBackupTime",
"=",
"nextBackupTime",
".",
"plusDays",
"(",
"1",
")",
";",
"}",
"return",
"ChronoUnit",
".",
"MILLIS",
".",
"between",
"(",
"now",
",",
"nextBackupTime",
")",
";",
"}"
] |
Gets the time gap between now and next backup time.
@return the time gap to next backup
|
[
"Gets",
"the",
"time",
"gap",
"between",
"now",
"and",
"next",
"backup",
"time",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/DailyMetadataBackup.java#L92-L104
|
19,014
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/DailyMetadataBackup.java
|
DailyMetadataBackup.dailyBackup
|
private void dailyBackup() {
try {
BackupResponse resp = mMetaMaster.backup(BackupPOptions.newBuilder()
.setTargetDirectory(mBackupDir).setLocalFileSystem(mIsLocal).build());
if (mIsLocal) {
LOG.info("Successfully backed up journal to {} on master {}",
resp.getBackupUri(), resp.getHostname());
} else {
LOG.info("Successfully backed up journal to {}", resp.getBackupUri());
}
} catch (Throwable t) {
LOG.error("Failed to execute daily backup at {}", mBackupDir, t);
return;
}
try {
deleteStaleBackups();
} catch (Throwable t) {
LOG.error("Failed to delete outdated backup files at {}", mBackupDir, t);
}
}
|
java
|
private void dailyBackup() {
try {
BackupResponse resp = mMetaMaster.backup(BackupPOptions.newBuilder()
.setTargetDirectory(mBackupDir).setLocalFileSystem(mIsLocal).build());
if (mIsLocal) {
LOG.info("Successfully backed up journal to {} on master {}",
resp.getBackupUri(), resp.getHostname());
} else {
LOG.info("Successfully backed up journal to {}", resp.getBackupUri());
}
} catch (Throwable t) {
LOG.error("Failed to execute daily backup at {}", mBackupDir, t);
return;
}
try {
deleteStaleBackups();
} catch (Throwable t) {
LOG.error("Failed to delete outdated backup files at {}", mBackupDir, t);
}
}
|
[
"private",
"void",
"dailyBackup",
"(",
")",
"{",
"try",
"{",
"BackupResponse",
"resp",
"=",
"mMetaMaster",
".",
"backup",
"(",
"BackupPOptions",
".",
"newBuilder",
"(",
")",
".",
"setTargetDirectory",
"(",
"mBackupDir",
")",
".",
"setLocalFileSystem",
"(",
"mIsLocal",
")",
".",
"build",
"(",
")",
")",
";",
"if",
"(",
"mIsLocal",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Successfully backed up journal to {} on master {}\"",
",",
"resp",
".",
"getBackupUri",
"(",
")",
",",
"resp",
".",
"getHostname",
"(",
")",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"info",
"(",
"\"Successfully backed up journal to {}\"",
",",
"resp",
".",
"getBackupUri",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to execute daily backup at {}\"",
",",
"mBackupDir",
",",
"t",
")",
";",
"return",
";",
"}",
"try",
"{",
"deleteStaleBackups",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to delete outdated backup files at {}\"",
",",
"mBackupDir",
",",
"t",
")",
";",
"}",
"}"
] |
The daily backup task.
|
[
"The",
"daily",
"backup",
"task",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/DailyMetadataBackup.java#L109-L129
|
19,015
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/DailyMetadataBackup.java
|
DailyMetadataBackup.deleteStaleBackups
|
private void deleteStaleBackups() throws Exception {
UfsStatus[] statuses = mUfs.listStatus(mBackupDir);
if (statuses.length <= mRetainedFiles) {
return;
}
// Sort the backup files according to create time from oldest to newest
TreeMap<Instant, String> timeToFile = new TreeMap<>((a, b) -> (
a.isBefore(b) ? -1 : a.isAfter(b) ? 1 : 0));
for (UfsStatus status : statuses) {
if (status.isFile()) {
Matcher matcher = BackupManager.BACKUP_FILE_PATTERN.matcher(status.getName());
if (matcher.matches()) {
timeToFile.put(Instant.ofEpochMilli(Long.parseLong(matcher.group(1))),
status.getName());
}
}
}
int toDeleteFileNum = timeToFile.size() - mRetainedFiles;
if (toDeleteFileNum <= 0) {
return;
}
for (int i = 0; i < toDeleteFileNum; i++) {
String toDeleteFile = PathUtils.concatPath(mBackupDir,
timeToFile.pollFirstEntry().getValue());
mUfs.deleteExistingFile(toDeleteFile);
}
LOG.info("Deleted {} stale metadata backup files at {}", toDeleteFileNum, mBackupDir);
}
|
java
|
private void deleteStaleBackups() throws Exception {
UfsStatus[] statuses = mUfs.listStatus(mBackupDir);
if (statuses.length <= mRetainedFiles) {
return;
}
// Sort the backup files according to create time from oldest to newest
TreeMap<Instant, String> timeToFile = new TreeMap<>((a, b) -> (
a.isBefore(b) ? -1 : a.isAfter(b) ? 1 : 0));
for (UfsStatus status : statuses) {
if (status.isFile()) {
Matcher matcher = BackupManager.BACKUP_FILE_PATTERN.matcher(status.getName());
if (matcher.matches()) {
timeToFile.put(Instant.ofEpochMilli(Long.parseLong(matcher.group(1))),
status.getName());
}
}
}
int toDeleteFileNum = timeToFile.size() - mRetainedFiles;
if (toDeleteFileNum <= 0) {
return;
}
for (int i = 0; i < toDeleteFileNum; i++) {
String toDeleteFile = PathUtils.concatPath(mBackupDir,
timeToFile.pollFirstEntry().getValue());
mUfs.deleteExistingFile(toDeleteFile);
}
LOG.info("Deleted {} stale metadata backup files at {}", toDeleteFileNum, mBackupDir);
}
|
[
"private",
"void",
"deleteStaleBackups",
"(",
")",
"throws",
"Exception",
"{",
"UfsStatus",
"[",
"]",
"statuses",
"=",
"mUfs",
".",
"listStatus",
"(",
"mBackupDir",
")",
";",
"if",
"(",
"statuses",
".",
"length",
"<=",
"mRetainedFiles",
")",
"{",
"return",
";",
"}",
"// Sort the backup files according to create time from oldest to newest",
"TreeMap",
"<",
"Instant",
",",
"String",
">",
"timeToFile",
"=",
"new",
"TreeMap",
"<>",
"(",
"(",
"a",
",",
"b",
")",
"->",
"(",
"a",
".",
"isBefore",
"(",
"b",
")",
"?",
"-",
"1",
":",
"a",
".",
"isAfter",
"(",
"b",
")",
"?",
"1",
":",
"0",
")",
")",
";",
"for",
"(",
"UfsStatus",
"status",
":",
"statuses",
")",
"{",
"if",
"(",
"status",
".",
"isFile",
"(",
")",
")",
"{",
"Matcher",
"matcher",
"=",
"BackupManager",
".",
"BACKUP_FILE_PATTERN",
".",
"matcher",
"(",
"status",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"matcher",
".",
"matches",
"(",
")",
")",
"{",
"timeToFile",
".",
"put",
"(",
"Instant",
".",
"ofEpochMilli",
"(",
"Long",
".",
"parseLong",
"(",
"matcher",
".",
"group",
"(",
"1",
")",
")",
")",
",",
"status",
".",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}",
"int",
"toDeleteFileNum",
"=",
"timeToFile",
".",
"size",
"(",
")",
"-",
"mRetainedFiles",
";",
"if",
"(",
"toDeleteFileNum",
"<=",
"0",
")",
"{",
"return",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"toDeleteFileNum",
";",
"i",
"++",
")",
"{",
"String",
"toDeleteFile",
"=",
"PathUtils",
".",
"concatPath",
"(",
"mBackupDir",
",",
"timeToFile",
".",
"pollFirstEntry",
"(",
")",
".",
"getValue",
"(",
")",
")",
";",
"mUfs",
".",
"deleteExistingFile",
"(",
"toDeleteFile",
")",
";",
"}",
"LOG",
".",
"info",
"(",
"\"Deleted {} stale metadata backup files at {}\"",
",",
"toDeleteFileNum",
",",
"mBackupDir",
")",
";",
"}"
] |
Deletes stale backup files to avoid consuming too many spaces.
|
[
"Deletes",
"stale",
"backup",
"files",
"to",
"avoid",
"consuming",
"too",
"many",
"spaces",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/DailyMetadataBackup.java#L134-L163
|
19,016
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/AsyncCacheRequestManager.java
|
AsyncCacheRequestManager.submitRequest
|
public void submitRequest(AsyncCacheRequest request) {
ASYNC_CACHE_REQUESTS.inc();
long blockId = request.getBlockId();
long blockLength = request.getLength();
if (mPendingRequests.putIfAbsent(blockId, request) != null) {
// This block is already planned.
ASYNC_CACHE_DUPLICATE_REQUESTS.inc();
return;
}
try {
mAsyncCacheExecutor.submit(() -> {
boolean result = false;
try {
// Check if the block has already been cached on this worker
long lockId = mBlockWorker.lockBlockNoException(Sessions.ASYNC_CACHE_SESSION_ID, blockId);
if (lockId != BlockLockManager.INVALID_LOCK_ID) {
try {
mBlockWorker.unlockBlock(lockId);
} catch (BlockDoesNotExistException e) {
LOG.error("Failed to unlock block on async caching. We should never reach here", e);
}
ASYNC_CACHE_DUPLICATE_REQUESTS.inc();
return;
}
Protocol.OpenUfsBlockOptions openUfsBlockOptions = request.getOpenUfsBlockOptions();
boolean isSourceLocal = mLocalWorkerHostname.equals(request.getSourceHost());
// Depends on the request, cache the target block from different sources
if (isSourceLocal) {
ASYNC_CACHE_UFS_BLOCKS.inc();
result = cacheBlockFromUfs(blockId, blockLength, openUfsBlockOptions);
} else {
ASYNC_CACHE_REMOTE_BLOCKS.inc();
InetSocketAddress sourceAddress =
new InetSocketAddress(request.getSourceHost(), request.getSourcePort());
result = cacheBlockFromRemoteWorker(
blockId, blockLength, sourceAddress, openUfsBlockOptions);
}
LOG.debug("Result of async caching block {}: {}", blockId, result);
} catch (Exception e) {
LOG.warn("Async cache request failed.\n{}\nError: {}", request, e);
} finally {
if (result) {
ASYNC_CACHE_SUCCEEDED_BLOCKS.inc();
} else {
ASYNC_CACHE_FAILED_BLOCKS.inc();
}
mPendingRequests.remove(blockId);
}
});
} catch (Exception e) {
// RuntimeExceptions (e.g. RejectedExecutionException) may be thrown in extreme cases when the
// gRPC thread pool is drained due to highly concurrent caching workloads. In these cases,
// return as async caching is at best effort.
LOG.warn("Failed to submit async cache request.\n{}\nError: {}", request, e);
ASYNC_CACHE_FAILED_BLOCKS.inc();
mPendingRequests.remove(blockId);
}
}
|
java
|
public void submitRequest(AsyncCacheRequest request) {
ASYNC_CACHE_REQUESTS.inc();
long blockId = request.getBlockId();
long blockLength = request.getLength();
if (mPendingRequests.putIfAbsent(blockId, request) != null) {
// This block is already planned.
ASYNC_CACHE_DUPLICATE_REQUESTS.inc();
return;
}
try {
mAsyncCacheExecutor.submit(() -> {
boolean result = false;
try {
// Check if the block has already been cached on this worker
long lockId = mBlockWorker.lockBlockNoException(Sessions.ASYNC_CACHE_SESSION_ID, blockId);
if (lockId != BlockLockManager.INVALID_LOCK_ID) {
try {
mBlockWorker.unlockBlock(lockId);
} catch (BlockDoesNotExistException e) {
LOG.error("Failed to unlock block on async caching. We should never reach here", e);
}
ASYNC_CACHE_DUPLICATE_REQUESTS.inc();
return;
}
Protocol.OpenUfsBlockOptions openUfsBlockOptions = request.getOpenUfsBlockOptions();
boolean isSourceLocal = mLocalWorkerHostname.equals(request.getSourceHost());
// Depends on the request, cache the target block from different sources
if (isSourceLocal) {
ASYNC_CACHE_UFS_BLOCKS.inc();
result = cacheBlockFromUfs(blockId, blockLength, openUfsBlockOptions);
} else {
ASYNC_CACHE_REMOTE_BLOCKS.inc();
InetSocketAddress sourceAddress =
new InetSocketAddress(request.getSourceHost(), request.getSourcePort());
result = cacheBlockFromRemoteWorker(
blockId, blockLength, sourceAddress, openUfsBlockOptions);
}
LOG.debug("Result of async caching block {}: {}", blockId, result);
} catch (Exception e) {
LOG.warn("Async cache request failed.\n{}\nError: {}", request, e);
} finally {
if (result) {
ASYNC_CACHE_SUCCEEDED_BLOCKS.inc();
} else {
ASYNC_CACHE_FAILED_BLOCKS.inc();
}
mPendingRequests.remove(blockId);
}
});
} catch (Exception e) {
// RuntimeExceptions (e.g. RejectedExecutionException) may be thrown in extreme cases when the
// gRPC thread pool is drained due to highly concurrent caching workloads. In these cases,
// return as async caching is at best effort.
LOG.warn("Failed to submit async cache request.\n{}\nError: {}", request, e);
ASYNC_CACHE_FAILED_BLOCKS.inc();
mPendingRequests.remove(blockId);
}
}
|
[
"public",
"void",
"submitRequest",
"(",
"AsyncCacheRequest",
"request",
")",
"{",
"ASYNC_CACHE_REQUESTS",
".",
"inc",
"(",
")",
";",
"long",
"blockId",
"=",
"request",
".",
"getBlockId",
"(",
")",
";",
"long",
"blockLength",
"=",
"request",
".",
"getLength",
"(",
")",
";",
"if",
"(",
"mPendingRequests",
".",
"putIfAbsent",
"(",
"blockId",
",",
"request",
")",
"!=",
"null",
")",
"{",
"// This block is already planned.",
"ASYNC_CACHE_DUPLICATE_REQUESTS",
".",
"inc",
"(",
")",
";",
"return",
";",
"}",
"try",
"{",
"mAsyncCacheExecutor",
".",
"submit",
"(",
"(",
")",
"->",
"{",
"boolean",
"result",
"=",
"false",
";",
"try",
"{",
"// Check if the block has already been cached on this worker",
"long",
"lockId",
"=",
"mBlockWorker",
".",
"lockBlockNoException",
"(",
"Sessions",
".",
"ASYNC_CACHE_SESSION_ID",
",",
"blockId",
")",
";",
"if",
"(",
"lockId",
"!=",
"BlockLockManager",
".",
"INVALID_LOCK_ID",
")",
"{",
"try",
"{",
"mBlockWorker",
".",
"unlockBlock",
"(",
"lockId",
")",
";",
"}",
"catch",
"(",
"BlockDoesNotExistException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to unlock block on async caching. We should never reach here\"",
",",
"e",
")",
";",
"}",
"ASYNC_CACHE_DUPLICATE_REQUESTS",
".",
"inc",
"(",
")",
";",
"return",
";",
"}",
"Protocol",
".",
"OpenUfsBlockOptions",
"openUfsBlockOptions",
"=",
"request",
".",
"getOpenUfsBlockOptions",
"(",
")",
";",
"boolean",
"isSourceLocal",
"=",
"mLocalWorkerHostname",
".",
"equals",
"(",
"request",
".",
"getSourceHost",
"(",
")",
")",
";",
"// Depends on the request, cache the target block from different sources",
"if",
"(",
"isSourceLocal",
")",
"{",
"ASYNC_CACHE_UFS_BLOCKS",
".",
"inc",
"(",
")",
";",
"result",
"=",
"cacheBlockFromUfs",
"(",
"blockId",
",",
"blockLength",
",",
"openUfsBlockOptions",
")",
";",
"}",
"else",
"{",
"ASYNC_CACHE_REMOTE_BLOCKS",
".",
"inc",
"(",
")",
";",
"InetSocketAddress",
"sourceAddress",
"=",
"new",
"InetSocketAddress",
"(",
"request",
".",
"getSourceHost",
"(",
")",
",",
"request",
".",
"getSourcePort",
"(",
")",
")",
";",
"result",
"=",
"cacheBlockFromRemoteWorker",
"(",
"blockId",
",",
"blockLength",
",",
"sourceAddress",
",",
"openUfsBlockOptions",
")",
";",
"}",
"LOG",
".",
"debug",
"(",
"\"Result of async caching block {}: {}\"",
",",
"blockId",
",",
"result",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Async cache request failed.\\n{}\\nError: {}\"",
",",
"request",
",",
"e",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"result",
")",
"{",
"ASYNC_CACHE_SUCCEEDED_BLOCKS",
".",
"inc",
"(",
")",
";",
"}",
"else",
"{",
"ASYNC_CACHE_FAILED_BLOCKS",
".",
"inc",
"(",
")",
";",
"}",
"mPendingRequests",
".",
"remove",
"(",
"blockId",
")",
";",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// RuntimeExceptions (e.g. RejectedExecutionException) may be thrown in extreme cases when the",
"// gRPC thread pool is drained due to highly concurrent caching workloads. In these cases,",
"// return as async caching is at best effort.",
"LOG",
".",
"warn",
"(",
"\"Failed to submit async cache request.\\n{}\\nError: {}\"",
",",
"request",
",",
"e",
")",
";",
"ASYNC_CACHE_FAILED_BLOCKS",
".",
"inc",
"(",
")",
";",
"mPendingRequests",
".",
"remove",
"(",
"blockId",
")",
";",
"}",
"}"
] |
Handles a request to cache a block asynchronously. This is a non-blocking call.
@param request the async cache request fields will be available
|
[
"Handles",
"a",
"request",
"to",
"cache",
"a",
"block",
"asynchronously",
".",
"This",
"is",
"a",
"non",
"-",
"blocking",
"call",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/AsyncCacheRequestManager.java#L81-L138
|
19,017
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/AsyncCacheRequestManager.java
|
AsyncCacheRequestManager.cacheBlockFromUfs
|
private boolean cacheBlockFromUfs(long blockId, long blockSize,
Protocol.OpenUfsBlockOptions openUfsBlockOptions) {
// Check if the block has been requested in UFS block store
try {
if (!mBlockWorker
.openUfsBlock(Sessions.ASYNC_CACHE_SESSION_ID, blockId, openUfsBlockOptions)) {
LOG.warn("Failed to async cache block {} from UFS on opening the block", blockId);
return false;
}
} catch (BlockAlreadyExistsException e) {
// It is already cached
return true;
}
try (BlockReader reader = mBlockWorker
.readUfsBlock(Sessions.ASYNC_CACHE_SESSION_ID, blockId, 0)) {
// Read the entire block, caching to block store will be handled internally in UFS block store
// Note that, we read from UFS with a smaller buffer to avoid high pressure on heap
// memory when concurrent async requests are received and thus trigger GC.
long offset = 0;
while (offset < blockSize) {
long bufferSize = Math.min(8 * Constants.MB, blockSize - offset);
reader.read(offset, bufferSize);
offset += bufferSize;
}
} catch (AlluxioException | IOException e) {
// This is only best effort
LOG.warn("Failed to async cache block {} from UFS on copying the block: {}", blockId, e);
return false;
} finally {
try {
mBlockWorker.closeUfsBlock(Sessions.ASYNC_CACHE_SESSION_ID, blockId);
} catch (AlluxioException | IOException ee) {
LOG.warn("Failed to close UFS block {}: {}", blockId, ee);
return false;
}
}
return true;
}
|
java
|
private boolean cacheBlockFromUfs(long blockId, long blockSize,
Protocol.OpenUfsBlockOptions openUfsBlockOptions) {
// Check if the block has been requested in UFS block store
try {
if (!mBlockWorker
.openUfsBlock(Sessions.ASYNC_CACHE_SESSION_ID, blockId, openUfsBlockOptions)) {
LOG.warn("Failed to async cache block {} from UFS on opening the block", blockId);
return false;
}
} catch (BlockAlreadyExistsException e) {
// It is already cached
return true;
}
try (BlockReader reader = mBlockWorker
.readUfsBlock(Sessions.ASYNC_CACHE_SESSION_ID, blockId, 0)) {
// Read the entire block, caching to block store will be handled internally in UFS block store
// Note that, we read from UFS with a smaller buffer to avoid high pressure on heap
// memory when concurrent async requests are received and thus trigger GC.
long offset = 0;
while (offset < blockSize) {
long bufferSize = Math.min(8 * Constants.MB, blockSize - offset);
reader.read(offset, bufferSize);
offset += bufferSize;
}
} catch (AlluxioException | IOException e) {
// This is only best effort
LOG.warn("Failed to async cache block {} from UFS on copying the block: {}", blockId, e);
return false;
} finally {
try {
mBlockWorker.closeUfsBlock(Sessions.ASYNC_CACHE_SESSION_ID, blockId);
} catch (AlluxioException | IOException ee) {
LOG.warn("Failed to close UFS block {}: {}", blockId, ee);
return false;
}
}
return true;
}
|
[
"private",
"boolean",
"cacheBlockFromUfs",
"(",
"long",
"blockId",
",",
"long",
"blockSize",
",",
"Protocol",
".",
"OpenUfsBlockOptions",
"openUfsBlockOptions",
")",
"{",
"// Check if the block has been requested in UFS block store",
"try",
"{",
"if",
"(",
"!",
"mBlockWorker",
".",
"openUfsBlock",
"(",
"Sessions",
".",
"ASYNC_CACHE_SESSION_ID",
",",
"blockId",
",",
"openUfsBlockOptions",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to async cache block {} from UFS on opening the block\"",
",",
"blockId",
")",
";",
"return",
"false",
";",
"}",
"}",
"catch",
"(",
"BlockAlreadyExistsException",
"e",
")",
"{",
"// It is already cached",
"return",
"true",
";",
"}",
"try",
"(",
"BlockReader",
"reader",
"=",
"mBlockWorker",
".",
"readUfsBlock",
"(",
"Sessions",
".",
"ASYNC_CACHE_SESSION_ID",
",",
"blockId",
",",
"0",
")",
")",
"{",
"// Read the entire block, caching to block store will be handled internally in UFS block store",
"// Note that, we read from UFS with a smaller buffer to avoid high pressure on heap",
"// memory when concurrent async requests are received and thus trigger GC.",
"long",
"offset",
"=",
"0",
";",
"while",
"(",
"offset",
"<",
"blockSize",
")",
"{",
"long",
"bufferSize",
"=",
"Math",
".",
"min",
"(",
"8",
"*",
"Constants",
".",
"MB",
",",
"blockSize",
"-",
"offset",
")",
";",
"reader",
".",
"read",
"(",
"offset",
",",
"bufferSize",
")",
";",
"offset",
"+=",
"bufferSize",
";",
"}",
"}",
"catch",
"(",
"AlluxioException",
"|",
"IOException",
"e",
")",
"{",
"// This is only best effort",
"LOG",
".",
"warn",
"(",
"\"Failed to async cache block {} from UFS on copying the block: {}\"",
",",
"blockId",
",",
"e",
")",
";",
"return",
"false",
";",
"}",
"finally",
"{",
"try",
"{",
"mBlockWorker",
".",
"closeUfsBlock",
"(",
"Sessions",
".",
"ASYNC_CACHE_SESSION_ID",
",",
"blockId",
")",
";",
"}",
"catch",
"(",
"AlluxioException",
"|",
"IOException",
"ee",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to close UFS block {}: {}\"",
",",
"blockId",
",",
"ee",
")",
";",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Caches the block via the local worker to read from UFS.
@param blockId block ID
@param blockSize block size
@param openUfsBlockOptions options to open the UFS file
@return if the block is cached
|
[
"Caches",
"the",
"block",
"via",
"the",
"local",
"worker",
"to",
"read",
"from",
"UFS",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/AsyncCacheRequestManager.java#L148-L185
|
19,018
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/AsyncJournalWriter.java
|
AsyncJournalWriter.flush
|
public void flush(final long targetCounter) throws IOException, JournalClosedException {
// Return if flushed.
if (targetCounter <= mFlushCounter.get()) {
return;
}
// Submit the ticket for flush thread to process.
FlushTicket ticket = new FlushTicket(targetCounter);
try (LockResource lr = new LockResource(mTicketLock)) {
mTicketList.add(ticket);
}
try {
// Give a permit for flush thread to run.
mFlushSemaphore.release();
// Wait on the ticket until completed.
ticket.waitCompleted();
} catch (InterruptedException ie) {
// Interpret interruption as cancellation.
throw new AlluxioStatusException(Status.CANCELLED.withCause(ie));
} catch (Throwable e) {
// Filter, journal specific exception codes.
if (e instanceof IOException) {
throw (IOException) e;
}
if (e instanceof JournalClosedException) {
throw (JournalClosedException) e;
}
// Not expected. throw internal error.
throw new AlluxioStatusException(Status.INTERNAL.withCause(e));
} finally {
/**
* Client can only try to reacquire the permit it has given
* because the permit may or may not have been used by the flush thread.
*/
mFlushSemaphore.tryAcquire();
}
}
|
java
|
public void flush(final long targetCounter) throws IOException, JournalClosedException {
// Return if flushed.
if (targetCounter <= mFlushCounter.get()) {
return;
}
// Submit the ticket for flush thread to process.
FlushTicket ticket = new FlushTicket(targetCounter);
try (LockResource lr = new LockResource(mTicketLock)) {
mTicketList.add(ticket);
}
try {
// Give a permit for flush thread to run.
mFlushSemaphore.release();
// Wait on the ticket until completed.
ticket.waitCompleted();
} catch (InterruptedException ie) {
// Interpret interruption as cancellation.
throw new AlluxioStatusException(Status.CANCELLED.withCause(ie));
} catch (Throwable e) {
// Filter, journal specific exception codes.
if (e instanceof IOException) {
throw (IOException) e;
}
if (e instanceof JournalClosedException) {
throw (JournalClosedException) e;
}
// Not expected. throw internal error.
throw new AlluxioStatusException(Status.INTERNAL.withCause(e));
} finally {
/**
* Client can only try to reacquire the permit it has given
* because the permit may or may not have been used by the flush thread.
*/
mFlushSemaphore.tryAcquire();
}
}
|
[
"public",
"void",
"flush",
"(",
"final",
"long",
"targetCounter",
")",
"throws",
"IOException",
",",
"JournalClosedException",
"{",
"// Return if flushed.",
"if",
"(",
"targetCounter",
"<=",
"mFlushCounter",
".",
"get",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Submit the ticket for flush thread to process.",
"FlushTicket",
"ticket",
"=",
"new",
"FlushTicket",
"(",
"targetCounter",
")",
";",
"try",
"(",
"LockResource",
"lr",
"=",
"new",
"LockResource",
"(",
"mTicketLock",
")",
")",
"{",
"mTicketList",
".",
"add",
"(",
"ticket",
")",
";",
"}",
"try",
"{",
"// Give a permit for flush thread to run.",
"mFlushSemaphore",
".",
"release",
"(",
")",
";",
"// Wait on the ticket until completed.",
"ticket",
".",
"waitCompleted",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"ie",
")",
"{",
"// Interpret interruption as cancellation.",
"throw",
"new",
"AlluxioStatusException",
"(",
"Status",
".",
"CANCELLED",
".",
"withCause",
"(",
"ie",
")",
")",
";",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"// Filter, journal specific exception codes.",
"if",
"(",
"e",
"instanceof",
"IOException",
")",
"{",
"throw",
"(",
"IOException",
")",
"e",
";",
"}",
"if",
"(",
"e",
"instanceof",
"JournalClosedException",
")",
"{",
"throw",
"(",
"JournalClosedException",
")",
"e",
";",
"}",
"// Not expected. throw internal error.",
"throw",
"new",
"AlluxioStatusException",
"(",
"Status",
".",
"INTERNAL",
".",
"withCause",
"(",
"e",
")",
")",
";",
"}",
"finally",
"{",
"/**\n * Client can only try to reacquire the permit it has given\n * because the permit may or may not have been used by the flush thread.\n */",
"mFlushSemaphore",
".",
"tryAcquire",
"(",
")",
";",
"}",
"}"
] |
Submits a ticket to flush thread and waits until ticket is served.
If the specified counter is already flushed, this is essentially a no-op.
@param targetCounter the counter to flush
|
[
"Submits",
"a",
"ticket",
"to",
"flush",
"thread",
"and",
"waits",
"until",
"ticket",
"is",
"served",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/AsyncJournalWriter.java#L327-L365
|
19,019
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/file/meta/MutableInodeFile.java
|
MutableInodeFile.updateFromEntry
|
public void updateFromEntry(UpdateInodeFileEntry entry) {
if (entry.hasPersistJobId()) {
setPersistJobId(entry.getPersistJobId());
}
if (entry.hasReplicationMax()) {
setReplicationMax(entry.getReplicationMax());
}
if (entry.hasReplicationMin()) {
setReplicationMin(entry.getReplicationMin());
}
if (entry.hasTempUfsPath()) {
setTempUfsPath(entry.getTempUfsPath());
}
if (entry.hasBlockSizeBytes()) {
setBlockSizeBytes(entry.getBlockSizeBytes());
}
if (entry.hasCacheable()) {
setCacheable(entry.getCacheable());
}
if (entry.hasCompleted()) {
setCompleted(entry.getCompleted());
}
if (entry.hasLength()) {
setLength(entry.getLength());
}
if (entry.getSetBlocksCount() > 0) {
setBlockIds(entry.getSetBlocksList());
}
}
|
java
|
public void updateFromEntry(UpdateInodeFileEntry entry) {
if (entry.hasPersistJobId()) {
setPersistJobId(entry.getPersistJobId());
}
if (entry.hasReplicationMax()) {
setReplicationMax(entry.getReplicationMax());
}
if (entry.hasReplicationMin()) {
setReplicationMin(entry.getReplicationMin());
}
if (entry.hasTempUfsPath()) {
setTempUfsPath(entry.getTempUfsPath());
}
if (entry.hasBlockSizeBytes()) {
setBlockSizeBytes(entry.getBlockSizeBytes());
}
if (entry.hasCacheable()) {
setCacheable(entry.getCacheable());
}
if (entry.hasCompleted()) {
setCompleted(entry.getCompleted());
}
if (entry.hasLength()) {
setLength(entry.getLength());
}
if (entry.getSetBlocksCount() > 0) {
setBlockIds(entry.getSetBlocksList());
}
}
|
[
"public",
"void",
"updateFromEntry",
"(",
"UpdateInodeFileEntry",
"entry",
")",
"{",
"if",
"(",
"entry",
".",
"hasPersistJobId",
"(",
")",
")",
"{",
"setPersistJobId",
"(",
"entry",
".",
"getPersistJobId",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasReplicationMax",
"(",
")",
")",
"{",
"setReplicationMax",
"(",
"entry",
".",
"getReplicationMax",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasReplicationMin",
"(",
")",
")",
"{",
"setReplicationMin",
"(",
"entry",
".",
"getReplicationMin",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasTempUfsPath",
"(",
")",
")",
"{",
"setTempUfsPath",
"(",
"entry",
".",
"getTempUfsPath",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasBlockSizeBytes",
"(",
")",
")",
"{",
"setBlockSizeBytes",
"(",
"entry",
".",
"getBlockSizeBytes",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasCacheable",
"(",
")",
")",
"{",
"setCacheable",
"(",
"entry",
".",
"getCacheable",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasCompleted",
"(",
")",
")",
"{",
"setCompleted",
"(",
"entry",
".",
"getCompleted",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"hasLength",
"(",
")",
")",
"{",
"setLength",
"(",
"entry",
".",
"getLength",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"getSetBlocksCount",
"(",
")",
">",
"0",
")",
"{",
"setBlockIds",
"(",
"entry",
".",
"getSetBlocksList",
"(",
")",
")",
";",
"}",
"}"
] |
Updates this inode file's state from the given entry.
@param entry the entry
|
[
"Updates",
"this",
"inode",
"file",
"s",
"state",
"from",
"the",
"given",
"entry",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/file/meta/MutableInodeFile.java#L305-L333
|
19,020
|
Alluxio/alluxio
|
job/common/src/main/java/alluxio/job/util/SerializationUtils.java
|
SerializationUtils.serialize
|
public static byte[] serialize(Object obj) throws IOException {
if (obj == null) {
return null;
}
try (ByteArrayOutputStream b = new ByteArrayOutputStream()) {
try (ObjectOutputStream o = new ObjectOutputStream(b)) {
o.writeObject(obj);
}
return b.toByteArray();
}
}
|
java
|
public static byte[] serialize(Object obj) throws IOException {
if (obj == null) {
return null;
}
try (ByteArrayOutputStream b = new ByteArrayOutputStream()) {
try (ObjectOutputStream o = new ObjectOutputStream(b)) {
o.writeObject(obj);
}
return b.toByteArray();
}
}
|
[
"public",
"static",
"byte",
"[",
"]",
"serialize",
"(",
"Object",
"obj",
")",
"throws",
"IOException",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"(",
"ByteArrayOutputStream",
"b",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
")",
"{",
"try",
"(",
"ObjectOutputStream",
"o",
"=",
"new",
"ObjectOutputStream",
"(",
"b",
")",
")",
"{",
"o",
".",
"writeObject",
"(",
"obj",
")",
";",
"}",
"return",
"b",
".",
"toByteArray",
"(",
")",
";",
"}",
"}"
] |
Serializes an object into a byte array. When the object is null, returns null.
@param obj the object to serialize
@return the serialized bytes
@throws IOException if the serialization fails
|
[
"Serializes",
"an",
"object",
"into",
"a",
"byte",
"array",
".",
"When",
"the",
"object",
"is",
"null",
"returns",
"null",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/common/src/main/java/alluxio/job/util/SerializationUtils.java#L43-L53
|
19,021
|
Alluxio/alluxio
|
job/common/src/main/java/alluxio/job/util/SerializationUtils.java
|
SerializationUtils.deserialize
|
public static Serializable deserialize(byte[] bytes) throws IOException, ClassNotFoundException {
if (bytes == null) {
return null;
}
try (ByteArrayInputStream b = new ByteArrayInputStream(bytes)) {
try (ObjectInputStream o = new ObjectInputStream(b)) {
return (Serializable) o.readObject();
}
}
}
|
java
|
public static Serializable deserialize(byte[] bytes) throws IOException, ClassNotFoundException {
if (bytes == null) {
return null;
}
try (ByteArrayInputStream b = new ByteArrayInputStream(bytes)) {
try (ObjectInputStream o = new ObjectInputStream(b)) {
return (Serializable) o.readObject();
}
}
}
|
[
"public",
"static",
"Serializable",
"deserialize",
"(",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"if",
"(",
"bytes",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"try",
"(",
"ByteArrayInputStream",
"b",
"=",
"new",
"ByteArrayInputStream",
"(",
"bytes",
")",
")",
"{",
"try",
"(",
"ObjectInputStream",
"o",
"=",
"new",
"ObjectInputStream",
"(",
"b",
")",
")",
"{",
"return",
"(",
"Serializable",
")",
"o",
".",
"readObject",
"(",
")",
";",
"}",
"}",
"}"
] |
Deserializes a byte array into an object. When the bytes are null, returns null.
@param bytes the byte array to deserialize
@return the deserialized object
@throws IOException if the deserialization fails
@throws ClassNotFoundException if no class found to deserialize into
|
[
"Deserializes",
"a",
"byte",
"array",
"into",
"an",
"object",
".",
"When",
"the",
"bytes",
"are",
"null",
"returns",
"null",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/job/common/src/main/java/alluxio/job/util/SerializationUtils.java#L79-L88
|
19,022
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/evictor/LRFUEvictor.java
|
LRFUEvictor.getSortedCRF
|
private List<Map.Entry<Long, Double>> getSortedCRF() {
List<Map.Entry<Long, Double>> sortedCRF = new ArrayList<>(mBlockIdToCRFValue.entrySet());
sortedCRF.sort(Comparator.comparingDouble(Entry::getValue));
return sortedCRF;
}
|
java
|
private List<Map.Entry<Long, Double>> getSortedCRF() {
List<Map.Entry<Long, Double>> sortedCRF = new ArrayList<>(mBlockIdToCRFValue.entrySet());
sortedCRF.sort(Comparator.comparingDouble(Entry::getValue));
return sortedCRF;
}
|
[
"private",
"List",
"<",
"Map",
".",
"Entry",
"<",
"Long",
",",
"Double",
">",
">",
"getSortedCRF",
"(",
")",
"{",
"List",
"<",
"Map",
".",
"Entry",
"<",
"Long",
",",
"Double",
">",
">",
"sortedCRF",
"=",
"new",
"ArrayList",
"<>",
"(",
"mBlockIdToCRFValue",
".",
"entrySet",
"(",
")",
")",
";",
"sortedCRF",
".",
"sort",
"(",
"Comparator",
".",
"comparingDouble",
"(",
"Entry",
"::",
"getValue",
")",
")",
";",
"return",
"sortedCRF",
";",
"}"
] |
Sorts all blocks in ascending order of CRF.
@return the sorted CRF of all blocks
|
[
"Sorts",
"all",
"blocks",
"in",
"ascending",
"order",
"of",
"CRF",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/evictor/LRFUEvictor.java#L134-L138
|
19,023
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/ExtensionUtils.java
|
ExtensionUtils.listExtensions
|
public static File[] listExtensions(String extensionDir) {
File[] extensions = new File(extensionDir)
.listFiles(file -> file.getPath().toLowerCase().endsWith(Constants.EXTENSION_JAR));
if (extensions == null) {
// Directory does not exist
return EMPTY_EXTENSIONS_LIST;
}
return extensions;
}
|
java
|
public static File[] listExtensions(String extensionDir) {
File[] extensions = new File(extensionDir)
.listFiles(file -> file.getPath().toLowerCase().endsWith(Constants.EXTENSION_JAR));
if (extensions == null) {
// Directory does not exist
return EMPTY_EXTENSIONS_LIST;
}
return extensions;
}
|
[
"public",
"static",
"File",
"[",
"]",
"listExtensions",
"(",
"String",
"extensionDir",
")",
"{",
"File",
"[",
"]",
"extensions",
"=",
"new",
"File",
"(",
"extensionDir",
")",
".",
"listFiles",
"(",
"file",
"->",
"file",
".",
"getPath",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"endsWith",
"(",
"Constants",
".",
"EXTENSION_JAR",
")",
")",
";",
"if",
"(",
"extensions",
"==",
"null",
")",
"{",
"// Directory does not exist",
"return",
"EMPTY_EXTENSIONS_LIST",
";",
"}",
"return",
"extensions",
";",
"}"
] |
List extension jars from the configured extensions directory.
@param extensionDir the directory containing extensions
@return an array of files (one file per jar)
|
[
"List",
"extension",
"jars",
"from",
"the",
"configured",
"extensions",
"directory",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/ExtensionUtils.java#L34-L42
|
19,024
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockStoreLocation.java
|
BlockStoreLocation.belongsTo
|
public boolean belongsTo(BlockStoreLocation location) {
boolean tierInRange =
tierAlias().equals(location.tierAlias()) || location.tierAlias().equals(ANY_TIER);
boolean dirInRange = (dir() == location.dir()) || (location.dir() == ANY_DIR);
return tierInRange && dirInRange;
}
|
java
|
public boolean belongsTo(BlockStoreLocation location) {
boolean tierInRange =
tierAlias().equals(location.tierAlias()) || location.tierAlias().equals(ANY_TIER);
boolean dirInRange = (dir() == location.dir()) || (location.dir() == ANY_DIR);
return tierInRange && dirInRange;
}
|
[
"public",
"boolean",
"belongsTo",
"(",
"BlockStoreLocation",
"location",
")",
"{",
"boolean",
"tierInRange",
"=",
"tierAlias",
"(",
")",
".",
"equals",
"(",
"location",
".",
"tierAlias",
"(",
")",
")",
"||",
"location",
".",
"tierAlias",
"(",
")",
".",
"equals",
"(",
"ANY_TIER",
")",
";",
"boolean",
"dirInRange",
"=",
"(",
"dir",
"(",
")",
"==",
"location",
".",
"dir",
"(",
")",
")",
"||",
"(",
"location",
".",
"dir",
"(",
")",
"==",
"ANY_DIR",
")",
";",
"return",
"tierInRange",
"&&",
"dirInRange",
";",
"}"
] |
Returns whether this location belongs to the specific location.
Location A belongs to B when tier and dir of A are all in the range of B respectively.
@param location the target BlockStoreLocation
@return true when this BlockStoreLocation belongs to the target, otherwise false
|
[
"Returns",
"whether",
"this",
"location",
"belongs",
"to",
"the",
"specific",
"location",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockStoreLocation.java#L93-L98
|
19,025
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/web/WebServer.java
|
WebServer.stop
|
public void stop() throws Exception {
// close all connectors and release all binding ports
for (Connector connector : mServer.getConnectors()) {
connector.stop();
}
mServer.stop();
}
|
java
|
public void stop() throws Exception {
// close all connectors and release all binding ports
for (Connector connector : mServer.getConnectors()) {
connector.stop();
}
mServer.stop();
}
|
[
"public",
"void",
"stop",
"(",
")",
"throws",
"Exception",
"{",
"// close all connectors and release all binding ports",
"for",
"(",
"Connector",
"connector",
":",
"mServer",
".",
"getConnectors",
"(",
")",
")",
"{",
"connector",
".",
"stop",
"(",
")",
";",
"}",
"mServer",
".",
"stop",
"(",
")",
";",
"}"
] |
Shuts down the web server.
|
[
"Shuts",
"down",
"the",
"web",
"server",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/web/WebServer.java#L145-L152
|
19,026
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/web/WebServer.java
|
WebServer.start
|
public void start() {
try {
mServer.start();
LOG.info("{} started @ {}", mServiceName, mAddress);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
|
java
|
public void start() {
try {
mServer.start();
LOG.info("{} started @ {}", mServiceName, mAddress);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
|
[
"public",
"void",
"start",
"(",
")",
"{",
"try",
"{",
"mServer",
".",
"start",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"{} started @ {}\"",
",",
"mServiceName",
",",
"mAddress",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] |
Starts the web server.
|
[
"Starts",
"the",
"web",
"server",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/web/WebServer.java#L157-L164
|
19,027
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/TLRandom.java
|
TLRandom.eraseThreadLocals
|
static final void eraseThreadLocals(Thread thread) {
U.putObject(thread, THREADLOCALS, null);
U.putObject(thread, INHERITABLETHREADLOCALS, null);
}
|
java
|
static final void eraseThreadLocals(Thread thread) {
U.putObject(thread, THREADLOCALS, null);
U.putObject(thread, INHERITABLETHREADLOCALS, null);
}
|
[
"static",
"final",
"void",
"eraseThreadLocals",
"(",
"Thread",
"thread",
")",
"{",
"U",
".",
"putObject",
"(",
"thread",
",",
"THREADLOCALS",
",",
"null",
")",
";",
"U",
".",
"putObject",
"(",
"thread",
",",
"INHERITABLETHREADLOCALS",
",",
"null",
")",
";",
"}"
] |
Erases ThreadLocals by nulling out Thread maps.
|
[
"Erases",
"ThreadLocals",
"by",
"nulling",
"out",
"Thread",
"maps",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/TLRandom.java#L181-L184
|
19,028
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalCheckpointThread.java
|
UfsJournalCheckpointThread.awaitTermination
|
public void awaitTermination(boolean waitQuietPeriod) {
LOG.info("{}: Journal checkpointer shutdown has been initiated.", mMaster.getName());
mWaitQuietPeriod = waitQuietPeriod;
mShutdownInitiated = true;
// Actively interrupt to cancel slow checkpoints.
synchronized (mCheckpointingLock) {
if (mCheckpointing) {
interrupt();
}
}
try {
// Wait for the thread to finish.
join();
LOG.info("{}: Journal shutdown complete", mMaster.getName());
} catch (InterruptedException e) {
LOG.error("{}: journal checkpointer shutdown is interrupted.", mMaster.getName(), e);
// Kills the master. This can happen in the following two scenarios:
// 1. The user Ctrl-C the server.
// 2. Zookeeper selects this master as standby before the master finishes the previous
// standby->leader transition. It is safer to crash the server because the behavior is
// undefined to have two journal checkpointer running concurrently.
throw new RuntimeException(e);
}
mStopped = true;
}
|
java
|
public void awaitTermination(boolean waitQuietPeriod) {
LOG.info("{}: Journal checkpointer shutdown has been initiated.", mMaster.getName());
mWaitQuietPeriod = waitQuietPeriod;
mShutdownInitiated = true;
// Actively interrupt to cancel slow checkpoints.
synchronized (mCheckpointingLock) {
if (mCheckpointing) {
interrupt();
}
}
try {
// Wait for the thread to finish.
join();
LOG.info("{}: Journal shutdown complete", mMaster.getName());
} catch (InterruptedException e) {
LOG.error("{}: journal checkpointer shutdown is interrupted.", mMaster.getName(), e);
// Kills the master. This can happen in the following two scenarios:
// 1. The user Ctrl-C the server.
// 2. Zookeeper selects this master as standby before the master finishes the previous
// standby->leader transition. It is safer to crash the server because the behavior is
// undefined to have two journal checkpointer running concurrently.
throw new RuntimeException(e);
}
mStopped = true;
}
|
[
"public",
"void",
"awaitTermination",
"(",
"boolean",
"waitQuietPeriod",
")",
"{",
"LOG",
".",
"info",
"(",
"\"{}: Journal checkpointer shutdown has been initiated.\"",
",",
"mMaster",
".",
"getName",
"(",
")",
")",
";",
"mWaitQuietPeriod",
"=",
"waitQuietPeriod",
";",
"mShutdownInitiated",
"=",
"true",
";",
"// Actively interrupt to cancel slow checkpoints.",
"synchronized",
"(",
"mCheckpointingLock",
")",
"{",
"if",
"(",
"mCheckpointing",
")",
"{",
"interrupt",
"(",
")",
";",
"}",
"}",
"try",
"{",
"// Wait for the thread to finish.",
"join",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"{}: Journal shutdown complete\"",
",",
"mMaster",
".",
"getName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"{}: journal checkpointer shutdown is interrupted.\"",
",",
"mMaster",
".",
"getName",
"(",
")",
",",
"e",
")",
";",
"// Kills the master. This can happen in the following two scenarios:",
"// 1. The user Ctrl-C the server.",
"// 2. Zookeeper selects this master as standby before the master finishes the previous",
"// standby->leader transition. It is safer to crash the server because the behavior is",
"// undefined to have two journal checkpointer running concurrently.",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"mStopped",
"=",
"true",
";",
"}"
] |
Initiates the shutdown of this checkpointer thread, and also waits for it to finish.
@param waitQuietPeriod whether to wait for a quiet period to pass before terminating the thread
|
[
"Initiates",
"the",
"shutdown",
"of",
"this",
"checkpointer",
"thread",
"and",
"also",
"waits",
"for",
"it",
"to",
"finish",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalCheckpointThread.java#L101-L126
|
19,029
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalCheckpointThread.java
|
UfsJournalCheckpointThread.maybeCheckpoint
|
private void maybeCheckpoint() {
if (mShutdownInitiated) {
return;
}
long nextSequenceNumber = mJournalReader.getNextSequenceNumber();
if (nextSequenceNumber - mNextSequenceNumberToCheckpoint < mCheckpointPeriodEntries) {
return;
}
try {
mNextSequenceNumberToCheckpoint = mJournal.getNextSequenceNumberToCheckpoint();
} catch (IOException e) {
LOG.warn("{}: Failed to get the next sequence number to checkpoint with error {}.",
mMaster.getName(), e.getMessage());
return;
}
if (nextSequenceNumber - mNextSequenceNumberToCheckpoint < mCheckpointPeriodEntries) {
return;
}
writeCheckpoint(nextSequenceNumber);
}
|
java
|
private void maybeCheckpoint() {
if (mShutdownInitiated) {
return;
}
long nextSequenceNumber = mJournalReader.getNextSequenceNumber();
if (nextSequenceNumber - mNextSequenceNumberToCheckpoint < mCheckpointPeriodEntries) {
return;
}
try {
mNextSequenceNumberToCheckpoint = mJournal.getNextSequenceNumberToCheckpoint();
} catch (IOException e) {
LOG.warn("{}: Failed to get the next sequence number to checkpoint with error {}.",
mMaster.getName(), e.getMessage());
return;
}
if (nextSequenceNumber - mNextSequenceNumberToCheckpoint < mCheckpointPeriodEntries) {
return;
}
writeCheckpoint(nextSequenceNumber);
}
|
[
"private",
"void",
"maybeCheckpoint",
"(",
")",
"{",
"if",
"(",
"mShutdownInitiated",
")",
"{",
"return",
";",
"}",
"long",
"nextSequenceNumber",
"=",
"mJournalReader",
".",
"getNextSequenceNumber",
"(",
")",
";",
"if",
"(",
"nextSequenceNumber",
"-",
"mNextSequenceNumberToCheckpoint",
"<",
"mCheckpointPeriodEntries",
")",
"{",
"return",
";",
"}",
"try",
"{",
"mNextSequenceNumberToCheckpoint",
"=",
"mJournal",
".",
"getNextSequenceNumberToCheckpoint",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"{}: Failed to get the next sequence number to checkpoint with error {}.\"",
",",
"mMaster",
".",
"getName",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"nextSequenceNumber",
"-",
"mNextSequenceNumberToCheckpoint",
"<",
"mCheckpointPeriodEntries",
")",
"{",
"return",
";",
"}",
"writeCheckpoint",
"(",
"nextSequenceNumber",
")",
";",
"}"
] |
Creates a new checkpoint if necessary.
|
[
"Creates",
"a",
"new",
"checkpoint",
"if",
"necessary",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalCheckpointThread.java#L231-L251
|
19,030
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java
|
BlockMetadataManager.addTempBlockMeta
|
public void addTempBlockMeta(TempBlockMeta tempBlockMeta)
throws WorkerOutOfSpaceException, BlockAlreadyExistsException {
StorageDir dir = tempBlockMeta.getParentDir();
dir.addTempBlockMeta(tempBlockMeta);
}
|
java
|
public void addTempBlockMeta(TempBlockMeta tempBlockMeta)
throws WorkerOutOfSpaceException, BlockAlreadyExistsException {
StorageDir dir = tempBlockMeta.getParentDir();
dir.addTempBlockMeta(tempBlockMeta);
}
|
[
"public",
"void",
"addTempBlockMeta",
"(",
"TempBlockMeta",
"tempBlockMeta",
")",
"throws",
"WorkerOutOfSpaceException",
",",
"BlockAlreadyExistsException",
"{",
"StorageDir",
"dir",
"=",
"tempBlockMeta",
".",
"getParentDir",
"(",
")",
";",
"dir",
".",
"addTempBlockMeta",
"(",
"tempBlockMeta",
")",
";",
"}"
] |
Adds a temp block.
@param tempBlockMeta the metadata of the temp block to add
@throws WorkerOutOfSpaceException when no more space left to hold the block
@throws BlockAlreadyExistsException when the block already exists
|
[
"Adds",
"a",
"temp",
"block",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java#L103-L107
|
19,031
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java
|
BlockMetadataManager.cleanupSessionTempBlocks
|
@Deprecated
public void cleanupSessionTempBlocks(long sessionId, List<Long> tempBlockIds) {
for (StorageTier tier : mTiers) {
for (StorageDir dir : tier.getStorageDirs()) {
dir.cleanupSessionTempBlocks(sessionId, tempBlockIds);
}
}
}
|
java
|
@Deprecated
public void cleanupSessionTempBlocks(long sessionId, List<Long> tempBlockIds) {
for (StorageTier tier : mTiers) {
for (StorageDir dir : tier.getStorageDirs()) {
dir.cleanupSessionTempBlocks(sessionId, tempBlockIds);
}
}
}
|
[
"@",
"Deprecated",
"public",
"void",
"cleanupSessionTempBlocks",
"(",
"long",
"sessionId",
",",
"List",
"<",
"Long",
">",
"tempBlockIds",
")",
"{",
"for",
"(",
"StorageTier",
"tier",
":",
"mTiers",
")",
"{",
"for",
"(",
"StorageDir",
"dir",
":",
"tier",
".",
"getStorageDirs",
"(",
")",
")",
"{",
"dir",
".",
"cleanupSessionTempBlocks",
"(",
"sessionId",
",",
"tempBlockIds",
")",
";",
"}",
"}",
"}"
] |
Cleans up the metadata of the given temp block ids.
@param sessionId the id of the client associated with the temp blocks
@param tempBlockIds the list of temporary block ids to be cleaned up, non temporary block ids
will be ignored.
@deprecated As of version 0.8.
|
[
"Cleans",
"up",
"the",
"metadata",
"of",
"the",
"given",
"temp",
"block",
"ids",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java#L139-L146
|
19,032
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java
|
BlockMetadataManager.getBlockMeta
|
public BlockMeta getBlockMeta(long blockId) throws BlockDoesNotExistException {
for (StorageTier tier : mTiers) {
for (StorageDir dir : tier.getStorageDirs()) {
if (dir.hasBlockMeta(blockId)) {
return dir.getBlockMeta(blockId);
}
}
}
throw new BlockDoesNotExistException(ExceptionMessage.BLOCK_META_NOT_FOUND, blockId);
}
|
java
|
public BlockMeta getBlockMeta(long blockId) throws BlockDoesNotExistException {
for (StorageTier tier : mTiers) {
for (StorageDir dir : tier.getStorageDirs()) {
if (dir.hasBlockMeta(blockId)) {
return dir.getBlockMeta(blockId);
}
}
}
throw new BlockDoesNotExistException(ExceptionMessage.BLOCK_META_NOT_FOUND, blockId);
}
|
[
"public",
"BlockMeta",
"getBlockMeta",
"(",
"long",
"blockId",
")",
"throws",
"BlockDoesNotExistException",
"{",
"for",
"(",
"StorageTier",
"tier",
":",
"mTiers",
")",
"{",
"for",
"(",
"StorageDir",
"dir",
":",
"tier",
".",
"getStorageDirs",
"(",
")",
")",
"{",
"if",
"(",
"dir",
".",
"hasBlockMeta",
"(",
"blockId",
")",
")",
"{",
"return",
"dir",
".",
"getBlockMeta",
"(",
"blockId",
")",
";",
"}",
"}",
"}",
"throw",
"new",
"BlockDoesNotExistException",
"(",
"ExceptionMessage",
".",
"BLOCK_META_NOT_FOUND",
",",
"blockId",
")",
";",
"}"
] |
Gets the metadata of a block given its block id.
@param blockId the block id
@return metadata of the block
@throws BlockDoesNotExistException if no BlockMeta for this block id is found
|
[
"Gets",
"the",
"metadata",
"of",
"a",
"block",
"given",
"its",
"block",
"id",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java#L186-L195
|
19,033
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java
|
BlockMetadataManager.getSessionTempBlocks
|
public List<TempBlockMeta> getSessionTempBlocks(long sessionId) {
List<TempBlockMeta> sessionTempBlocks = new ArrayList<>();
for (StorageTier tier : mTiers) {
for (StorageDir dir : tier.getStorageDirs()) {
sessionTempBlocks.addAll(dir.getSessionTempBlocks(sessionId));
}
}
return sessionTempBlocks;
}
|
java
|
public List<TempBlockMeta> getSessionTempBlocks(long sessionId) {
List<TempBlockMeta> sessionTempBlocks = new ArrayList<>();
for (StorageTier tier : mTiers) {
for (StorageDir dir : tier.getStorageDirs()) {
sessionTempBlocks.addAll(dir.getSessionTempBlocks(sessionId));
}
}
return sessionTempBlocks;
}
|
[
"public",
"List",
"<",
"TempBlockMeta",
">",
"getSessionTempBlocks",
"(",
"long",
"sessionId",
")",
"{",
"List",
"<",
"TempBlockMeta",
">",
"sessionTempBlocks",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"StorageTier",
"tier",
":",
"mTiers",
")",
"{",
"for",
"(",
"StorageDir",
"dir",
":",
"tier",
".",
"getStorageDirs",
"(",
")",
")",
"{",
"sessionTempBlocks",
".",
"addAll",
"(",
"dir",
".",
"getSessionTempBlocks",
"(",
"sessionId",
")",
")",
";",
"}",
"}",
"return",
"sessionTempBlocks",
";",
"}"
] |
Gets all the temporary blocks associated with a session, empty list is returned if the session
has no temporary blocks.
@param sessionId the id of the session
@return A list of temp blocks associated with the session
|
[
"Gets",
"all",
"the",
"temporary",
"blocks",
"associated",
"with",
"a",
"session",
"empty",
"list",
"is",
"returned",
"if",
"the",
"session",
"has",
"no",
"temporary",
"blocks",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java#L321-L329
|
19,034
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java
|
BlockMetadataManager.hasBlockMeta
|
public boolean hasBlockMeta(long blockId) {
for (StorageTier tier : mTiers) {
for (StorageDir dir : tier.getStorageDirs()) {
if (dir.hasBlockMeta(blockId)) {
return true;
}
}
}
return false;
}
|
java
|
public boolean hasBlockMeta(long blockId) {
for (StorageTier tier : mTiers) {
for (StorageDir dir : tier.getStorageDirs()) {
if (dir.hasBlockMeta(blockId)) {
return true;
}
}
}
return false;
}
|
[
"public",
"boolean",
"hasBlockMeta",
"(",
"long",
"blockId",
")",
"{",
"for",
"(",
"StorageTier",
"tier",
":",
"mTiers",
")",
"{",
"for",
"(",
"StorageDir",
"dir",
":",
"tier",
".",
"getStorageDirs",
"(",
")",
")",
"{",
"if",
"(",
"dir",
".",
"hasBlockMeta",
"(",
"blockId",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks if the storage has a given block.
@param blockId the block id
@return true if the block is contained, false otherwise
|
[
"Checks",
"if",
"the",
"storage",
"has",
"a",
"given",
"block",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java#L337-L346
|
19,035
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java
|
BlockMetadataManager.moveBlockMeta
|
public BlockMeta moveBlockMeta(BlockMeta blockMeta, TempBlockMeta tempBlockMeta)
throws BlockDoesNotExistException, WorkerOutOfSpaceException, BlockAlreadyExistsException {
StorageDir srcDir = blockMeta.getParentDir();
StorageDir dstDir = tempBlockMeta.getParentDir();
srcDir.removeBlockMeta(blockMeta);
BlockMeta newBlockMeta =
new BlockMeta(blockMeta.getBlockId(), blockMeta.getBlockSize(), dstDir);
dstDir.removeTempBlockMeta(tempBlockMeta);
dstDir.addBlockMeta(newBlockMeta);
return newBlockMeta;
}
|
java
|
public BlockMeta moveBlockMeta(BlockMeta blockMeta, TempBlockMeta tempBlockMeta)
throws BlockDoesNotExistException, WorkerOutOfSpaceException, BlockAlreadyExistsException {
StorageDir srcDir = blockMeta.getParentDir();
StorageDir dstDir = tempBlockMeta.getParentDir();
srcDir.removeBlockMeta(blockMeta);
BlockMeta newBlockMeta =
new BlockMeta(blockMeta.getBlockId(), blockMeta.getBlockSize(), dstDir);
dstDir.removeTempBlockMeta(tempBlockMeta);
dstDir.addBlockMeta(newBlockMeta);
return newBlockMeta;
}
|
[
"public",
"BlockMeta",
"moveBlockMeta",
"(",
"BlockMeta",
"blockMeta",
",",
"TempBlockMeta",
"tempBlockMeta",
")",
"throws",
"BlockDoesNotExistException",
",",
"WorkerOutOfSpaceException",
",",
"BlockAlreadyExistsException",
"{",
"StorageDir",
"srcDir",
"=",
"blockMeta",
".",
"getParentDir",
"(",
")",
";",
"StorageDir",
"dstDir",
"=",
"tempBlockMeta",
".",
"getParentDir",
"(",
")",
";",
"srcDir",
".",
"removeBlockMeta",
"(",
"blockMeta",
")",
";",
"BlockMeta",
"newBlockMeta",
"=",
"new",
"BlockMeta",
"(",
"blockMeta",
".",
"getBlockId",
"(",
")",
",",
"blockMeta",
".",
"getBlockSize",
"(",
")",
",",
"dstDir",
")",
";",
"dstDir",
".",
"removeTempBlockMeta",
"(",
"tempBlockMeta",
")",
";",
"dstDir",
".",
"addBlockMeta",
"(",
"newBlockMeta",
")",
";",
"return",
"newBlockMeta",
";",
"}"
] |
Moves an existing block to another location currently hold by a temp block.
@param blockMeta the metadata of the block to move
@param tempBlockMeta a placeholder in the destination directory
@return the new block metadata if success, absent otherwise
@throws BlockDoesNotExistException when the block to move is not found
@throws BlockAlreadyExistsException when the block to move already exists in the destination
@throws WorkerOutOfSpaceException when destination have no extra space to hold the block to
move
|
[
"Moves",
"an",
"existing",
"block",
"to",
"another",
"location",
"currently",
"hold",
"by",
"a",
"temp",
"block",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java#L376-L386
|
19,036
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java
|
BlockMetadataManager.removeBlockMeta
|
public void removeBlockMeta(BlockMeta block) throws BlockDoesNotExistException {
StorageDir dir = block.getParentDir();
dir.removeBlockMeta(block);
}
|
java
|
public void removeBlockMeta(BlockMeta block) throws BlockDoesNotExistException {
StorageDir dir = block.getParentDir();
dir.removeBlockMeta(block);
}
|
[
"public",
"void",
"removeBlockMeta",
"(",
"BlockMeta",
"block",
")",
"throws",
"BlockDoesNotExistException",
"{",
"StorageDir",
"dir",
"=",
"block",
".",
"getParentDir",
"(",
")",
";",
"dir",
".",
"removeBlockMeta",
"(",
"block",
")",
";",
"}"
] |
Removes the metadata of a specific block.
@param block the metadata of the block to remove
@throws BlockDoesNotExistException when block is not found
|
[
"Removes",
"the",
"metadata",
"of",
"a",
"specific",
"block",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java#L447-L450
|
19,037
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java
|
BlockMetadataManager.resizeTempBlockMeta
|
public void resizeTempBlockMeta(TempBlockMeta tempBlockMeta, long newSize)
throws InvalidWorkerStateException {
StorageDir dir = tempBlockMeta.getParentDir();
dir.resizeTempBlockMeta(tempBlockMeta, newSize);
}
|
java
|
public void resizeTempBlockMeta(TempBlockMeta tempBlockMeta, long newSize)
throws InvalidWorkerStateException {
StorageDir dir = tempBlockMeta.getParentDir();
dir.resizeTempBlockMeta(tempBlockMeta, newSize);
}
|
[
"public",
"void",
"resizeTempBlockMeta",
"(",
"TempBlockMeta",
"tempBlockMeta",
",",
"long",
"newSize",
")",
"throws",
"InvalidWorkerStateException",
"{",
"StorageDir",
"dir",
"=",
"tempBlockMeta",
".",
"getParentDir",
"(",
")",
";",
"dir",
".",
"resizeTempBlockMeta",
"(",
"tempBlockMeta",
",",
"newSize",
")",
";",
"}"
] |
Modifies the size of a temp block.
@param tempBlockMeta the temp block to modify
@param newSize new size in bytes
@throws InvalidWorkerStateException when newSize is smaller than current size
|
[
"Modifies",
"the",
"size",
"of",
"a",
"temp",
"block",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMetadataManager.java#L459-L463
|
19,038
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/security/authentication/SaslStreamClientDriver.java
|
SaslStreamClientDriver.start
|
public void start(String channelId) throws AlluxioStatusException {
try {
LOG.debug("Starting SASL handshake for ChannelId:{}", channelId);
// Send the server initial message.
mRequestObserver.onNext(mSaslHandshakeClientHandler.getInitialMessage(channelId));
// Wait until authentication status changes.
mAuthenticated.get(mGrpcAuthTimeoutMs, TimeUnit.MILLISECONDS);
} catch (SaslException se) {
throw new UnauthenticatedException(se.getMessage(), se);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw new UnavailableException(ie.getMessage(), ie);
} catch (ExecutionException e) {
Throwable cause = (e.getCause() != null) ? e.getCause() : e;
if (cause != null && cause instanceof StatusRuntimeException) {
StatusRuntimeException sre = (StatusRuntimeException) cause;
// If caught unimplemented, that means server does not support authentication.
if (sre.getStatus().getCode() == Status.Code.UNIMPLEMENTED) {
throw new UnauthenticatedException("Authentication is disabled on target host.");
}
throw AlluxioStatusException.fromStatusRuntimeException((StatusRuntimeException) cause);
}
throw new UnknownException(cause.getMessage(), cause);
} catch (TimeoutException e) {
throw new UnavailableException(e);
}
}
|
java
|
public void start(String channelId) throws AlluxioStatusException {
try {
LOG.debug("Starting SASL handshake for ChannelId:{}", channelId);
// Send the server initial message.
mRequestObserver.onNext(mSaslHandshakeClientHandler.getInitialMessage(channelId));
// Wait until authentication status changes.
mAuthenticated.get(mGrpcAuthTimeoutMs, TimeUnit.MILLISECONDS);
} catch (SaslException se) {
throw new UnauthenticatedException(se.getMessage(), se);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
throw new UnavailableException(ie.getMessage(), ie);
} catch (ExecutionException e) {
Throwable cause = (e.getCause() != null) ? e.getCause() : e;
if (cause != null && cause instanceof StatusRuntimeException) {
StatusRuntimeException sre = (StatusRuntimeException) cause;
// If caught unimplemented, that means server does not support authentication.
if (sre.getStatus().getCode() == Status.Code.UNIMPLEMENTED) {
throw new UnauthenticatedException("Authentication is disabled on target host.");
}
throw AlluxioStatusException.fromStatusRuntimeException((StatusRuntimeException) cause);
}
throw new UnknownException(cause.getMessage(), cause);
} catch (TimeoutException e) {
throw new UnavailableException(e);
}
}
|
[
"public",
"void",
"start",
"(",
"String",
"channelId",
")",
"throws",
"AlluxioStatusException",
"{",
"try",
"{",
"LOG",
".",
"debug",
"(",
"\"Starting SASL handshake for ChannelId:{}\"",
",",
"channelId",
")",
";",
"// Send the server initial message.",
"mRequestObserver",
".",
"onNext",
"(",
"mSaslHandshakeClientHandler",
".",
"getInitialMessage",
"(",
"channelId",
")",
")",
";",
"// Wait until authentication status changes.",
"mAuthenticated",
".",
"get",
"(",
"mGrpcAuthTimeoutMs",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
";",
"}",
"catch",
"(",
"SaslException",
"se",
")",
"{",
"throw",
"new",
"UnauthenticatedException",
"(",
"se",
".",
"getMessage",
"(",
")",
",",
"se",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"ie",
")",
"{",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"throw",
"new",
"UnavailableException",
"(",
"ie",
".",
"getMessage",
"(",
")",
",",
"ie",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"Throwable",
"cause",
"=",
"(",
"e",
".",
"getCause",
"(",
")",
"!=",
"null",
")",
"?",
"e",
".",
"getCause",
"(",
")",
":",
"e",
";",
"if",
"(",
"cause",
"!=",
"null",
"&&",
"cause",
"instanceof",
"StatusRuntimeException",
")",
"{",
"StatusRuntimeException",
"sre",
"=",
"(",
"StatusRuntimeException",
")",
"cause",
";",
"// If caught unimplemented, that means server does not support authentication.",
"if",
"(",
"sre",
".",
"getStatus",
"(",
")",
".",
"getCode",
"(",
")",
"==",
"Status",
".",
"Code",
".",
"UNIMPLEMENTED",
")",
"{",
"throw",
"new",
"UnauthenticatedException",
"(",
"\"Authentication is disabled on target host.\"",
")",
";",
"}",
"throw",
"AlluxioStatusException",
".",
"fromStatusRuntimeException",
"(",
"(",
"StatusRuntimeException",
")",
"cause",
")",
";",
"}",
"throw",
"new",
"UnknownException",
"(",
"cause",
".",
"getMessage",
"(",
")",
",",
"cause",
")",
";",
"}",
"catch",
"(",
"TimeoutException",
"e",
")",
"{",
"throw",
"new",
"UnavailableException",
"(",
"e",
")",
";",
"}",
"}"
] |
Starts authentication with the server and wait until completion.
@param channelId channel that is authenticating with the server
@throws UnauthenticatedException
|
[
"Starts",
"authentication",
"with",
"the",
"server",
"and",
"wait",
"until",
"completion",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/security/authentication/SaslStreamClientDriver.java#L102-L128
|
19,039
|
Alluxio/alluxio
|
core/base/src/main/java/alluxio/underfs/UfsStatus.java
|
UfsStatus.convertToNames
|
@Nullable
public static String[] convertToNames(UfsStatus[] children) {
if (children == null) {
return null;
}
String[] ret = new String[children.length];
for (int i = 0; i < children.length; ++i) {
ret[i] = children[i].getName();
}
return ret;
}
|
java
|
@Nullable
public static String[] convertToNames(UfsStatus[] children) {
if (children == null) {
return null;
}
String[] ret = new String[children.length];
for (int i = 0; i < children.length; ++i) {
ret[i] = children[i].getName();
}
return ret;
}
|
[
"@",
"Nullable",
"public",
"static",
"String",
"[",
"]",
"convertToNames",
"(",
"UfsStatus",
"[",
"]",
"children",
")",
"{",
"if",
"(",
"children",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"String",
"[",
"]",
"ret",
"=",
"new",
"String",
"[",
"children",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"++",
"i",
")",
"{",
"ret",
"[",
"i",
"]",
"=",
"children",
"[",
"i",
"]",
".",
"getName",
"(",
")",
";",
"}",
"return",
"ret",
";",
"}"
] |
Converts an array of UFS file status to a listing result where each element in the array is
a file or directory name.
@param children array of listing statuses
@return array of file or directory names, or null if the input is null
|
[
"Converts",
"an",
"array",
"of",
"UFS",
"file",
"status",
"to",
"a",
"listing",
"result",
"where",
"each",
"element",
"in",
"the",
"array",
"is",
"a",
"file",
"or",
"directory",
"name",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/base/src/main/java/alluxio/underfs/UfsStatus.java#L84-L94
|
19,040
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/MasterUtils.java
|
MasterUtils.createMasters
|
public static void createMasters(MasterRegistry registry, MasterContext context) {
List<Callable<Void>> callables = new ArrayList<>();
for (final MasterFactory factory : alluxio.master.ServiceUtils.getMasterServiceLoader()) {
callables.add(() -> {
if (factory.isEnabled()) {
factory.create(registry, context);
}
return null;
});
}
try {
CommonUtils.invokeAll(callables, 10 * Constants.MINUTE_MS);
} catch (Exception e) {
throw new RuntimeException("Failed to start masters", e);
}
}
|
java
|
public static void createMasters(MasterRegistry registry, MasterContext context) {
List<Callable<Void>> callables = new ArrayList<>();
for (final MasterFactory factory : alluxio.master.ServiceUtils.getMasterServiceLoader()) {
callables.add(() -> {
if (factory.isEnabled()) {
factory.create(registry, context);
}
return null;
});
}
try {
CommonUtils.invokeAll(callables, 10 * Constants.MINUTE_MS);
} catch (Exception e) {
throw new RuntimeException("Failed to start masters", e);
}
}
|
[
"public",
"static",
"void",
"createMasters",
"(",
"MasterRegistry",
"registry",
",",
"MasterContext",
"context",
")",
"{",
"List",
"<",
"Callable",
"<",
"Void",
">>",
"callables",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"final",
"MasterFactory",
"factory",
":",
"alluxio",
".",
"master",
".",
"ServiceUtils",
".",
"getMasterServiceLoader",
"(",
")",
")",
"{",
"callables",
".",
"add",
"(",
"(",
")",
"->",
"{",
"if",
"(",
"factory",
".",
"isEnabled",
"(",
")",
")",
"{",
"factory",
".",
"create",
"(",
"registry",
",",
"context",
")",
";",
"}",
"return",
"null",
";",
"}",
")",
";",
"}",
"try",
"{",
"CommonUtils",
".",
"invokeAll",
"(",
"callables",
",",
"10",
"*",
"Constants",
".",
"MINUTE_MS",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to start masters\"",
",",
"e",
")",
";",
"}",
"}"
] |
Creates all the masters and registers them to the master registry.
@param registry the master registry
@param context master context
|
[
"Creates",
"all",
"the",
"masters",
"and",
"registers",
"them",
"to",
"the",
"master",
"registry",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/MasterUtils.java#L44-L59
|
19,041
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/evictor/EvictorUtils.java
|
EvictorUtils.selectDirWithRequestedSpace
|
@Nullable
public static StorageDirView selectDirWithRequestedSpace(long bytesToBeAvailable,
BlockStoreLocation location, BlockMetadataManagerView mManagerView) {
if (location.equals(BlockStoreLocation.anyTier())) {
for (StorageTierView tierView : mManagerView.getTierViews()) {
for (StorageDirView dirView : tierView.getDirViews()) {
if (dirView.getAvailableBytes() >= bytesToBeAvailable) {
return dirView;
}
}
}
return null;
}
String tierAlias = location.tierAlias();
StorageTierView tierView = mManagerView.getTierView(tierAlias);
if (location.equals(BlockStoreLocation.anyDirInTier(tierAlias))) {
for (StorageDirView dirView : tierView.getDirViews()) {
if (dirView.getAvailableBytes() >= bytesToBeAvailable) {
return dirView;
}
}
return null;
}
StorageDirView dirView = tierView.getDirView(location.dir());
return (dirView.getAvailableBytes() >= bytesToBeAvailable) ? dirView : null;
}
|
java
|
@Nullable
public static StorageDirView selectDirWithRequestedSpace(long bytesToBeAvailable,
BlockStoreLocation location, BlockMetadataManagerView mManagerView) {
if (location.equals(BlockStoreLocation.anyTier())) {
for (StorageTierView tierView : mManagerView.getTierViews()) {
for (StorageDirView dirView : tierView.getDirViews()) {
if (dirView.getAvailableBytes() >= bytesToBeAvailable) {
return dirView;
}
}
}
return null;
}
String tierAlias = location.tierAlias();
StorageTierView tierView = mManagerView.getTierView(tierAlias);
if (location.equals(BlockStoreLocation.anyDirInTier(tierAlias))) {
for (StorageDirView dirView : tierView.getDirViews()) {
if (dirView.getAvailableBytes() >= bytesToBeAvailable) {
return dirView;
}
}
return null;
}
StorageDirView dirView = tierView.getDirView(location.dir());
return (dirView.getAvailableBytes() >= bytesToBeAvailable) ? dirView : null;
}
|
[
"@",
"Nullable",
"public",
"static",
"StorageDirView",
"selectDirWithRequestedSpace",
"(",
"long",
"bytesToBeAvailable",
",",
"BlockStoreLocation",
"location",
",",
"BlockMetadataManagerView",
"mManagerView",
")",
"{",
"if",
"(",
"location",
".",
"equals",
"(",
"BlockStoreLocation",
".",
"anyTier",
"(",
")",
")",
")",
"{",
"for",
"(",
"StorageTierView",
"tierView",
":",
"mManagerView",
".",
"getTierViews",
"(",
")",
")",
"{",
"for",
"(",
"StorageDirView",
"dirView",
":",
"tierView",
".",
"getDirViews",
"(",
")",
")",
"{",
"if",
"(",
"dirView",
".",
"getAvailableBytes",
"(",
")",
">=",
"bytesToBeAvailable",
")",
"{",
"return",
"dirView",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}",
"String",
"tierAlias",
"=",
"location",
".",
"tierAlias",
"(",
")",
";",
"StorageTierView",
"tierView",
"=",
"mManagerView",
".",
"getTierView",
"(",
"tierAlias",
")",
";",
"if",
"(",
"location",
".",
"equals",
"(",
"BlockStoreLocation",
".",
"anyDirInTier",
"(",
"tierAlias",
")",
")",
")",
"{",
"for",
"(",
"StorageDirView",
"dirView",
":",
"tierView",
".",
"getDirViews",
"(",
")",
")",
"{",
"if",
"(",
"dirView",
".",
"getAvailableBytes",
"(",
")",
">=",
"bytesToBeAvailable",
")",
"{",
"return",
"dirView",
";",
"}",
"}",
"return",
"null",
";",
"}",
"StorageDirView",
"dirView",
"=",
"tierView",
".",
"getDirView",
"(",
"location",
".",
"dir",
"(",
")",
")",
";",
"return",
"(",
"dirView",
".",
"getAvailableBytes",
"(",
")",
">=",
"bytesToBeAvailable",
")",
"?",
"dirView",
":",
"null",
";",
"}"
] |
Finds a directory in the given location range with capacity upwards of the given bound.
@param bytesToBeAvailable the capacity bound
@param location the location range
@param mManagerView the storage manager view
@return a {@link StorageDirView} in the range of location that already has availableBytes
larger than bytesToBeAvailable, otherwise null
|
[
"Finds",
"a",
"directory",
"in",
"the",
"given",
"location",
"range",
"with",
"capacity",
"upwards",
"of",
"the",
"given",
"bound",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/evictor/EvictorUtils.java#L84-L111
|
19,042
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/ShortCircuitBlockReadHandler.java
|
ShortCircuitBlockReadHandler.onNext
|
@Override
public void onNext(OpenLocalBlockRequest request) {
RpcUtils.streamingRPCAndLog(LOG, new RpcUtils.StreamingRpcCallable<OpenLocalBlockResponse>() {
@Override
public OpenLocalBlockResponse call() throws Exception {
Preconditions.checkState(mRequest == null);
mRequest = request;
if (mLockId == BlockLockManager.INVALID_LOCK_ID) {
mSessionId = IdUtils.createSessionId();
// TODO(calvin): Update the locking logic so this can be done better
if (mRequest.getPromote()) {
try {
mWorker
.moveBlock(mSessionId, mRequest.getBlockId(), mStorageTierAssoc.getAlias(0));
} catch (BlockDoesNotExistException e) {
LOG.debug("Block {} to promote does not exist in Alluxio: {}",
mRequest.getBlockId(), e.getMessage());
} catch (Exception e) {
LOG.warn("Failed to promote block {}: {}", mRequest.getBlockId(), e.getMessage());
}
}
mLockId = mWorker.lockBlock(mSessionId, mRequest.getBlockId());
mWorker.accessBlock(mSessionId, mRequest.getBlockId());
} else {
LOG.warn("Lock block {} without releasing previous block lock {}.",
mRequest.getBlockId(), mLockId);
throw new InvalidWorkerStateException(
ExceptionMessage.LOCK_NOT_RELEASED.getMessage(mLockId));
}
OpenLocalBlockResponse response = OpenLocalBlockResponse.newBuilder()
.setPath(mWorker.readBlock(mSessionId, mRequest.getBlockId(), mLockId)).build();
return response;
}
@Override
public void exceptionCaught(Throwable e) {
if (mLockId != BlockLockManager.INVALID_LOCK_ID) {
try {
mWorker.unlockBlock(mLockId);
} catch (BlockDoesNotExistException ee) {
LOG.error("Failed to unlock block {}.", mRequest.getBlockId(), e);
}
mLockId = BlockLockManager.INVALID_LOCK_ID;
}
mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(e));
}
}, "OpenBlock", true, false, mResponseObserver, "Session=%d, Request=%s",
mSessionId, mRequest);
}
|
java
|
@Override
public void onNext(OpenLocalBlockRequest request) {
RpcUtils.streamingRPCAndLog(LOG, new RpcUtils.StreamingRpcCallable<OpenLocalBlockResponse>() {
@Override
public OpenLocalBlockResponse call() throws Exception {
Preconditions.checkState(mRequest == null);
mRequest = request;
if (mLockId == BlockLockManager.INVALID_LOCK_ID) {
mSessionId = IdUtils.createSessionId();
// TODO(calvin): Update the locking logic so this can be done better
if (mRequest.getPromote()) {
try {
mWorker
.moveBlock(mSessionId, mRequest.getBlockId(), mStorageTierAssoc.getAlias(0));
} catch (BlockDoesNotExistException e) {
LOG.debug("Block {} to promote does not exist in Alluxio: {}",
mRequest.getBlockId(), e.getMessage());
} catch (Exception e) {
LOG.warn("Failed to promote block {}: {}", mRequest.getBlockId(), e.getMessage());
}
}
mLockId = mWorker.lockBlock(mSessionId, mRequest.getBlockId());
mWorker.accessBlock(mSessionId, mRequest.getBlockId());
} else {
LOG.warn("Lock block {} without releasing previous block lock {}.",
mRequest.getBlockId(), mLockId);
throw new InvalidWorkerStateException(
ExceptionMessage.LOCK_NOT_RELEASED.getMessage(mLockId));
}
OpenLocalBlockResponse response = OpenLocalBlockResponse.newBuilder()
.setPath(mWorker.readBlock(mSessionId, mRequest.getBlockId(), mLockId)).build();
return response;
}
@Override
public void exceptionCaught(Throwable e) {
if (mLockId != BlockLockManager.INVALID_LOCK_ID) {
try {
mWorker.unlockBlock(mLockId);
} catch (BlockDoesNotExistException ee) {
LOG.error("Failed to unlock block {}.", mRequest.getBlockId(), e);
}
mLockId = BlockLockManager.INVALID_LOCK_ID;
}
mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(e));
}
}, "OpenBlock", true, false, mResponseObserver, "Session=%d, Request=%s",
mSessionId, mRequest);
}
|
[
"@",
"Override",
"public",
"void",
"onNext",
"(",
"OpenLocalBlockRequest",
"request",
")",
"{",
"RpcUtils",
".",
"streamingRPCAndLog",
"(",
"LOG",
",",
"new",
"RpcUtils",
".",
"StreamingRpcCallable",
"<",
"OpenLocalBlockResponse",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OpenLocalBlockResponse",
"call",
"(",
")",
"throws",
"Exception",
"{",
"Preconditions",
".",
"checkState",
"(",
"mRequest",
"==",
"null",
")",
";",
"mRequest",
"=",
"request",
";",
"if",
"(",
"mLockId",
"==",
"BlockLockManager",
".",
"INVALID_LOCK_ID",
")",
"{",
"mSessionId",
"=",
"IdUtils",
".",
"createSessionId",
"(",
")",
";",
"// TODO(calvin): Update the locking logic so this can be done better",
"if",
"(",
"mRequest",
".",
"getPromote",
"(",
")",
")",
"{",
"try",
"{",
"mWorker",
".",
"moveBlock",
"(",
"mSessionId",
",",
"mRequest",
".",
"getBlockId",
"(",
")",
",",
"mStorageTierAssoc",
".",
"getAlias",
"(",
"0",
")",
")",
";",
"}",
"catch",
"(",
"BlockDoesNotExistException",
"e",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Block {} to promote does not exist in Alluxio: {}\"",
",",
"mRequest",
".",
"getBlockId",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to promote block {}: {}\"",
",",
"mRequest",
".",
"getBlockId",
"(",
")",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"mLockId",
"=",
"mWorker",
".",
"lockBlock",
"(",
"mSessionId",
",",
"mRequest",
".",
"getBlockId",
"(",
")",
")",
";",
"mWorker",
".",
"accessBlock",
"(",
"mSessionId",
",",
"mRequest",
".",
"getBlockId",
"(",
")",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"warn",
"(",
"\"Lock block {} without releasing previous block lock {}.\"",
",",
"mRequest",
".",
"getBlockId",
"(",
")",
",",
"mLockId",
")",
";",
"throw",
"new",
"InvalidWorkerStateException",
"(",
"ExceptionMessage",
".",
"LOCK_NOT_RELEASED",
".",
"getMessage",
"(",
"mLockId",
")",
")",
";",
"}",
"OpenLocalBlockResponse",
"response",
"=",
"OpenLocalBlockResponse",
".",
"newBuilder",
"(",
")",
".",
"setPath",
"(",
"mWorker",
".",
"readBlock",
"(",
"mSessionId",
",",
"mRequest",
".",
"getBlockId",
"(",
")",
",",
"mLockId",
")",
")",
".",
"build",
"(",
")",
";",
"return",
"response",
";",
"}",
"@",
"Override",
"public",
"void",
"exceptionCaught",
"(",
"Throwable",
"e",
")",
"{",
"if",
"(",
"mLockId",
"!=",
"BlockLockManager",
".",
"INVALID_LOCK_ID",
")",
"{",
"try",
"{",
"mWorker",
".",
"unlockBlock",
"(",
"mLockId",
")",
";",
"}",
"catch",
"(",
"BlockDoesNotExistException",
"ee",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to unlock block {}.\"",
",",
"mRequest",
".",
"getBlockId",
"(",
")",
",",
"e",
")",
";",
"}",
"mLockId",
"=",
"BlockLockManager",
".",
"INVALID_LOCK_ID",
";",
"}",
"mResponseObserver",
".",
"onError",
"(",
"GrpcExceptionUtils",
".",
"fromThrowable",
"(",
"e",
")",
")",
";",
"}",
"}",
",",
"\"OpenBlock\"",
",",
"true",
",",
"false",
",",
"mResponseObserver",
",",
"\"Session=%d, Request=%s\"",
",",
"mSessionId",
",",
"mRequest",
")",
";",
"}"
] |
Handles block open request.
|
[
"Handles",
"block",
"open",
"request",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/ShortCircuitBlockReadHandler.java#L71-L119
|
19,043
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/grpc/ShortCircuitBlockReadHandler.java
|
ShortCircuitBlockReadHandler.onCompleted
|
@Override
public void onCompleted() {
RpcUtils.streamingRPCAndLog(LOG, new RpcUtils.StreamingRpcCallable<OpenLocalBlockResponse>() {
@Override
public OpenLocalBlockResponse call() throws Exception {
if (mLockId != BlockLockManager.INVALID_LOCK_ID) {
mWorker.unlockBlock(mLockId);
mLockId = BlockLockManager.INVALID_LOCK_ID;
} else if (mRequest != null) {
LOG.warn("Close a closed block {}.", mRequest.getBlockId());
}
return null;
}
@Override
public void exceptionCaught(Throwable e) {
mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(e));
mLockId = BlockLockManager.INVALID_LOCK_ID;
}
}, "CloseBlock", false, true, mResponseObserver, "Session=%d, Request=%s",
mSessionId, mRequest);
}
|
java
|
@Override
public void onCompleted() {
RpcUtils.streamingRPCAndLog(LOG, new RpcUtils.StreamingRpcCallable<OpenLocalBlockResponse>() {
@Override
public OpenLocalBlockResponse call() throws Exception {
if (mLockId != BlockLockManager.INVALID_LOCK_ID) {
mWorker.unlockBlock(mLockId);
mLockId = BlockLockManager.INVALID_LOCK_ID;
} else if (mRequest != null) {
LOG.warn("Close a closed block {}.", mRequest.getBlockId());
}
return null;
}
@Override
public void exceptionCaught(Throwable e) {
mResponseObserver.onError(GrpcExceptionUtils.fromThrowable(e));
mLockId = BlockLockManager.INVALID_LOCK_ID;
}
}, "CloseBlock", false, true, mResponseObserver, "Session=%d, Request=%s",
mSessionId, mRequest);
}
|
[
"@",
"Override",
"public",
"void",
"onCompleted",
"(",
")",
"{",
"RpcUtils",
".",
"streamingRPCAndLog",
"(",
"LOG",
",",
"new",
"RpcUtils",
".",
"StreamingRpcCallable",
"<",
"OpenLocalBlockResponse",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"OpenLocalBlockResponse",
"call",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"mLockId",
"!=",
"BlockLockManager",
".",
"INVALID_LOCK_ID",
")",
"{",
"mWorker",
".",
"unlockBlock",
"(",
"mLockId",
")",
";",
"mLockId",
"=",
"BlockLockManager",
".",
"INVALID_LOCK_ID",
";",
"}",
"else",
"if",
"(",
"mRequest",
"!=",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Close a closed block {}.\"",
",",
"mRequest",
".",
"getBlockId",
"(",
")",
")",
";",
"}",
"return",
"null",
";",
"}",
"@",
"Override",
"public",
"void",
"exceptionCaught",
"(",
"Throwable",
"e",
")",
"{",
"mResponseObserver",
".",
"onError",
"(",
"GrpcExceptionUtils",
".",
"fromThrowable",
"(",
"e",
")",
")",
";",
"mLockId",
"=",
"BlockLockManager",
".",
"INVALID_LOCK_ID",
";",
"}",
"}",
",",
"\"CloseBlock\"",
",",
"false",
",",
"true",
",",
"mResponseObserver",
",",
"\"Session=%d, Request=%s\"",
",",
"mSessionId",
",",
"mRequest",
")",
";",
"}"
] |
Handles block close request. No exceptions should be thrown.
|
[
"Handles",
"block",
"close",
"request",
".",
"No",
"exceptions",
"should",
"be",
"thrown",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/grpc/ShortCircuitBlockReadHandler.java#L138-L159
|
19,044
|
Alluxio/alluxio
|
integration/mesos/src/main/java/alluxio/mesos/AlluxioFramework.java
|
AlluxioFramework.run
|
public void run() {
Protos.FrameworkInfo.Builder frameworkInfo = Protos.FrameworkInfo.newBuilder()
.setName("alluxio").setCheckpoint(true);
if (ServerConfiguration.isSet(PropertyKey.INTEGRATION_MESOS_ROLE)) {
frameworkInfo.setRole(ServerConfiguration.get(PropertyKey.INTEGRATION_MESOS_ROLE));
}
if (ServerConfiguration.isSet(PropertyKey.INTEGRATION_MESOS_USER)) {
frameworkInfo.setUser(ServerConfiguration.get(PropertyKey.INTEGRATION_MESOS_USER));
} else {
// Setting the user to an empty string will prompt Mesos to set it to the current user.
frameworkInfo.setUser("");
}
if (ServerConfiguration.isSet(PropertyKey.INTEGRATION_MESOS_PRINCIPAL)) {
frameworkInfo.setPrincipal(ServerConfiguration.get(PropertyKey.INTEGRATION_MESOS_PRINCIPAL));
}
// Publish WebUI url to mesos master.
String masterWebUrl = createMasterWebUrl();
frameworkInfo.setWebuiUrl(masterWebUrl);
Scheduler scheduler = new AlluxioScheduler(mAlluxioMasterHostname);
Protos.Credential cred = createCredential();
MesosSchedulerDriver driver;
if (cred == null) {
driver = new MesosSchedulerDriver(scheduler, frameworkInfo.build(), mMesosMaster);
} else {
driver = new MesosSchedulerDriver(scheduler, frameworkInfo.build(), mMesosMaster, cred);
}
int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;
System.exit(status);
}
|
java
|
public void run() {
Protos.FrameworkInfo.Builder frameworkInfo = Protos.FrameworkInfo.newBuilder()
.setName("alluxio").setCheckpoint(true);
if (ServerConfiguration.isSet(PropertyKey.INTEGRATION_MESOS_ROLE)) {
frameworkInfo.setRole(ServerConfiguration.get(PropertyKey.INTEGRATION_MESOS_ROLE));
}
if (ServerConfiguration.isSet(PropertyKey.INTEGRATION_MESOS_USER)) {
frameworkInfo.setUser(ServerConfiguration.get(PropertyKey.INTEGRATION_MESOS_USER));
} else {
// Setting the user to an empty string will prompt Mesos to set it to the current user.
frameworkInfo.setUser("");
}
if (ServerConfiguration.isSet(PropertyKey.INTEGRATION_MESOS_PRINCIPAL)) {
frameworkInfo.setPrincipal(ServerConfiguration.get(PropertyKey.INTEGRATION_MESOS_PRINCIPAL));
}
// Publish WebUI url to mesos master.
String masterWebUrl = createMasterWebUrl();
frameworkInfo.setWebuiUrl(masterWebUrl);
Scheduler scheduler = new AlluxioScheduler(mAlluxioMasterHostname);
Protos.Credential cred = createCredential();
MesosSchedulerDriver driver;
if (cred == null) {
driver = new MesosSchedulerDriver(scheduler, frameworkInfo.build(), mMesosMaster);
} else {
driver = new MesosSchedulerDriver(scheduler, frameworkInfo.build(), mMesosMaster, cred);
}
int status = driver.run() == Protos.Status.DRIVER_STOPPED ? 0 : 1;
System.exit(status);
}
|
[
"public",
"void",
"run",
"(",
")",
"{",
"Protos",
".",
"FrameworkInfo",
".",
"Builder",
"frameworkInfo",
"=",
"Protos",
".",
"FrameworkInfo",
".",
"newBuilder",
"(",
")",
".",
"setName",
"(",
"\"alluxio\"",
")",
".",
"setCheckpoint",
"(",
"true",
")",
";",
"if",
"(",
"ServerConfiguration",
".",
"isSet",
"(",
"PropertyKey",
".",
"INTEGRATION_MESOS_ROLE",
")",
")",
"{",
"frameworkInfo",
".",
"setRole",
"(",
"ServerConfiguration",
".",
"get",
"(",
"PropertyKey",
".",
"INTEGRATION_MESOS_ROLE",
")",
")",
";",
"}",
"if",
"(",
"ServerConfiguration",
".",
"isSet",
"(",
"PropertyKey",
".",
"INTEGRATION_MESOS_USER",
")",
")",
"{",
"frameworkInfo",
".",
"setUser",
"(",
"ServerConfiguration",
".",
"get",
"(",
"PropertyKey",
".",
"INTEGRATION_MESOS_USER",
")",
")",
";",
"}",
"else",
"{",
"// Setting the user to an empty string will prompt Mesos to set it to the current user.",
"frameworkInfo",
".",
"setUser",
"(",
"\"\"",
")",
";",
"}",
"if",
"(",
"ServerConfiguration",
".",
"isSet",
"(",
"PropertyKey",
".",
"INTEGRATION_MESOS_PRINCIPAL",
")",
")",
"{",
"frameworkInfo",
".",
"setPrincipal",
"(",
"ServerConfiguration",
".",
"get",
"(",
"PropertyKey",
".",
"INTEGRATION_MESOS_PRINCIPAL",
")",
")",
";",
"}",
"// Publish WebUI url to mesos master.",
"String",
"masterWebUrl",
"=",
"createMasterWebUrl",
"(",
")",
";",
"frameworkInfo",
".",
"setWebuiUrl",
"(",
"masterWebUrl",
")",
";",
"Scheduler",
"scheduler",
"=",
"new",
"AlluxioScheduler",
"(",
"mAlluxioMasterHostname",
")",
";",
"Protos",
".",
"Credential",
"cred",
"=",
"createCredential",
"(",
")",
";",
"MesosSchedulerDriver",
"driver",
";",
"if",
"(",
"cred",
"==",
"null",
")",
"{",
"driver",
"=",
"new",
"MesosSchedulerDriver",
"(",
"scheduler",
",",
"frameworkInfo",
".",
"build",
"(",
")",
",",
"mMesosMaster",
")",
";",
"}",
"else",
"{",
"driver",
"=",
"new",
"MesosSchedulerDriver",
"(",
"scheduler",
",",
"frameworkInfo",
".",
"build",
"(",
")",
",",
"mMesosMaster",
",",
"cred",
")",
";",
"}",
"int",
"status",
"=",
"driver",
".",
"run",
"(",
")",
"==",
"Protos",
".",
"Status",
".",
"DRIVER_STOPPED",
"?",
"0",
":",
"1",
";",
"System",
".",
"exit",
"(",
"status",
")",
";",
"}"
] |
Runs the mesos framework.
|
[
"Runs",
"the",
"mesos",
"framework",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/mesos/src/main/java/alluxio/mesos/AlluxioFramework.java#L63-L98
|
19,045
|
Alluxio/alluxio
|
integration/mesos/src/main/java/alluxio/mesos/AlluxioFramework.java
|
AlluxioFramework.createMasterWebUrl
|
private static String createMasterWebUrl() {
InetSocketAddress masterWeb = NetworkAddressUtils.getConnectAddress(
ServiceType.MASTER_WEB, ServerConfiguration.global());
return "http://" + masterWeb.getHostString() + ":" + masterWeb.getPort();
}
|
java
|
private static String createMasterWebUrl() {
InetSocketAddress masterWeb = NetworkAddressUtils.getConnectAddress(
ServiceType.MASTER_WEB, ServerConfiguration.global());
return "http://" + masterWeb.getHostString() + ":" + masterWeb.getPort();
}
|
[
"private",
"static",
"String",
"createMasterWebUrl",
"(",
")",
"{",
"InetSocketAddress",
"masterWeb",
"=",
"NetworkAddressUtils",
".",
"getConnectAddress",
"(",
"ServiceType",
".",
"MASTER_WEB",
",",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
";",
"return",
"\"http://\"",
"+",
"masterWeb",
".",
"getHostString",
"(",
")",
"+",
"\":\"",
"+",
"masterWeb",
".",
"getPort",
"(",
")",
";",
"}"
] |
Create AlluxioMaster web url.
|
[
"Create",
"AlluxioMaster",
"web",
"url",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/mesos/src/main/java/alluxio/mesos/AlluxioFramework.java#L103-L107
|
19,046
|
Alluxio/alluxio
|
integration/mesos/src/main/java/alluxio/mesos/AlluxioFramework.java
|
AlluxioFramework.main
|
public static void main(String[] args) throws Exception {
AlluxioFramework framework = new AlluxioFramework();
JCommander jc = new JCommander(framework);
try {
jc.parse(args);
} catch (Exception e) {
System.out.println(e.getMessage());
jc.usage();
System.exit(1);
}
framework.run();
}
|
java
|
public static void main(String[] args) throws Exception {
AlluxioFramework framework = new AlluxioFramework();
JCommander jc = new JCommander(framework);
try {
jc.parse(args);
} catch (Exception e) {
System.out.println(e.getMessage());
jc.usage();
System.exit(1);
}
framework.run();
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"AlluxioFramework",
"framework",
"=",
"new",
"AlluxioFramework",
"(",
")",
";",
"JCommander",
"jc",
"=",
"new",
"JCommander",
"(",
"framework",
")",
";",
"try",
"{",
"jc",
".",
"parse",
"(",
"args",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"jc",
".",
"usage",
"(",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"framework",
".",
"run",
"(",
")",
";",
"}"
] |
Starts the Alluxio framework.
@param args command-line arguments
|
[
"Starts",
"the",
"Alluxio",
"framework",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/integration/mesos/src/main/java/alluxio/mesos/AlluxioFramework.java#L133-L144
|
19,047
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/network/TieredIdentityFactory.java
|
TieredIdentityFactory.create
|
@VisibleForTesting
static TieredIdentity create(AlluxioConfiguration conf) {
TieredIdentity scriptIdentity = fromScript(conf);
List<LocalityTier> tiers = new ArrayList<>();
List<String> orderedTierNames = conf.getList(PropertyKey.LOCALITY_ORDER, ",");
for (int i = 0; i < orderedTierNames.size(); i++) {
String tierName = orderedTierNames.get(i);
String value = null;
if (scriptIdentity != null) {
LocalityTier scriptTier = scriptIdentity.getTier(i);
Preconditions.checkState(scriptTier.getTierName().equals(tierName));
value = scriptTier.getValue();
}
// Explicit configuration overrides script output.
if (conf.isSet(Template.LOCALITY_TIER.format(tierName))) {
value = conf.get(Template.LOCALITY_TIER.format(tierName));
}
tiers.add(new LocalityTier(tierName, value));
}
// If the user doesn't specify the value of the "node" tier, we fill in a sensible default.
if (tiers.size() > 0 && tiers.get(0).getTierName().equals(Constants.LOCALITY_NODE)
&& tiers.get(0).getValue() == null) {
String name = NetworkAddressUtils.getLocalNodeName(conf);
tiers.set(0, new LocalityTier(Constants.LOCALITY_NODE, name));
}
return new TieredIdentity(tiers);
}
|
java
|
@VisibleForTesting
static TieredIdentity create(AlluxioConfiguration conf) {
TieredIdentity scriptIdentity = fromScript(conf);
List<LocalityTier> tiers = new ArrayList<>();
List<String> orderedTierNames = conf.getList(PropertyKey.LOCALITY_ORDER, ",");
for (int i = 0; i < orderedTierNames.size(); i++) {
String tierName = orderedTierNames.get(i);
String value = null;
if (scriptIdentity != null) {
LocalityTier scriptTier = scriptIdentity.getTier(i);
Preconditions.checkState(scriptTier.getTierName().equals(tierName));
value = scriptTier.getValue();
}
// Explicit configuration overrides script output.
if (conf.isSet(Template.LOCALITY_TIER.format(tierName))) {
value = conf.get(Template.LOCALITY_TIER.format(tierName));
}
tiers.add(new LocalityTier(tierName, value));
}
// If the user doesn't specify the value of the "node" tier, we fill in a sensible default.
if (tiers.size() > 0 && tiers.get(0).getTierName().equals(Constants.LOCALITY_NODE)
&& tiers.get(0).getValue() == null) {
String name = NetworkAddressUtils.getLocalNodeName(conf);
tiers.set(0, new LocalityTier(Constants.LOCALITY_NODE, name));
}
return new TieredIdentity(tiers);
}
|
[
"@",
"VisibleForTesting",
"static",
"TieredIdentity",
"create",
"(",
"AlluxioConfiguration",
"conf",
")",
"{",
"TieredIdentity",
"scriptIdentity",
"=",
"fromScript",
"(",
"conf",
")",
";",
"List",
"<",
"LocalityTier",
">",
"tiers",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"String",
">",
"orderedTierNames",
"=",
"conf",
".",
"getList",
"(",
"PropertyKey",
".",
"LOCALITY_ORDER",
",",
"\",\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"orderedTierNames",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"String",
"tierName",
"=",
"orderedTierNames",
".",
"get",
"(",
"i",
")",
";",
"String",
"value",
"=",
"null",
";",
"if",
"(",
"scriptIdentity",
"!=",
"null",
")",
"{",
"LocalityTier",
"scriptTier",
"=",
"scriptIdentity",
".",
"getTier",
"(",
"i",
")",
";",
"Preconditions",
".",
"checkState",
"(",
"scriptTier",
".",
"getTierName",
"(",
")",
".",
"equals",
"(",
"tierName",
")",
")",
";",
"value",
"=",
"scriptTier",
".",
"getValue",
"(",
")",
";",
"}",
"// Explicit configuration overrides script output.",
"if",
"(",
"conf",
".",
"isSet",
"(",
"Template",
".",
"LOCALITY_TIER",
".",
"format",
"(",
"tierName",
")",
")",
")",
"{",
"value",
"=",
"conf",
".",
"get",
"(",
"Template",
".",
"LOCALITY_TIER",
".",
"format",
"(",
"tierName",
")",
")",
";",
"}",
"tiers",
".",
"add",
"(",
"new",
"LocalityTier",
"(",
"tierName",
",",
"value",
")",
")",
";",
"}",
"// If the user doesn't specify the value of the \"node\" tier, we fill in a sensible default.",
"if",
"(",
"tiers",
".",
"size",
"(",
")",
">",
"0",
"&&",
"tiers",
".",
"get",
"(",
"0",
")",
".",
"getTierName",
"(",
")",
".",
"equals",
"(",
"Constants",
".",
"LOCALITY_NODE",
")",
"&&",
"tiers",
".",
"get",
"(",
"0",
")",
".",
"getValue",
"(",
")",
"==",
"null",
")",
"{",
"String",
"name",
"=",
"NetworkAddressUtils",
".",
"getLocalNodeName",
"(",
"conf",
")",
";",
"tiers",
".",
"set",
"(",
"0",
",",
"new",
"LocalityTier",
"(",
"Constants",
".",
"LOCALITY_NODE",
",",
"name",
")",
")",
";",
"}",
"return",
"new",
"TieredIdentity",
"(",
"tiers",
")",
";",
"}"
] |
Creates a tiered identity based on configuration.
@return the created tiered identity
|
[
"Creates",
"a",
"tiered",
"identity",
"based",
"on",
"configuration",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/network/TieredIdentityFactory.java#L75-L102
|
19,048
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/underfs/UnderFileSystemConfiguration.java
|
UnderFileSystemConfiguration.createMountSpecificConf
|
public UnderFileSystemConfiguration createMountSpecificConf(Map<String, String> mountConf) {
UnderFileSystemConfiguration ufsConf = new UnderFileSystemConfiguration(mProperties.copy());
ufsConf.mProperties.merge(mountConf, Source.MOUNT_OPTION);
ufsConf.mReadOnly = mReadOnly;
ufsConf.mShared = mShared;
return ufsConf;
}
|
java
|
public UnderFileSystemConfiguration createMountSpecificConf(Map<String, String> mountConf) {
UnderFileSystemConfiguration ufsConf = new UnderFileSystemConfiguration(mProperties.copy());
ufsConf.mProperties.merge(mountConf, Source.MOUNT_OPTION);
ufsConf.mReadOnly = mReadOnly;
ufsConf.mShared = mShared;
return ufsConf;
}
|
[
"public",
"UnderFileSystemConfiguration",
"createMountSpecificConf",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"mountConf",
")",
"{",
"UnderFileSystemConfiguration",
"ufsConf",
"=",
"new",
"UnderFileSystemConfiguration",
"(",
"mProperties",
".",
"copy",
"(",
")",
")",
";",
"ufsConf",
".",
"mProperties",
".",
"merge",
"(",
"mountConf",
",",
"Source",
".",
"MOUNT_OPTION",
")",
";",
"ufsConf",
".",
"mReadOnly",
"=",
"mReadOnly",
";",
"ufsConf",
".",
"mShared",
"=",
"mShared",
";",
"return",
"ufsConf",
";",
"}"
] |
Creates a new instance from the current configuration and adds in new properties.
@param mountConf the mount specific configuration map
@return the updated configuration object
|
[
"Creates",
"a",
"new",
"instance",
"from",
"the",
"current",
"configuration",
"and",
"adds",
"in",
"new",
"properties",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/underfs/UnderFileSystemConfiguration.java#L121-L127
|
19,049
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMasterSync.java
|
BlockMasterSync.registerWithMaster
|
private void registerWithMaster() throws IOException {
BlockStoreMeta storeMeta = mBlockWorker.getStoreMetaFull();
StorageTierAssoc storageTierAssoc = new WorkerStorageTierAssoc();
List<ConfigProperty> configList =
ConfigurationUtils.getConfiguration(ServerConfiguration.global(), Scope.WORKER);
mMasterClient.register(mWorkerId.get(),
storageTierAssoc.getOrderedStorageAliases(), storeMeta.getCapacityBytesOnTiers(),
storeMeta.getUsedBytesOnTiers(), storeMeta.getBlockList(),
storeMeta.getLostStorage(), configList);
}
|
java
|
private void registerWithMaster() throws IOException {
BlockStoreMeta storeMeta = mBlockWorker.getStoreMetaFull();
StorageTierAssoc storageTierAssoc = new WorkerStorageTierAssoc();
List<ConfigProperty> configList =
ConfigurationUtils.getConfiguration(ServerConfiguration.global(), Scope.WORKER);
mMasterClient.register(mWorkerId.get(),
storageTierAssoc.getOrderedStorageAliases(), storeMeta.getCapacityBytesOnTiers(),
storeMeta.getUsedBytesOnTiers(), storeMeta.getBlockList(),
storeMeta.getLostStorage(), configList);
}
|
[
"private",
"void",
"registerWithMaster",
"(",
")",
"throws",
"IOException",
"{",
"BlockStoreMeta",
"storeMeta",
"=",
"mBlockWorker",
".",
"getStoreMetaFull",
"(",
")",
";",
"StorageTierAssoc",
"storageTierAssoc",
"=",
"new",
"WorkerStorageTierAssoc",
"(",
")",
";",
"List",
"<",
"ConfigProperty",
">",
"configList",
"=",
"ConfigurationUtils",
".",
"getConfiguration",
"(",
"ServerConfiguration",
".",
"global",
"(",
")",
",",
"Scope",
".",
"WORKER",
")",
";",
"mMasterClient",
".",
"register",
"(",
"mWorkerId",
".",
"get",
"(",
")",
",",
"storageTierAssoc",
".",
"getOrderedStorageAliases",
"(",
")",
",",
"storeMeta",
".",
"getCapacityBytesOnTiers",
"(",
")",
",",
"storeMeta",
".",
"getUsedBytesOnTiers",
"(",
")",
",",
"storeMeta",
".",
"getBlockList",
"(",
")",
",",
"storeMeta",
".",
"getLostStorage",
"(",
")",
",",
"configList",
")",
";",
"}"
] |
Registers with the Alluxio master. This should be called before the continuous heartbeat thread
begins.
|
[
"Registers",
"with",
"the",
"Alluxio",
"master",
".",
"This",
"should",
"be",
"called",
"before",
"the",
"continuous",
"heartbeat",
"thread",
"begins",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMasterSync.java#L103-L112
|
19,050
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/block/BlockMasterSync.java
|
BlockMasterSync.heartbeat
|
@Override
public void heartbeat() {
// Prepare metadata for the next heartbeat
BlockHeartbeatReport blockReport = mBlockWorker.getReport();
BlockStoreMeta storeMeta = mBlockWorker.getStoreMeta();
// Send the heartbeat and execute the response
Command cmdFromMaster = null;
List<alluxio.grpc.Metric> metrics = new ArrayList<>();
for (Metric metric : MetricsSystem.allWorkerMetrics()) {
metrics.add(metric.toProto());
}
try {
cmdFromMaster = mMasterClient.heartbeat(mWorkerId.get(), storeMeta.getCapacityBytesOnTiers(),
storeMeta.getUsedBytesOnTiers(), blockReport.getRemovedBlocks(),
blockReport.getAddedBlocks(), blockReport.getLostStorage(), metrics);
handleMasterCommand(cmdFromMaster);
mLastSuccessfulHeartbeatMs = System.currentTimeMillis();
} catch (IOException | ConnectionFailedException e) {
// An error occurred, log and ignore it or error if heartbeat timeout is reached
if (cmdFromMaster == null) {
LOG.error("Failed to receive master heartbeat command.", e);
} else {
LOG.error("Failed to receive or execute master heartbeat command: {}",
cmdFromMaster.toString(), e);
}
mMasterClient.disconnect();
if (mHeartbeatTimeoutMs > 0) {
if (System.currentTimeMillis() - mLastSuccessfulHeartbeatMs >= mHeartbeatTimeoutMs) {
if (ServerConfiguration.getBoolean(PropertyKey.TEST_MODE)) {
throw new RuntimeException("Master heartbeat timeout exceeded: " + mHeartbeatTimeoutMs);
}
// TODO(andrew): Propagate the exception to the main thread and exit there.
ProcessUtils.fatalError(LOG, "Master heartbeat timeout exceeded: %d",
mHeartbeatTimeoutMs);
}
}
}
}
|
java
|
@Override
public void heartbeat() {
// Prepare metadata for the next heartbeat
BlockHeartbeatReport blockReport = mBlockWorker.getReport();
BlockStoreMeta storeMeta = mBlockWorker.getStoreMeta();
// Send the heartbeat and execute the response
Command cmdFromMaster = null;
List<alluxio.grpc.Metric> metrics = new ArrayList<>();
for (Metric metric : MetricsSystem.allWorkerMetrics()) {
metrics.add(metric.toProto());
}
try {
cmdFromMaster = mMasterClient.heartbeat(mWorkerId.get(), storeMeta.getCapacityBytesOnTiers(),
storeMeta.getUsedBytesOnTiers(), blockReport.getRemovedBlocks(),
blockReport.getAddedBlocks(), blockReport.getLostStorage(), metrics);
handleMasterCommand(cmdFromMaster);
mLastSuccessfulHeartbeatMs = System.currentTimeMillis();
} catch (IOException | ConnectionFailedException e) {
// An error occurred, log and ignore it or error if heartbeat timeout is reached
if (cmdFromMaster == null) {
LOG.error("Failed to receive master heartbeat command.", e);
} else {
LOG.error("Failed to receive or execute master heartbeat command: {}",
cmdFromMaster.toString(), e);
}
mMasterClient.disconnect();
if (mHeartbeatTimeoutMs > 0) {
if (System.currentTimeMillis() - mLastSuccessfulHeartbeatMs >= mHeartbeatTimeoutMs) {
if (ServerConfiguration.getBoolean(PropertyKey.TEST_MODE)) {
throw new RuntimeException("Master heartbeat timeout exceeded: " + mHeartbeatTimeoutMs);
}
// TODO(andrew): Propagate the exception to the main thread and exit there.
ProcessUtils.fatalError(LOG, "Master heartbeat timeout exceeded: %d",
mHeartbeatTimeoutMs);
}
}
}
}
|
[
"@",
"Override",
"public",
"void",
"heartbeat",
"(",
")",
"{",
"// Prepare metadata for the next heartbeat",
"BlockHeartbeatReport",
"blockReport",
"=",
"mBlockWorker",
".",
"getReport",
"(",
")",
";",
"BlockStoreMeta",
"storeMeta",
"=",
"mBlockWorker",
".",
"getStoreMeta",
"(",
")",
";",
"// Send the heartbeat and execute the response",
"Command",
"cmdFromMaster",
"=",
"null",
";",
"List",
"<",
"alluxio",
".",
"grpc",
".",
"Metric",
">",
"metrics",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Metric",
"metric",
":",
"MetricsSystem",
".",
"allWorkerMetrics",
"(",
")",
")",
"{",
"metrics",
".",
"add",
"(",
"metric",
".",
"toProto",
"(",
")",
")",
";",
"}",
"try",
"{",
"cmdFromMaster",
"=",
"mMasterClient",
".",
"heartbeat",
"(",
"mWorkerId",
".",
"get",
"(",
")",
",",
"storeMeta",
".",
"getCapacityBytesOnTiers",
"(",
")",
",",
"storeMeta",
".",
"getUsedBytesOnTiers",
"(",
")",
",",
"blockReport",
".",
"getRemovedBlocks",
"(",
")",
",",
"blockReport",
".",
"getAddedBlocks",
"(",
")",
",",
"blockReport",
".",
"getLostStorage",
"(",
")",
",",
"metrics",
")",
";",
"handleMasterCommand",
"(",
"cmdFromMaster",
")",
";",
"mLastSuccessfulHeartbeatMs",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"|",
"ConnectionFailedException",
"e",
")",
"{",
"// An error occurred, log and ignore it or error if heartbeat timeout is reached",
"if",
"(",
"cmdFromMaster",
"==",
"null",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to receive master heartbeat command.\"",
",",
"e",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"error",
"(",
"\"Failed to receive or execute master heartbeat command: {}\"",
",",
"cmdFromMaster",
".",
"toString",
"(",
")",
",",
"e",
")",
";",
"}",
"mMasterClient",
".",
"disconnect",
"(",
")",
";",
"if",
"(",
"mHeartbeatTimeoutMs",
">",
"0",
")",
"{",
"if",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"-",
"mLastSuccessfulHeartbeatMs",
">=",
"mHeartbeatTimeoutMs",
")",
"{",
"if",
"(",
"ServerConfiguration",
".",
"getBoolean",
"(",
"PropertyKey",
".",
"TEST_MODE",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Master heartbeat timeout exceeded: \"",
"+",
"mHeartbeatTimeoutMs",
")",
";",
"}",
"// TODO(andrew): Propagate the exception to the main thread and exit there.",
"ProcessUtils",
".",
"fatalError",
"(",
"LOG",
",",
"\"Master heartbeat timeout exceeded: %d\"",
",",
"mHeartbeatTimeoutMs",
")",
";",
"}",
"}",
"}",
"}"
] |
Heartbeats to the master node about the change in the worker's managed space.
|
[
"Heartbeats",
"to",
"the",
"master",
"node",
"about",
"the",
"change",
"in",
"the",
"worker",
"s",
"managed",
"space",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/block/BlockMasterSync.java#L117-L155
|
19,051
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/raft/JournalStateMachine.java
|
JournalStateMachine.applyEntry
|
private void applyEntry(JournalEntry entry) {
Preconditions.checkState(
entry.getAllFields().size() <= 1
|| (entry.getAllFields().size() == 2 && entry.hasSequenceNumber()),
"Raft journal entries should never set multiple fields in addition to sequence "
+ "number, but found %s",
entry);
if (entry.getJournalEntriesCount() > 0) {
// This entry aggregates multiple entries.
for (JournalEntry e : entry.getJournalEntriesList()) {
applyEntry(e);
}
} else if (entry.getSequenceNumber() < 0) {
// Negative sequence numbers indicate special entries used to indicate that a new primary is
// starting to serve.
mLastPrimaryStartSequenceNumber = entry.getSequenceNumber();
} else if (entry.toBuilder().clearSequenceNumber().build()
.equals(JournalEntry.getDefaultInstance())) {
// Ignore empty entries, they are created during snapshotting.
} else {
applySingleEntry(entry);
}
}
|
java
|
private void applyEntry(JournalEntry entry) {
Preconditions.checkState(
entry.getAllFields().size() <= 1
|| (entry.getAllFields().size() == 2 && entry.hasSequenceNumber()),
"Raft journal entries should never set multiple fields in addition to sequence "
+ "number, but found %s",
entry);
if (entry.getJournalEntriesCount() > 0) {
// This entry aggregates multiple entries.
for (JournalEntry e : entry.getJournalEntriesList()) {
applyEntry(e);
}
} else if (entry.getSequenceNumber() < 0) {
// Negative sequence numbers indicate special entries used to indicate that a new primary is
// starting to serve.
mLastPrimaryStartSequenceNumber = entry.getSequenceNumber();
} else if (entry.toBuilder().clearSequenceNumber().build()
.equals(JournalEntry.getDefaultInstance())) {
// Ignore empty entries, they are created during snapshotting.
} else {
applySingleEntry(entry);
}
}
|
[
"private",
"void",
"applyEntry",
"(",
"JournalEntry",
"entry",
")",
"{",
"Preconditions",
".",
"checkState",
"(",
"entry",
".",
"getAllFields",
"(",
")",
".",
"size",
"(",
")",
"<=",
"1",
"||",
"(",
"entry",
".",
"getAllFields",
"(",
")",
".",
"size",
"(",
")",
"==",
"2",
"&&",
"entry",
".",
"hasSequenceNumber",
"(",
")",
")",
",",
"\"Raft journal entries should never set multiple fields in addition to sequence \"",
"+",
"\"number, but found %s\"",
",",
"entry",
")",
";",
"if",
"(",
"entry",
".",
"getJournalEntriesCount",
"(",
")",
">",
"0",
")",
"{",
"// This entry aggregates multiple entries.",
"for",
"(",
"JournalEntry",
"e",
":",
"entry",
".",
"getJournalEntriesList",
"(",
")",
")",
"{",
"applyEntry",
"(",
"e",
")",
";",
"}",
"}",
"else",
"if",
"(",
"entry",
".",
"getSequenceNumber",
"(",
")",
"<",
"0",
")",
"{",
"// Negative sequence numbers indicate special entries used to indicate that a new primary is",
"// starting to serve.",
"mLastPrimaryStartSequenceNumber",
"=",
"entry",
".",
"getSequenceNumber",
"(",
")",
";",
"}",
"else",
"if",
"(",
"entry",
".",
"toBuilder",
"(",
")",
".",
"clearSequenceNumber",
"(",
")",
".",
"build",
"(",
")",
".",
"equals",
"(",
"JournalEntry",
".",
"getDefaultInstance",
"(",
")",
")",
")",
"{",
"// Ignore empty entries, they are created during snapshotting.",
"}",
"else",
"{",
"applySingleEntry",
"(",
"entry",
")",
";",
"}",
"}"
] |
Applies the journal entry, ignoring empty entries and expanding multi-entries.
@param entry the entry to apply
|
[
"Applies",
"the",
"journal",
"entry",
"ignoring",
"empty",
"entries",
"and",
"expanding",
"multi",
"-",
"entries",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/raft/JournalStateMachine.java#L110-L132
|
19,052
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/underfs/UnderFileSystemFactoryRegistry.java
|
UnderFileSystemFactoryRegistry.findAll
|
public static List<UnderFileSystemFactory> findAll(String path,
UnderFileSystemConfiguration ufsConf, AlluxioConfiguration alluxioConf) {
List<UnderFileSystemFactory> eligibleFactories = sRegistryInstance.findAll(path, ufsConf,
alluxioConf);
if (eligibleFactories.isEmpty() && ufsConf != null) {
// Check if any versioned factory supports the default configuration
List<UnderFileSystemFactory> factories = sRegistryInstance.findAll(path, null, alluxioConf);
List<String> supportedVersions = new java.util.ArrayList<>();
for (UnderFileSystemFactory factory : factories) {
if (!factory.getVersion().isEmpty()) {
supportedVersions.add(factory.getVersion());
}
}
if (!supportedVersions.isEmpty()) {
String configuredVersion = ufsConf.get(PropertyKey.UNDERFS_VERSION);
LOG.warn("Versions [{}] are supported for path {} but you have configured version: {}",
StringUtils.join(supportedVersions, ","), path,
configuredVersion);
}
}
return eligibleFactories;
}
|
java
|
public static List<UnderFileSystemFactory> findAll(String path,
UnderFileSystemConfiguration ufsConf, AlluxioConfiguration alluxioConf) {
List<UnderFileSystemFactory> eligibleFactories = sRegistryInstance.findAll(path, ufsConf,
alluxioConf);
if (eligibleFactories.isEmpty() && ufsConf != null) {
// Check if any versioned factory supports the default configuration
List<UnderFileSystemFactory> factories = sRegistryInstance.findAll(path, null, alluxioConf);
List<String> supportedVersions = new java.util.ArrayList<>();
for (UnderFileSystemFactory factory : factories) {
if (!factory.getVersion().isEmpty()) {
supportedVersions.add(factory.getVersion());
}
}
if (!supportedVersions.isEmpty()) {
String configuredVersion = ufsConf.get(PropertyKey.UNDERFS_VERSION);
LOG.warn("Versions [{}] are supported for path {} but you have configured version: {}",
StringUtils.join(supportedVersions, ","), path,
configuredVersion);
}
}
return eligibleFactories;
}
|
[
"public",
"static",
"List",
"<",
"UnderFileSystemFactory",
">",
"findAll",
"(",
"String",
"path",
",",
"UnderFileSystemConfiguration",
"ufsConf",
",",
"AlluxioConfiguration",
"alluxioConf",
")",
"{",
"List",
"<",
"UnderFileSystemFactory",
">",
"eligibleFactories",
"=",
"sRegistryInstance",
".",
"findAll",
"(",
"path",
",",
"ufsConf",
",",
"alluxioConf",
")",
";",
"if",
"(",
"eligibleFactories",
".",
"isEmpty",
"(",
")",
"&&",
"ufsConf",
"!=",
"null",
")",
"{",
"// Check if any versioned factory supports the default configuration",
"List",
"<",
"UnderFileSystemFactory",
">",
"factories",
"=",
"sRegistryInstance",
".",
"findAll",
"(",
"path",
",",
"null",
",",
"alluxioConf",
")",
";",
"List",
"<",
"String",
">",
"supportedVersions",
"=",
"new",
"java",
".",
"util",
".",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"UnderFileSystemFactory",
"factory",
":",
"factories",
")",
"{",
"if",
"(",
"!",
"factory",
".",
"getVersion",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"supportedVersions",
".",
"add",
"(",
"factory",
".",
"getVersion",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"supportedVersions",
".",
"isEmpty",
"(",
")",
")",
"{",
"String",
"configuredVersion",
"=",
"ufsConf",
".",
"get",
"(",
"PropertyKey",
".",
"UNDERFS_VERSION",
")",
";",
"LOG",
".",
"warn",
"(",
"\"Versions [{}] are supported for path {} but you have configured version: {}\"",
",",
"StringUtils",
".",
"join",
"(",
"supportedVersions",
",",
"\",\"",
")",
",",
"path",
",",
"configuredVersion",
")",
";",
"}",
"}",
"return",
"eligibleFactories",
";",
"}"
] |
Finds all the Under File System factories that support the given path.
@param path path
@param ufsConf configuration of the UFS
@param alluxioConf Alluxio configuration
@return list of factories that support the given path which may be an empty list
|
[
"Finds",
"all",
"the",
"Under",
"File",
"System",
"factories",
"that",
"support",
"the",
"given",
"path",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/underfs/UnderFileSystemFactoryRegistry.java#L110-L131
|
19,053
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/command/DistributedLoadCommand.java
|
DistributedLoadCommand.load
|
private void load(AlluxioURI filePath, int replication)
throws AlluxioException, IOException, InterruptedException {
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, replication);
}
} else {
Thread thread = JobGrpcClientUtils.createProgressThread(System.out);
thread.start();
try {
JobGrpcClientUtils.run(new LoadConfig(filePath.getPath(), replication), 3,
mFsContext.getPathConf(filePath));
} finally {
thread.interrupt();
}
}
System.out.println(filePath + " loaded");
}
|
java
|
private void load(AlluxioURI filePath, int replication)
throws AlluxioException, IOException, InterruptedException {
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, replication);
}
} else {
Thread thread = JobGrpcClientUtils.createProgressThread(System.out);
thread.start();
try {
JobGrpcClientUtils.run(new LoadConfig(filePath.getPath(), replication), 3,
mFsContext.getPathConf(filePath));
} finally {
thread.interrupt();
}
}
System.out.println(filePath + " loaded");
}
|
[
"private",
"void",
"load",
"(",
"AlluxioURI",
"filePath",
",",
"int",
"replication",
")",
"throws",
"AlluxioException",
",",
"IOException",
",",
"InterruptedException",
"{",
"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",
",",
"replication",
")",
";",
"}",
"}",
"else",
"{",
"Thread",
"thread",
"=",
"JobGrpcClientUtils",
".",
"createProgressThread",
"(",
"System",
".",
"out",
")",
";",
"thread",
".",
"start",
"(",
")",
";",
"try",
"{",
"JobGrpcClientUtils",
".",
"run",
"(",
"new",
"LoadConfig",
"(",
"filePath",
".",
"getPath",
"(",
")",
",",
"replication",
")",
",",
"3",
",",
"mFsContext",
".",
"getPathConf",
"(",
"filePath",
")",
")",
";",
"}",
"finally",
"{",
"thread",
".",
"interrupt",
"(",
")",
";",
"}",
"}",
"System",
".",
"out",
".",
"println",
"(",
"filePath",
"+",
"\" loaded\"",
")",
";",
"}"
] |
Loads a file or directory in Alluxio space, makes it resident in memory.
@param filePath The {@link AlluxioURI} path to load into Alluxio memory
@throws AlluxioException when Alluxio exception occurs
@throws IOException when non-Alluxio exception occurs
|
[
"Loads",
"a",
"file",
"or",
"directory",
"in",
"Alluxio",
"space",
"makes",
"it",
"resident",
"in",
"memory",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/command/DistributedLoadCommand.java#L92-L112
|
19,054
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/underfs/AbstractUfsManager.java
|
AbstractUfsManager.getOrAdd
|
private UnderFileSystem getOrAdd(AlluxioURI ufsUri, UnderFileSystemConfiguration ufsConf) {
Key key = new Key(ufsUri, ufsConf.getMountSpecificConf());
UnderFileSystem cachedFs = mUnderFileSystemMap.get(key);
if (cachedFs != null) {
return cachedFs;
}
// On cache miss, synchronize the creation to ensure ufs is only created once
synchronized (mLock) {
cachedFs = mUnderFileSystemMap.get(key);
if (cachedFs != null) {
return cachedFs;
}
UnderFileSystem fs = UnderFileSystem.Factory.create(ufsUri.toString(), ufsConf);
// Detect whether to use managed blocking on UFS operations.
boolean useManagedBlocking = fs.isObjectStorage();
if (ufsConf.isSet(PropertyKey.UNDERFS_RUN_WITH_MANAGEDBLOCKING)) {
useManagedBlocking = ufsConf.getBoolean(PropertyKey.UNDERFS_RUN_WITH_MANAGEDBLOCKING);
}
// Wrap UFS under managed blocking forwarder if required.
if (useManagedBlocking) {
fs = new ManagedBlockingUfsForwarder(fs);
}
mUnderFileSystemMap.putIfAbsent(key, fs);
mCloser.register(fs);
try {
connectUfs(fs);
} catch (IOException e) {
LOG.warn("Failed to perform initial connect to UFS {}: {}", ufsUri, e.getMessage());
}
return fs;
}
}
|
java
|
private UnderFileSystem getOrAdd(AlluxioURI ufsUri, UnderFileSystemConfiguration ufsConf) {
Key key = new Key(ufsUri, ufsConf.getMountSpecificConf());
UnderFileSystem cachedFs = mUnderFileSystemMap.get(key);
if (cachedFs != null) {
return cachedFs;
}
// On cache miss, synchronize the creation to ensure ufs is only created once
synchronized (mLock) {
cachedFs = mUnderFileSystemMap.get(key);
if (cachedFs != null) {
return cachedFs;
}
UnderFileSystem fs = UnderFileSystem.Factory.create(ufsUri.toString(), ufsConf);
// Detect whether to use managed blocking on UFS operations.
boolean useManagedBlocking = fs.isObjectStorage();
if (ufsConf.isSet(PropertyKey.UNDERFS_RUN_WITH_MANAGEDBLOCKING)) {
useManagedBlocking = ufsConf.getBoolean(PropertyKey.UNDERFS_RUN_WITH_MANAGEDBLOCKING);
}
// Wrap UFS under managed blocking forwarder if required.
if (useManagedBlocking) {
fs = new ManagedBlockingUfsForwarder(fs);
}
mUnderFileSystemMap.putIfAbsent(key, fs);
mCloser.register(fs);
try {
connectUfs(fs);
} catch (IOException e) {
LOG.warn("Failed to perform initial connect to UFS {}: {}", ufsUri, e.getMessage());
}
return fs;
}
}
|
[
"private",
"UnderFileSystem",
"getOrAdd",
"(",
"AlluxioURI",
"ufsUri",
",",
"UnderFileSystemConfiguration",
"ufsConf",
")",
"{",
"Key",
"key",
"=",
"new",
"Key",
"(",
"ufsUri",
",",
"ufsConf",
".",
"getMountSpecificConf",
"(",
")",
")",
";",
"UnderFileSystem",
"cachedFs",
"=",
"mUnderFileSystemMap",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"cachedFs",
"!=",
"null",
")",
"{",
"return",
"cachedFs",
";",
"}",
"// On cache miss, synchronize the creation to ensure ufs is only created once",
"synchronized",
"(",
"mLock",
")",
"{",
"cachedFs",
"=",
"mUnderFileSystemMap",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"cachedFs",
"!=",
"null",
")",
"{",
"return",
"cachedFs",
";",
"}",
"UnderFileSystem",
"fs",
"=",
"UnderFileSystem",
".",
"Factory",
".",
"create",
"(",
"ufsUri",
".",
"toString",
"(",
")",
",",
"ufsConf",
")",
";",
"// Detect whether to use managed blocking on UFS operations.",
"boolean",
"useManagedBlocking",
"=",
"fs",
".",
"isObjectStorage",
"(",
")",
";",
"if",
"(",
"ufsConf",
".",
"isSet",
"(",
"PropertyKey",
".",
"UNDERFS_RUN_WITH_MANAGEDBLOCKING",
")",
")",
"{",
"useManagedBlocking",
"=",
"ufsConf",
".",
"getBoolean",
"(",
"PropertyKey",
".",
"UNDERFS_RUN_WITH_MANAGEDBLOCKING",
")",
";",
"}",
"// Wrap UFS under managed blocking forwarder if required.",
"if",
"(",
"useManagedBlocking",
")",
"{",
"fs",
"=",
"new",
"ManagedBlockingUfsForwarder",
"(",
"fs",
")",
";",
"}",
"mUnderFileSystemMap",
".",
"putIfAbsent",
"(",
"key",
",",
"fs",
")",
";",
"mCloser",
".",
"register",
"(",
"fs",
")",
";",
"try",
"{",
"connectUfs",
"(",
"fs",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Failed to perform initial connect to UFS {}: {}\"",
",",
"ufsUri",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"fs",
";",
"}",
"}"
] |
Return a UFS instance if it already exists in the cache, otherwise, creates a new instance and
return this.
@param ufsUri the UFS path
@param ufsConf the UFS configuration
@return the UFS instance
|
[
"Return",
"a",
"UFS",
"instance",
"if",
"it",
"already",
"exists",
"in",
"the",
"cache",
"otherwise",
"creates",
"a",
"new",
"instance",
"and",
"return",
"this",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/underfs/AbstractUfsManager.java#L116-L149
|
19,055
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java
|
FileSystemShellUtils.getAlluxioURIs
|
private static List<AlluxioURI> getAlluxioURIs(FileSystem alluxioClient, AlluxioURI inputURI,
AlluxioURI parentDir) throws IOException {
List<AlluxioURI> res = new ArrayList<>();
List<URIStatus> statuses;
try {
statuses = alluxioClient.listStatus(parentDir);
} catch (AlluxioException e) {
throw new IOException(e);
}
for (URIStatus status : statuses) {
AlluxioURI fileURI =
new AlluxioURI(inputURI.getScheme(), inputURI.getAuthority(), status.getPath());
if (match(fileURI, inputURI)) { // if it matches
res.add(fileURI);
} else {
if (status.isFolder()) { // if it is a folder, we do it recursively
AlluxioURI dirURI =
new AlluxioURI(inputURI.getScheme(), inputURI.getAuthority(), status.getPath());
String prefix = inputURI.getLeadingPath(dirURI.getDepth());
if (prefix != null && match(dirURI, new AlluxioURI(prefix))) {
res.addAll(getAlluxioURIs(alluxioClient, inputURI, dirURI));
}
}
}
}
return res;
}
|
java
|
private static List<AlluxioURI> getAlluxioURIs(FileSystem alluxioClient, AlluxioURI inputURI,
AlluxioURI parentDir) throws IOException {
List<AlluxioURI> res = new ArrayList<>();
List<URIStatus> statuses;
try {
statuses = alluxioClient.listStatus(parentDir);
} catch (AlluxioException e) {
throw new IOException(e);
}
for (URIStatus status : statuses) {
AlluxioURI fileURI =
new AlluxioURI(inputURI.getScheme(), inputURI.getAuthority(), status.getPath());
if (match(fileURI, inputURI)) { // if it matches
res.add(fileURI);
} else {
if (status.isFolder()) { // if it is a folder, we do it recursively
AlluxioURI dirURI =
new AlluxioURI(inputURI.getScheme(), inputURI.getAuthority(), status.getPath());
String prefix = inputURI.getLeadingPath(dirURI.getDepth());
if (prefix != null && match(dirURI, new AlluxioURI(prefix))) {
res.addAll(getAlluxioURIs(alluxioClient, inputURI, dirURI));
}
}
}
}
return res;
}
|
[
"private",
"static",
"List",
"<",
"AlluxioURI",
">",
"getAlluxioURIs",
"(",
"FileSystem",
"alluxioClient",
",",
"AlluxioURI",
"inputURI",
",",
"AlluxioURI",
"parentDir",
")",
"throws",
"IOException",
"{",
"List",
"<",
"AlluxioURI",
">",
"res",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"URIStatus",
">",
"statuses",
";",
"try",
"{",
"statuses",
"=",
"alluxioClient",
".",
"listStatus",
"(",
"parentDir",
")",
";",
"}",
"catch",
"(",
"AlluxioException",
"e",
")",
"{",
"throw",
"new",
"IOException",
"(",
"e",
")",
";",
"}",
"for",
"(",
"URIStatus",
"status",
":",
"statuses",
")",
"{",
"AlluxioURI",
"fileURI",
"=",
"new",
"AlluxioURI",
"(",
"inputURI",
".",
"getScheme",
"(",
")",
",",
"inputURI",
".",
"getAuthority",
"(",
")",
",",
"status",
".",
"getPath",
"(",
")",
")",
";",
"if",
"(",
"match",
"(",
"fileURI",
",",
"inputURI",
")",
")",
"{",
"// if it matches",
"res",
".",
"add",
"(",
"fileURI",
")",
";",
"}",
"else",
"{",
"if",
"(",
"status",
".",
"isFolder",
"(",
")",
")",
"{",
"// if it is a folder, we do it recursively",
"AlluxioURI",
"dirURI",
"=",
"new",
"AlluxioURI",
"(",
"inputURI",
".",
"getScheme",
"(",
")",
",",
"inputURI",
".",
"getAuthority",
"(",
")",
",",
"status",
".",
"getPath",
"(",
")",
")",
";",
"String",
"prefix",
"=",
"inputURI",
".",
"getLeadingPath",
"(",
"dirURI",
".",
"getDepth",
"(",
")",
")",
";",
"if",
"(",
"prefix",
"!=",
"null",
"&&",
"match",
"(",
"dirURI",
",",
"new",
"AlluxioURI",
"(",
"prefix",
")",
")",
")",
"{",
"res",
".",
"addAll",
"(",
"getAlluxioURIs",
"(",
"alluxioClient",
",",
"inputURI",
",",
"dirURI",
")",
")",
";",
"}",
"}",
"}",
"}",
"return",
"res",
";",
"}"
] |
The utility function used to implement getAlluxioURIs.
Basically, it recursively iterates through the directory from the parent directory of inputURI
(e.g., for input "/a/b/*", it will start from "/a/b") until it finds all the matches;
It does not go into a directory if the prefix mismatches
(e.g., for input "/a/b/*", it won't go inside directory "/a/c")
@param alluxioClient the client used to fetch metadata of Alluxio files
@param inputURI the input URI (could contain wildcards)
@param parentDir the {@link AlluxioURI} of the directory in which we are searching matched
files
@return a list of {@link AlluxioURI}s of the files that match the inputURI in parentDir
|
[
"The",
"utility",
"function",
"used",
"to",
"implement",
"getAlluxioURIs",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java#L135-L161
|
19,056
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java
|
FileSystemShellUtils.getFiles
|
private static List<File> getFiles(String inputPath, String parent) {
List<File> res = new ArrayList<>();
File pFile = new File(parent);
if (!pFile.exists() || !pFile.isDirectory()) {
return res;
}
if (pFile.isDirectory() && pFile.canRead()) {
File[] fileList = pFile.listFiles();
if (fileList == null) {
return res;
}
for (File file : fileList) {
if (match(file.getPath(), inputPath)) { // if it matches
res.add(file);
} else {
if (file.isDirectory()) { // if it is a folder, we do it recursively
AlluxioURI dirURI = new AlluxioURI(file.getPath());
String prefix = new AlluxioURI(inputPath).getLeadingPath(dirURI.getDepth());
if (prefix != null && match(dirURI, new AlluxioURI(prefix))) {
res.addAll(getFiles(inputPath, dirURI.getPath()));
}
}
}
}
}
return res;
}
|
java
|
private static List<File> getFiles(String inputPath, String parent) {
List<File> res = new ArrayList<>();
File pFile = new File(parent);
if (!pFile.exists() || !pFile.isDirectory()) {
return res;
}
if (pFile.isDirectory() && pFile.canRead()) {
File[] fileList = pFile.listFiles();
if (fileList == null) {
return res;
}
for (File file : fileList) {
if (match(file.getPath(), inputPath)) { // if it matches
res.add(file);
} else {
if (file.isDirectory()) { // if it is a folder, we do it recursively
AlluxioURI dirURI = new AlluxioURI(file.getPath());
String prefix = new AlluxioURI(inputPath).getLeadingPath(dirURI.getDepth());
if (prefix != null && match(dirURI, new AlluxioURI(prefix))) {
res.addAll(getFiles(inputPath, dirURI.getPath()));
}
}
}
}
}
return res;
}
|
[
"private",
"static",
"List",
"<",
"File",
">",
"getFiles",
"(",
"String",
"inputPath",
",",
"String",
"parent",
")",
"{",
"List",
"<",
"File",
">",
"res",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"File",
"pFile",
"=",
"new",
"File",
"(",
"parent",
")",
";",
"if",
"(",
"!",
"pFile",
".",
"exists",
"(",
")",
"||",
"!",
"pFile",
".",
"isDirectory",
"(",
")",
")",
"{",
"return",
"res",
";",
"}",
"if",
"(",
"pFile",
".",
"isDirectory",
"(",
")",
"&&",
"pFile",
".",
"canRead",
"(",
")",
")",
"{",
"File",
"[",
"]",
"fileList",
"=",
"pFile",
".",
"listFiles",
"(",
")",
";",
"if",
"(",
"fileList",
"==",
"null",
")",
"{",
"return",
"res",
";",
"}",
"for",
"(",
"File",
"file",
":",
"fileList",
")",
"{",
"if",
"(",
"match",
"(",
"file",
".",
"getPath",
"(",
")",
",",
"inputPath",
")",
")",
"{",
"// if it matches",
"res",
".",
"add",
"(",
"file",
")",
";",
"}",
"else",
"{",
"if",
"(",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"// if it is a folder, we do it recursively",
"AlluxioURI",
"dirURI",
"=",
"new",
"AlluxioURI",
"(",
"file",
".",
"getPath",
"(",
")",
")",
";",
"String",
"prefix",
"=",
"new",
"AlluxioURI",
"(",
"inputPath",
")",
".",
"getLeadingPath",
"(",
"dirURI",
".",
"getDepth",
"(",
")",
")",
";",
"if",
"(",
"prefix",
"!=",
"null",
"&&",
"match",
"(",
"dirURI",
",",
"new",
"AlluxioURI",
"(",
"prefix",
")",
")",
")",
"{",
"res",
".",
"addAll",
"(",
"getFiles",
"(",
"inputPath",
",",
"dirURI",
".",
"getPath",
"(",
")",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"res",
";",
"}"
] |
The utility function used to implement getFiles.
It follows the same algorithm as {@link #getAlluxioURIs}.
@param inputPath the input file path (could contain wildcards)
@param parent the directory in which we are searching matched files
@return a list of files that matches the input path in the parent directory
|
[
"The",
"utility",
"function",
"used",
"to",
"implement",
"getFiles",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java#L195-L221
|
19,057
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java
|
FileSystemShellUtils.getIntArg
|
public static int getIntArg(CommandLine cl, Option option, int defaultValue) {
int arg = defaultValue;
if (cl.hasOption(option.getLongOpt())) {
String argOption = cl.getOptionValue(option.getLongOpt());
arg = Integer.parseInt(argOption);
}
return arg;
}
|
java
|
public static int getIntArg(CommandLine cl, Option option, int defaultValue) {
int arg = defaultValue;
if (cl.hasOption(option.getLongOpt())) {
String argOption = cl.getOptionValue(option.getLongOpt());
arg = Integer.parseInt(argOption);
}
return arg;
}
|
[
"public",
"static",
"int",
"getIntArg",
"(",
"CommandLine",
"cl",
",",
"Option",
"option",
",",
"int",
"defaultValue",
")",
"{",
"int",
"arg",
"=",
"defaultValue",
";",
"if",
"(",
"cl",
".",
"hasOption",
"(",
"option",
".",
"getLongOpt",
"(",
")",
")",
")",
"{",
"String",
"argOption",
"=",
"cl",
".",
"getOptionValue",
"(",
"option",
".",
"getLongOpt",
"(",
")",
")",
";",
"arg",
"=",
"Integer",
".",
"parseInt",
"(",
"argOption",
")",
";",
"}",
"return",
"arg",
";",
"}"
] |
Gets the value of an option from the command line.
@param cl command line object
@param option the option to check for in the command line
@param defaultValue default value for the option
@return argument from command line or default if not present
|
[
"Gets",
"the",
"value",
"of",
"an",
"option",
"from",
"the",
"command",
"line",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java#L231-L238
|
19,058
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java
|
FileSystemShellUtils.getMs
|
public static long getMs(String time) {
try {
return FormatUtils.parseTimeSize(time);
} catch (Exception e) {
throw new RuntimeException(ExceptionMessage.INVALID_TIME.getMessage(time));
}
}
|
java
|
public static long getMs(String time) {
try {
return FormatUtils.parseTimeSize(time);
} catch (Exception e) {
throw new RuntimeException(ExceptionMessage.INVALID_TIME.getMessage(time));
}
}
|
[
"public",
"static",
"long",
"getMs",
"(",
"String",
"time",
")",
"{",
"try",
"{",
"return",
"FormatUtils",
".",
"parseTimeSize",
"(",
"time",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"ExceptionMessage",
".",
"INVALID_TIME",
".",
"getMessage",
"(",
"time",
")",
")",
";",
"}",
"}"
] |
Converts the input time into millisecond unit.
@param time the time to be converted into milliseconds
@return the time in millisecond unit
|
[
"Converts",
"the",
"input",
"time",
"into",
"millisecond",
"unit",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java#L258-L264
|
19,059
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java
|
FileSystemShellUtils.match
|
private static boolean match(AlluxioURI fileURI, AlluxioURI patternURI) {
return escape(fileURI.getPath()).matches(replaceWildcards(patternURI.getPath()));
}
|
java
|
private static boolean match(AlluxioURI fileURI, AlluxioURI patternURI) {
return escape(fileURI.getPath()).matches(replaceWildcards(patternURI.getPath()));
}
|
[
"private",
"static",
"boolean",
"match",
"(",
"AlluxioURI",
"fileURI",
",",
"AlluxioURI",
"patternURI",
")",
"{",
"return",
"escape",
"(",
"fileURI",
".",
"getPath",
"(",
")",
")",
".",
"matches",
"(",
"replaceWildcards",
"(",
"patternURI",
".",
"getPath",
"(",
")",
")",
")",
";",
"}"
] |
Returns whether or not fileURI matches the patternURI.
@param fileURI the {@link AlluxioURI} of a particular file
@param patternURI the URI that can contain wildcards
@return true if matches; false if not
|
[
"Returns",
"whether",
"or",
"not",
"fileURI",
"matches",
"the",
"patternURI",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java#L295-L297
|
19,060
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java
|
FileSystemShellUtils.match
|
public static boolean match(String filePath, String patternPath) {
return match(new AlluxioURI(filePath), new AlluxioURI(patternPath));
}
|
java
|
public static boolean match(String filePath, String patternPath) {
return match(new AlluxioURI(filePath), new AlluxioURI(patternPath));
}
|
[
"public",
"static",
"boolean",
"match",
"(",
"String",
"filePath",
",",
"String",
"patternPath",
")",
"{",
"return",
"match",
"(",
"new",
"AlluxioURI",
"(",
"filePath",
")",
",",
"new",
"AlluxioURI",
"(",
"patternPath",
")",
")",
";",
"}"
] |
Returns whether or not filePath matches patternPath.
@param filePath path of a given file
@param patternPath path that can contain wildcards
@return true if matches; false if not
|
[
"Returns",
"whether",
"or",
"not",
"filePath",
"matches",
"patternPath",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fs/FileSystemShellUtils.java#L306-L308
|
19,061
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/underfs/MasterUfsManager.java
|
MasterUfsManager.setUfsMode
|
public synchronized void setUfsMode(Supplier<JournalContext> journalContext, AlluxioURI ufsPath,
UfsMode ufsMode) throws InvalidPathException {
LOG.info("Set ufs mode for {} to {}", ufsPath, ufsMode);
String root = ufsPath.getRootPath();
if (!mUfsRoots.contains(root)) {
LOG.warn("No managed ufs for physical ufs path {}", root);
throw new InvalidPathException(String.format("Unknown Ufs path %s", root));
}
mState.applyAndJournal(journalContext, UpdateUfsModeEntry.newBuilder()
.setUfsPath(ufsPath.getRootPath())
.setUfsMode(File.UfsMode.valueOf(ufsMode.name()))
.build());
}
|
java
|
public synchronized void setUfsMode(Supplier<JournalContext> journalContext, AlluxioURI ufsPath,
UfsMode ufsMode) throws InvalidPathException {
LOG.info("Set ufs mode for {} to {}", ufsPath, ufsMode);
String root = ufsPath.getRootPath();
if (!mUfsRoots.contains(root)) {
LOG.warn("No managed ufs for physical ufs path {}", root);
throw new InvalidPathException(String.format("Unknown Ufs path %s", root));
}
mState.applyAndJournal(journalContext, UpdateUfsModeEntry.newBuilder()
.setUfsPath(ufsPath.getRootPath())
.setUfsMode(File.UfsMode.valueOf(ufsMode.name()))
.build());
}
|
[
"public",
"synchronized",
"void",
"setUfsMode",
"(",
"Supplier",
"<",
"JournalContext",
">",
"journalContext",
",",
"AlluxioURI",
"ufsPath",
",",
"UfsMode",
"ufsMode",
")",
"throws",
"InvalidPathException",
"{",
"LOG",
".",
"info",
"(",
"\"Set ufs mode for {} to {}\"",
",",
"ufsPath",
",",
"ufsMode",
")",
";",
"String",
"root",
"=",
"ufsPath",
".",
"getRootPath",
"(",
")",
";",
"if",
"(",
"!",
"mUfsRoots",
".",
"contains",
"(",
"root",
")",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"No managed ufs for physical ufs path {}\"",
",",
"root",
")",
";",
"throw",
"new",
"InvalidPathException",
"(",
"String",
".",
"format",
"(",
"\"Unknown Ufs path %s\"",
",",
"root",
")",
")",
";",
"}",
"mState",
".",
"applyAndJournal",
"(",
"journalContext",
",",
"UpdateUfsModeEntry",
".",
"newBuilder",
"(",
")",
".",
"setUfsPath",
"(",
"ufsPath",
".",
"getRootPath",
"(",
")",
")",
".",
"setUfsMode",
"(",
"File",
".",
"UfsMode",
".",
"valueOf",
"(",
"ufsMode",
".",
"name",
"(",
")",
")",
")",
".",
"build",
"(",
")",
")",
";",
"}"
] |
Set the operation mode the given physical ufs.
@param journalContext the journal context
@param ufsPath the physical ufs path (scheme and authority only)
@param ufsMode the ufs operation mode
@throws InvalidPathException if no managed ufs covers the given path
|
[
"Set",
"the",
"operation",
"mode",
"the",
"given",
"physical",
"ufs",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/underfs/MasterUfsManager.java#L110-L124
|
19,062
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CountedCompleter.java
|
CountedCompleter.getRoot
|
public final CountedCompleter<?> getRoot() {
CountedCompleter<?> a = this, p;
while ((p = a.completer) != null)
a = p;
return a;
}
|
java
|
public final CountedCompleter<?> getRoot() {
CountedCompleter<?> a = this, p;
while ((p = a.completer) != null)
a = p;
return a;
}
|
[
"public",
"final",
"CountedCompleter",
"<",
"?",
">",
"getRoot",
"(",
")",
"{",
"CountedCompleter",
"<",
"?",
">",
"a",
"=",
"this",
",",
"p",
";",
"while",
"(",
"(",
"p",
"=",
"a",
".",
"completer",
")",
"!=",
"null",
")",
"a",
"=",
"p",
";",
"return",
"a",
";",
"}"
] |
Returns the root of the current computation; i.e., this task if it has no completer, else its
completer's root.
@return the root of the current computation
|
[
"Returns",
"the",
"root",
"of",
"the",
"current",
"computation",
";",
"i",
".",
"e",
".",
"this",
"task",
"if",
"it",
"has",
"no",
"completer",
"else",
"its",
"completer",
"s",
"root",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CountedCompleter.java#L534-L539
|
19,063
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CountedCompleter.java
|
CountedCompleter.helpComplete
|
public final void helpComplete(int maxTasks) {
Thread t;
ForkJoinWorkerThread wt;
if (maxTasks > 0 && status >= 0) {
if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)
(wt = (ForkJoinWorkerThread) t).pool.helpComplete(wt.workQueue, this, maxTasks);
else
ForkJoinPool.common.externalHelpComplete(this, maxTasks);
}
}
|
java
|
public final void helpComplete(int maxTasks) {
Thread t;
ForkJoinWorkerThread wt;
if (maxTasks > 0 && status >= 0) {
if ((t = Thread.currentThread()) instanceof ForkJoinWorkerThread)
(wt = (ForkJoinWorkerThread) t).pool.helpComplete(wt.workQueue, this, maxTasks);
else
ForkJoinPool.common.externalHelpComplete(this, maxTasks);
}
}
|
[
"public",
"final",
"void",
"helpComplete",
"(",
"int",
"maxTasks",
")",
"{",
"Thread",
"t",
";",
"ForkJoinWorkerThread",
"wt",
";",
"if",
"(",
"maxTasks",
">",
"0",
"&&",
"status",
">=",
"0",
")",
"{",
"if",
"(",
"(",
"t",
"=",
"Thread",
".",
"currentThread",
"(",
")",
")",
"instanceof",
"ForkJoinWorkerThread",
")",
"(",
"wt",
"=",
"(",
"ForkJoinWorkerThread",
")",
"t",
")",
".",
"pool",
".",
"helpComplete",
"(",
"wt",
".",
"workQueue",
",",
"this",
",",
"maxTasks",
")",
";",
"else",
"ForkJoinPool",
".",
"common",
".",
"externalHelpComplete",
"(",
"this",
",",
"maxTasks",
")",
";",
"}",
"}"
] |
If this task has not completed, attempts to process at most the given number of other
unprocessed tasks for which this task is on the completion path, if any are known to exist.
@param maxTasks the maximum number of tasks to process. If less than or equal to zero, then no
tasks are processed.
|
[
"If",
"this",
"task",
"has",
"not",
"completed",
"attempts",
"to",
"process",
"at",
"most",
"the",
"given",
"number",
"of",
"other",
"unprocessed",
"tasks",
"for",
"which",
"this",
"task",
"is",
"on",
"the",
"completion",
"path",
"if",
"any",
"are",
"known",
"to",
"exist",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CountedCompleter.java#L669-L678
|
19,064
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/concurrent/jsr/CountedCompleter.java
|
CountedCompleter.internalPropagateException
|
void internalPropagateException(Throwable ex) {
CountedCompleter<?> a = this, s = a;
while (a.onExceptionalCompletion(ex, s) && (a = (s = a).completer) != null && a.status >= 0
&& a.recordExceptionalCompletion(ex) == EXCEPTIONAL);
}
|
java
|
void internalPropagateException(Throwable ex) {
CountedCompleter<?> a = this, s = a;
while (a.onExceptionalCompletion(ex, s) && (a = (s = a).completer) != null && a.status >= 0
&& a.recordExceptionalCompletion(ex) == EXCEPTIONAL);
}
|
[
"void",
"internalPropagateException",
"(",
"Throwable",
"ex",
")",
"{",
"CountedCompleter",
"<",
"?",
">",
"a",
"=",
"this",
",",
"s",
"=",
"a",
";",
"while",
"(",
"a",
".",
"onExceptionalCompletion",
"(",
"ex",
",",
"s",
")",
"&&",
"(",
"a",
"=",
"(",
"s",
"=",
"a",
")",
".",
"completer",
")",
"!=",
"null",
"&&",
"a",
".",
"status",
">=",
"0",
"&&",
"a",
".",
"recordExceptionalCompletion",
"(",
"ex",
")",
"==",
"EXCEPTIONAL",
")",
";",
"}"
] |
Supports ForkJoinTask exception propagation.
|
[
"Supports",
"ForkJoinTask",
"exception",
"propagation",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/concurrent/jsr/CountedCompleter.java#L683-L687
|
19,065
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/proto/ProtoUtils.java
|
ProtoUtils.toProto
|
public static PStatus toProto(Status status) {
switch (status.getCode()) {
case ABORTED:
return PStatus.ABORTED;
case ALREADY_EXISTS:
return PStatus.ALREADY_EXISTS;
case CANCELLED:
return PStatus.CANCELED;
case DATA_LOSS:
return PStatus.DATA_LOSS;
case DEADLINE_EXCEEDED:
return PStatus.DEADLINE_EXCEEDED;
case FAILED_PRECONDITION:
return PStatus.FAILED_PRECONDITION;
case INTERNAL:
return PStatus.INTERNAL;
case INVALID_ARGUMENT:
return PStatus.INVALID_ARGUMENT;
case NOT_FOUND:
return PStatus.NOT_FOUND;
case OK:
return PStatus.OK;
case OUT_OF_RANGE:
return PStatus.OUT_OF_RANGE;
case PERMISSION_DENIED:
return PStatus.PERMISSION_DENIED;
case RESOURCE_EXHAUSTED:
return PStatus.RESOURCE_EXHAUSTED;
case UNAUTHENTICATED:
return PStatus.UNAUTHENTICATED;
case UNAVAILABLE:
return PStatus.UNAVAILABLE;
case UNIMPLEMENTED:
return PStatus.UNIMPLEMENTED;
case UNKNOWN:
return PStatus.UNKNOWN;
default:
return PStatus.UNKNOWN;
}
}
|
java
|
public static PStatus toProto(Status status) {
switch (status.getCode()) {
case ABORTED:
return PStatus.ABORTED;
case ALREADY_EXISTS:
return PStatus.ALREADY_EXISTS;
case CANCELLED:
return PStatus.CANCELED;
case DATA_LOSS:
return PStatus.DATA_LOSS;
case DEADLINE_EXCEEDED:
return PStatus.DEADLINE_EXCEEDED;
case FAILED_PRECONDITION:
return PStatus.FAILED_PRECONDITION;
case INTERNAL:
return PStatus.INTERNAL;
case INVALID_ARGUMENT:
return PStatus.INVALID_ARGUMENT;
case NOT_FOUND:
return PStatus.NOT_FOUND;
case OK:
return PStatus.OK;
case OUT_OF_RANGE:
return PStatus.OUT_OF_RANGE;
case PERMISSION_DENIED:
return PStatus.PERMISSION_DENIED;
case RESOURCE_EXHAUSTED:
return PStatus.RESOURCE_EXHAUSTED;
case UNAUTHENTICATED:
return PStatus.UNAUTHENTICATED;
case UNAVAILABLE:
return PStatus.UNAVAILABLE;
case UNIMPLEMENTED:
return PStatus.UNIMPLEMENTED;
case UNKNOWN:
return PStatus.UNKNOWN;
default:
return PStatus.UNKNOWN;
}
}
|
[
"public",
"static",
"PStatus",
"toProto",
"(",
"Status",
"status",
")",
"{",
"switch",
"(",
"status",
".",
"getCode",
"(",
")",
")",
"{",
"case",
"ABORTED",
":",
"return",
"PStatus",
".",
"ABORTED",
";",
"case",
"ALREADY_EXISTS",
":",
"return",
"PStatus",
".",
"ALREADY_EXISTS",
";",
"case",
"CANCELLED",
":",
"return",
"PStatus",
".",
"CANCELED",
";",
"case",
"DATA_LOSS",
":",
"return",
"PStatus",
".",
"DATA_LOSS",
";",
"case",
"DEADLINE_EXCEEDED",
":",
"return",
"PStatus",
".",
"DEADLINE_EXCEEDED",
";",
"case",
"FAILED_PRECONDITION",
":",
"return",
"PStatus",
".",
"FAILED_PRECONDITION",
";",
"case",
"INTERNAL",
":",
"return",
"PStatus",
".",
"INTERNAL",
";",
"case",
"INVALID_ARGUMENT",
":",
"return",
"PStatus",
".",
"INVALID_ARGUMENT",
";",
"case",
"NOT_FOUND",
":",
"return",
"PStatus",
".",
"NOT_FOUND",
";",
"case",
"OK",
":",
"return",
"PStatus",
".",
"OK",
";",
"case",
"OUT_OF_RANGE",
":",
"return",
"PStatus",
".",
"OUT_OF_RANGE",
";",
"case",
"PERMISSION_DENIED",
":",
"return",
"PStatus",
".",
"PERMISSION_DENIED",
";",
"case",
"RESOURCE_EXHAUSTED",
":",
"return",
"PStatus",
".",
"RESOURCE_EXHAUSTED",
";",
"case",
"UNAUTHENTICATED",
":",
"return",
"PStatus",
".",
"UNAUTHENTICATED",
";",
"case",
"UNAVAILABLE",
":",
"return",
"PStatus",
".",
"UNAVAILABLE",
";",
"case",
"UNIMPLEMENTED",
":",
"return",
"PStatus",
".",
"UNIMPLEMENTED",
";",
"case",
"UNKNOWN",
":",
"return",
"PStatus",
".",
"UNKNOWN",
";",
"default",
":",
"return",
"PStatus",
".",
"UNKNOWN",
";",
"}",
"}"
] |
Converts an internal exception status to a protocol buffer type status.
@param status the status to convert
@return the protocol buffer type status
|
[
"Converts",
"an",
"internal",
"exception",
"status",
"to",
"a",
"protocol",
"buffer",
"type",
"status",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/proto/ProtoUtils.java#L228-L267
|
19,066
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/util/proto/ProtoUtils.java
|
ProtoUtils.fromProto
|
public static SetAclAction fromProto(File.PSetAclAction pSetAclAction) {
if (pSetAclAction == null) {
throw new IllegalStateException("Null proto set acl action.");
}
switch (pSetAclAction) {
case REPLACE:
return SetAclAction.REPLACE;
case MODIFY:
return SetAclAction.MODIFY;
case REMOVE:
return SetAclAction.REMOVE;
case REMOVE_ALL:
return SetAclAction.REMOVE_ALL;
case REMOVE_DEFAULT:
return SetAclAction.REMOVE_DEFAULT;
default:
throw new IllegalStateException("Unrecognized proto set acl action: " + pSetAclAction);
}
}
|
java
|
public static SetAclAction fromProto(File.PSetAclAction pSetAclAction) {
if (pSetAclAction == null) {
throw new IllegalStateException("Null proto set acl action.");
}
switch (pSetAclAction) {
case REPLACE:
return SetAclAction.REPLACE;
case MODIFY:
return SetAclAction.MODIFY;
case REMOVE:
return SetAclAction.REMOVE;
case REMOVE_ALL:
return SetAclAction.REMOVE_ALL;
case REMOVE_DEFAULT:
return SetAclAction.REMOVE_DEFAULT;
default:
throw new IllegalStateException("Unrecognized proto set acl action: " + pSetAclAction);
}
}
|
[
"public",
"static",
"SetAclAction",
"fromProto",
"(",
"File",
".",
"PSetAclAction",
"pSetAclAction",
")",
"{",
"if",
"(",
"pSetAclAction",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Null proto set acl action.\"",
")",
";",
"}",
"switch",
"(",
"pSetAclAction",
")",
"{",
"case",
"REPLACE",
":",
"return",
"SetAclAction",
".",
"REPLACE",
";",
"case",
"MODIFY",
":",
"return",
"SetAclAction",
".",
"MODIFY",
";",
"case",
"REMOVE",
":",
"return",
"SetAclAction",
".",
"REMOVE",
";",
"case",
"REMOVE_ALL",
":",
"return",
"SetAclAction",
".",
"REMOVE_ALL",
";",
"case",
"REMOVE_DEFAULT",
":",
"return",
"SetAclAction",
".",
"REMOVE_DEFAULT",
";",
"default",
":",
"throw",
"new",
"IllegalStateException",
"(",
"\"Unrecognized proto set acl action: \"",
"+",
"pSetAclAction",
")",
";",
"}",
"}"
] |
Converts proto type to wire type.
@param pSetAclAction {@link File.PSetAclAction}
@return {@link SetAclAction} equivalent
|
[
"Converts",
"proto",
"type",
"to",
"wire",
"type",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/util/proto/ProtoUtils.java#L433-L451
|
19,067
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/doctor/ConfigurationCommand.java
|
ConfigurationCommand.run
|
public int run() throws IOException {
ConfigCheckReport report = mMetaMasterClient.getConfigReport();
ConfigStatus configStatus = report.getConfigStatus();
if (configStatus == ConfigStatus.PASSED) {
// No errors or warnings to show
mPrintStream.println("No server-side configuration errors or warnings.");
return 0;
}
Map<Scope, List<InconsistentProperty>> errors = report.getConfigErrors();
if (errors.size() != 0) {
mPrintStream.println("Server-side configuration errors "
+ "(those properties are required to be identical): ");
printInconsistentProperties(errors);
}
Map<Scope, List<InconsistentProperty>> warnings = report.getConfigWarns();
if (warnings.size() != 0) {
mPrintStream.println("\nServer-side configuration warnings "
+ "(those properties are recommended to be identical): ");
printInconsistentProperties(warnings);
}
return 0;
}
|
java
|
public int run() throws IOException {
ConfigCheckReport report = mMetaMasterClient.getConfigReport();
ConfigStatus configStatus = report.getConfigStatus();
if (configStatus == ConfigStatus.PASSED) {
// No errors or warnings to show
mPrintStream.println("No server-side configuration errors or warnings.");
return 0;
}
Map<Scope, List<InconsistentProperty>> errors = report.getConfigErrors();
if (errors.size() != 0) {
mPrintStream.println("Server-side configuration errors "
+ "(those properties are required to be identical): ");
printInconsistentProperties(errors);
}
Map<Scope, List<InconsistentProperty>> warnings = report.getConfigWarns();
if (warnings.size() != 0) {
mPrintStream.println("\nServer-side configuration warnings "
+ "(those properties are recommended to be identical): ");
printInconsistentProperties(warnings);
}
return 0;
}
|
[
"public",
"int",
"run",
"(",
")",
"throws",
"IOException",
"{",
"ConfigCheckReport",
"report",
"=",
"mMetaMasterClient",
".",
"getConfigReport",
"(",
")",
";",
"ConfigStatus",
"configStatus",
"=",
"report",
".",
"getConfigStatus",
"(",
")",
";",
"if",
"(",
"configStatus",
"==",
"ConfigStatus",
".",
"PASSED",
")",
"{",
"// No errors or warnings to show",
"mPrintStream",
".",
"println",
"(",
"\"No server-side configuration errors or warnings.\"",
")",
";",
"return",
"0",
";",
"}",
"Map",
"<",
"Scope",
",",
"List",
"<",
"InconsistentProperty",
">",
">",
"errors",
"=",
"report",
".",
"getConfigErrors",
"(",
")",
";",
"if",
"(",
"errors",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"mPrintStream",
".",
"println",
"(",
"\"Server-side configuration errors \"",
"+",
"\"(those properties are required to be identical): \"",
")",
";",
"printInconsistentProperties",
"(",
"errors",
")",
";",
"}",
"Map",
"<",
"Scope",
",",
"List",
"<",
"InconsistentProperty",
">",
">",
"warnings",
"=",
"report",
".",
"getConfigWarns",
"(",
")",
";",
"if",
"(",
"warnings",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"mPrintStream",
".",
"println",
"(",
"\"\\nServer-side configuration warnings \"",
"+",
"\"(those properties are recommended to be identical): \"",
")",
";",
"printInconsistentProperties",
"(",
"warnings",
")",
";",
"}",
"return",
"0",
";",
"}"
] |
Runs doctor configuration command.
@return 0 on success, 1 otherwise
|
[
"Runs",
"doctor",
"configuration",
"command",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/doctor/ConfigurationCommand.java#L49-L72
|
19,068
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/doctor/ConfigurationCommand.java
|
ConfigurationCommand.printInconsistentProperties
|
private void printInconsistentProperties(
Map<Scope, List<InconsistentProperty>> inconsistentProperties) {
for (List<InconsistentProperty> list : inconsistentProperties.values()) {
for (InconsistentProperty prop : list) {
mPrintStream.println("key: " + prop.getName());
for (Map.Entry<Optional<String>, List<String>> entry : prop.getValues().entrySet()) {
mPrintStream.println(" value: " + String.format("%s (%s)",
entry.getKey().orElse("no value set"),
String.join(", ", entry.getValue())));
}
}
}
}
|
java
|
private void printInconsistentProperties(
Map<Scope, List<InconsistentProperty>> inconsistentProperties) {
for (List<InconsistentProperty> list : inconsistentProperties.values()) {
for (InconsistentProperty prop : list) {
mPrintStream.println("key: " + prop.getName());
for (Map.Entry<Optional<String>, List<String>> entry : prop.getValues().entrySet()) {
mPrintStream.println(" value: " + String.format("%s (%s)",
entry.getKey().orElse("no value set"),
String.join(", ", entry.getValue())));
}
}
}
}
|
[
"private",
"void",
"printInconsistentProperties",
"(",
"Map",
"<",
"Scope",
",",
"List",
"<",
"InconsistentProperty",
">",
">",
"inconsistentProperties",
")",
"{",
"for",
"(",
"List",
"<",
"InconsistentProperty",
">",
"list",
":",
"inconsistentProperties",
".",
"values",
"(",
")",
")",
"{",
"for",
"(",
"InconsistentProperty",
"prop",
":",
"list",
")",
"{",
"mPrintStream",
".",
"println",
"(",
"\"key: \"",
"+",
"prop",
".",
"getName",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"Optional",
"<",
"String",
">",
",",
"List",
"<",
"String",
">",
">",
"entry",
":",
"prop",
".",
"getValues",
"(",
")",
".",
"entrySet",
"(",
")",
")",
"{",
"mPrintStream",
".",
"println",
"(",
"\" value: \"",
"+",
"String",
".",
"format",
"(",
"\"%s (%s)\"",
",",
"entry",
".",
"getKey",
"(",
")",
".",
"orElse",
"(",
"\"no value set\"",
")",
",",
"String",
".",
"join",
"(",
"\", \"",
",",
"entry",
".",
"getValue",
"(",
")",
")",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Prints the inconsistent properties in server-side configuration.
@param inconsistentProperties the inconsistent properties to print
|
[
"Prints",
"the",
"inconsistent",
"properties",
"in",
"server",
"-",
"side",
"configuration",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/doctor/ConfigurationCommand.java#L79-L91
|
19,069
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/AbstractLocalAlluxioCluster.java
|
AbstractLocalAlluxioCluster.startProxy
|
private void startProxy() throws Exception {
mProxyProcess = ProxyProcess.Factory.create();
Runnable runProxy = () -> {
try {
mProxyProcess.start();
} catch (InterruptedException e) {
// this is expected
} catch (Exception e) {
// Log the exception as the RuntimeException will be caught and handled silently by JUnit
LOG.error("Start proxy error", e);
throw new RuntimeException(e + " \n Start Proxy Error \n" + e.getMessage(), e);
}
};
mProxyThread = new Thread(runProxy);
mProxyThread.setName("ProxyThread-" + System.identityHashCode(mProxyThread));
mProxyThread.start();
TestUtils.waitForReady(mProxyProcess);
}
|
java
|
private void startProxy() throws Exception {
mProxyProcess = ProxyProcess.Factory.create();
Runnable runProxy = () -> {
try {
mProxyProcess.start();
} catch (InterruptedException e) {
// this is expected
} catch (Exception e) {
// Log the exception as the RuntimeException will be caught and handled silently by JUnit
LOG.error("Start proxy error", e);
throw new RuntimeException(e + " \n Start Proxy Error \n" + e.getMessage(), e);
}
};
mProxyThread = new Thread(runProxy);
mProxyThread.setName("ProxyThread-" + System.identityHashCode(mProxyThread));
mProxyThread.start();
TestUtils.waitForReady(mProxyProcess);
}
|
[
"private",
"void",
"startProxy",
"(",
")",
"throws",
"Exception",
"{",
"mProxyProcess",
"=",
"ProxyProcess",
".",
"Factory",
".",
"create",
"(",
")",
";",
"Runnable",
"runProxy",
"=",
"(",
")",
"->",
"{",
"try",
"{",
"mProxyProcess",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// this is expected",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Log the exception as the RuntimeException will be caught and handled silently by JUnit",
"LOG",
".",
"error",
"(",
"\"Start proxy error\"",
",",
"e",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"e",
"+",
"\" \\n Start Proxy Error \\n\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
";",
"mProxyThread",
"=",
"new",
"Thread",
"(",
"runProxy",
")",
";",
"mProxyThread",
".",
"setName",
"(",
"\"ProxyThread-\"",
"+",
"System",
".",
"identityHashCode",
"(",
"mProxyThread",
")",
")",
";",
"mProxyThread",
".",
"start",
"(",
")",
";",
"TestUtils",
".",
"waitForReady",
"(",
"mProxyProcess",
")",
";",
"}"
] |
Configures and starts the proxy.
|
[
"Configures",
"and",
"starts",
"the",
"proxy",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/AbstractLocalAlluxioCluster.java#L111-L129
|
19,070
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/AbstractLocalAlluxioCluster.java
|
AbstractLocalAlluxioCluster.formatAndRestartMasters
|
public void formatAndRestartMasters() throws Exception {
stopMasters();
Format.format(Format.Mode.MASTER, ServerConfiguration.global());
startMasters();
}
|
java
|
public void formatAndRestartMasters() throws Exception {
stopMasters();
Format.format(Format.Mode.MASTER, ServerConfiguration.global());
startMasters();
}
|
[
"public",
"void",
"formatAndRestartMasters",
"(",
")",
"throws",
"Exception",
"{",
"stopMasters",
"(",
")",
";",
"Format",
".",
"format",
"(",
"Format",
".",
"Mode",
".",
"MASTER",
",",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
";",
"startMasters",
"(",
")",
";",
"}"
] |
Stops the masters, formats them, and then restarts them. This is useful if a fresh state is
desired, for example when restoring from a backup.
|
[
"Stops",
"the",
"masters",
"formats",
"them",
"and",
"then",
"restarts",
"them",
".",
"This",
"is",
"useful",
"if",
"a",
"fresh",
"state",
"is",
"desired",
"for",
"example",
"when",
"restoring",
"from",
"a",
"backup",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/AbstractLocalAlluxioCluster.java#L216-L220
|
19,071
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/AbstractLocalAlluxioCluster.java
|
AbstractLocalAlluxioCluster.stopProxy
|
protected void stopProxy() throws Exception {
mProxyProcess.stop();
if (mProxyThread != null) {
while (mProxyThread.isAlive()) {
LOG.info("Stopping thread {}.", mProxyThread.getName());
mProxyThread.interrupt();
mProxyThread.join(1000);
}
mProxyThread = null;
}
}
|
java
|
protected void stopProxy() throws Exception {
mProxyProcess.stop();
if (mProxyThread != null) {
while (mProxyThread.isAlive()) {
LOG.info("Stopping thread {}.", mProxyThread.getName());
mProxyThread.interrupt();
mProxyThread.join(1000);
}
mProxyThread = null;
}
}
|
[
"protected",
"void",
"stopProxy",
"(",
")",
"throws",
"Exception",
"{",
"mProxyProcess",
".",
"stop",
"(",
")",
";",
"if",
"(",
"mProxyThread",
"!=",
"null",
")",
"{",
"while",
"(",
"mProxyThread",
".",
"isAlive",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Stopping thread {}.\"",
",",
"mProxyThread",
".",
"getName",
"(",
")",
")",
";",
"mProxyThread",
".",
"interrupt",
"(",
")",
";",
"mProxyThread",
".",
"join",
"(",
"1000",
")",
";",
"}",
"mProxyThread",
"=",
"null",
";",
"}",
"}"
] |
Stops the proxy.
|
[
"Stops",
"the",
"proxy",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/AbstractLocalAlluxioCluster.java#L230-L240
|
19,072
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/AbstractLocalAlluxioCluster.java
|
AbstractLocalAlluxioCluster.stopWorkers
|
public void stopWorkers() throws Exception {
if (mWorkers == null) {
return;
}
for (WorkerProcess worker : mWorkers) {
worker.stop();
}
for (Thread thread : mWorkerThreads) {
while (thread.isAlive()) {
LOG.info("Stopping thread {}.", thread.getName());
thread.interrupt();
thread.join(1000);
}
}
mWorkerThreads.clear();
}
|
java
|
public void stopWorkers() throws Exception {
if (mWorkers == null) {
return;
}
for (WorkerProcess worker : mWorkers) {
worker.stop();
}
for (Thread thread : mWorkerThreads) {
while (thread.isAlive()) {
LOG.info("Stopping thread {}.", thread.getName());
thread.interrupt();
thread.join(1000);
}
}
mWorkerThreads.clear();
}
|
[
"public",
"void",
"stopWorkers",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"mWorkers",
"==",
"null",
")",
"{",
"return",
";",
"}",
"for",
"(",
"WorkerProcess",
"worker",
":",
"mWorkers",
")",
"{",
"worker",
".",
"stop",
"(",
")",
";",
"}",
"for",
"(",
"Thread",
"thread",
":",
"mWorkerThreads",
")",
"{",
"while",
"(",
"thread",
".",
"isAlive",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Stopping thread {}.\"",
",",
"thread",
".",
"getName",
"(",
")",
")",
";",
"thread",
".",
"interrupt",
"(",
")",
";",
"thread",
".",
"join",
"(",
"1000",
")",
";",
"}",
"}",
"mWorkerThreads",
".",
"clear",
"(",
")",
";",
"}"
] |
Stops the workers.
|
[
"Stops",
"the",
"workers",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/AbstractLocalAlluxioCluster.java#L245-L260
|
19,073
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/AbstractLocalAlluxioCluster.java
|
AbstractLocalAlluxioCluster.waitForWorkersRegistered
|
public void waitForWorkersRegistered(int timeoutMs)
throws TimeoutException, InterruptedException, IOException {
try (MetaMasterClient client =
new RetryHandlingMetaMasterClient(MasterClientContext
.newBuilder(ClientContext.create(ServerConfiguration.global())).build())) {
CommonUtils.waitFor("workers registered", () -> {
try {
return client.getMasterInfo(Collections.emptySet())
.getWorkerAddressesList().size() == mNumWorkers;
} catch (UnavailableException e) {
return false;
} catch (Exception e) {
throw new RuntimeException(e);
}
}, WaitForOptions.defaults().setInterval(200).setTimeoutMs(timeoutMs));
}
}
|
java
|
public void waitForWorkersRegistered(int timeoutMs)
throws TimeoutException, InterruptedException, IOException {
try (MetaMasterClient client =
new RetryHandlingMetaMasterClient(MasterClientContext
.newBuilder(ClientContext.create(ServerConfiguration.global())).build())) {
CommonUtils.waitFor("workers registered", () -> {
try {
return client.getMasterInfo(Collections.emptySet())
.getWorkerAddressesList().size() == mNumWorkers;
} catch (UnavailableException e) {
return false;
} catch (Exception e) {
throw new RuntimeException(e);
}
}, WaitForOptions.defaults().setInterval(200).setTimeoutMs(timeoutMs));
}
}
|
[
"public",
"void",
"waitForWorkersRegistered",
"(",
"int",
"timeoutMs",
")",
"throws",
"TimeoutException",
",",
"InterruptedException",
",",
"IOException",
"{",
"try",
"(",
"MetaMasterClient",
"client",
"=",
"new",
"RetryHandlingMetaMasterClient",
"(",
"MasterClientContext",
".",
"newBuilder",
"(",
"ClientContext",
".",
"create",
"(",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
")",
".",
"build",
"(",
")",
")",
")",
"{",
"CommonUtils",
".",
"waitFor",
"(",
"\"workers registered\"",
",",
"(",
")",
"->",
"{",
"try",
"{",
"return",
"client",
".",
"getMasterInfo",
"(",
"Collections",
".",
"emptySet",
"(",
")",
")",
".",
"getWorkerAddressesList",
"(",
")",
".",
"size",
"(",
")",
"==",
"mNumWorkers",
";",
"}",
"catch",
"(",
"UnavailableException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
",",
"WaitForOptions",
".",
"defaults",
"(",
")",
".",
"setInterval",
"(",
"200",
")",
".",
"setTimeoutMs",
"(",
"timeoutMs",
")",
")",
";",
"}",
"}"
] |
Waits for all workers registered with master.
@param timeoutMs the timeout to wait
|
[
"Waits",
"for",
"all",
"workers",
"registered",
"with",
"master",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/AbstractLocalAlluxioCluster.java#L299-L315
|
19,074
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java
|
LocalAlluxioMaster.create
|
public static LocalAlluxioMaster create(boolean includeSecondary) throws IOException {
String workDirectory = uniquePath();
FileUtils.deletePathRecursively(workDirectory);
ServerConfiguration.set(PropertyKey.WORK_DIR, workDirectory);
return create(workDirectory, includeSecondary);
}
|
java
|
public static LocalAlluxioMaster create(boolean includeSecondary) throws IOException {
String workDirectory = uniquePath();
FileUtils.deletePathRecursively(workDirectory);
ServerConfiguration.set(PropertyKey.WORK_DIR, workDirectory);
return create(workDirectory, includeSecondary);
}
|
[
"public",
"static",
"LocalAlluxioMaster",
"create",
"(",
"boolean",
"includeSecondary",
")",
"throws",
"IOException",
"{",
"String",
"workDirectory",
"=",
"uniquePath",
"(",
")",
";",
"FileUtils",
".",
"deletePathRecursively",
"(",
"workDirectory",
")",
";",
"ServerConfiguration",
".",
"set",
"(",
"PropertyKey",
".",
"WORK_DIR",
",",
"workDirectory",
")",
";",
"return",
"create",
"(",
"workDirectory",
",",
"includeSecondary",
")",
";",
"}"
] |
Creates a new local Alluxio master with an isolated work directory and port.
@param includeSecondary whether to start a secondary master alongside the regular master
@return an instance of Alluxio master
|
[
"Creates",
"a",
"new",
"local",
"Alluxio",
"master",
"with",
"an",
"isolated",
"work",
"directory",
"and",
"port",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java#L75-L80
|
19,075
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java
|
LocalAlluxioMaster.create
|
public static LocalAlluxioMaster create(String workDirectory, boolean includeSecondary)
throws IOException {
if (!Files.isDirectory(Paths.get(workDirectory))) {
Files.createDirectory(Paths.get(workDirectory));
}
return new LocalAlluxioMaster(includeSecondary);
}
|
java
|
public static LocalAlluxioMaster create(String workDirectory, boolean includeSecondary)
throws IOException {
if (!Files.isDirectory(Paths.get(workDirectory))) {
Files.createDirectory(Paths.get(workDirectory));
}
return new LocalAlluxioMaster(includeSecondary);
}
|
[
"public",
"static",
"LocalAlluxioMaster",
"create",
"(",
"String",
"workDirectory",
",",
"boolean",
"includeSecondary",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"Files",
".",
"isDirectory",
"(",
"Paths",
".",
"get",
"(",
"workDirectory",
")",
")",
")",
"{",
"Files",
".",
"createDirectory",
"(",
"Paths",
".",
"get",
"(",
"workDirectory",
")",
")",
";",
"}",
"return",
"new",
"LocalAlluxioMaster",
"(",
"includeSecondary",
")",
";",
"}"
] |
Creates a new local Alluxio master with a isolated port.
@param workDirectory Alluxio work directory, this method will create it if it doesn't exist yet
@param includeSecondary whether to start a secondary master alongside the regular master
@return the created Alluxio master
|
[
"Creates",
"a",
"new",
"local",
"Alluxio",
"master",
"with",
"a",
"isolated",
"port",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java#L89-L95
|
19,076
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java
|
LocalAlluxioMaster.start
|
public void start() {
mMasterProcess = AlluxioMasterProcess.Factory.create();
Runnable runMaster = new Runnable() {
@Override
public void run() {
try {
LOG.info("Starting Alluxio master {}.", mMasterProcess);
mMasterProcess.start();
} catch (InterruptedException e) {
// this is expected
} catch (Exception e) {
// Log the exception as the RuntimeException will be caught and handled silently by JUnit
LOG.error("Start master error", e);
throw new RuntimeException(e + " \n Start Master Error \n" + e.getMessage(), e);
}
}
};
mMasterThread = new Thread(runMaster);
mMasterThread.setName("MasterThread-" + System.identityHashCode(mMasterThread));
mMasterThread.start();
TestUtils.waitForReady(mMasterProcess);
// Don't start a secondary master when using the Raft journal.
if (ServerConfiguration.getEnum(PropertyKey.MASTER_JOURNAL_TYPE,
JournalType.class) == JournalType.EMBEDDED) {
return;
}
if (!mIncludeSecondary) {
return;
}
mSecondaryMaster = new AlluxioSecondaryMaster();
Runnable runSecondaryMaster = new Runnable() {
@Override
public void run() {
try {
LOG.info("Starting secondary master {}.", mSecondaryMaster);
mSecondaryMaster.start();
} catch (InterruptedException e) {
// this is expected
} catch (Exception e) {
// Log the exception as the RuntimeException will be caught and handled silently by JUnit
LOG.error("Start secondary master error", e);
throw new RuntimeException(e + " \n Start Secondary Master Error \n" + e.getMessage(), e);
}
}
};
mSecondaryMasterThread = new Thread(runSecondaryMaster);
mSecondaryMasterThread
.setName("SecondaryMasterThread-" + System.identityHashCode(mSecondaryMasterThread));
mSecondaryMasterThread.start();
TestUtils.waitForReady(mSecondaryMaster);
}
|
java
|
public void start() {
mMasterProcess = AlluxioMasterProcess.Factory.create();
Runnable runMaster = new Runnable() {
@Override
public void run() {
try {
LOG.info("Starting Alluxio master {}.", mMasterProcess);
mMasterProcess.start();
} catch (InterruptedException e) {
// this is expected
} catch (Exception e) {
// Log the exception as the RuntimeException will be caught and handled silently by JUnit
LOG.error("Start master error", e);
throw new RuntimeException(e + " \n Start Master Error \n" + e.getMessage(), e);
}
}
};
mMasterThread = new Thread(runMaster);
mMasterThread.setName("MasterThread-" + System.identityHashCode(mMasterThread));
mMasterThread.start();
TestUtils.waitForReady(mMasterProcess);
// Don't start a secondary master when using the Raft journal.
if (ServerConfiguration.getEnum(PropertyKey.MASTER_JOURNAL_TYPE,
JournalType.class) == JournalType.EMBEDDED) {
return;
}
if (!mIncludeSecondary) {
return;
}
mSecondaryMaster = new AlluxioSecondaryMaster();
Runnable runSecondaryMaster = new Runnable() {
@Override
public void run() {
try {
LOG.info("Starting secondary master {}.", mSecondaryMaster);
mSecondaryMaster.start();
} catch (InterruptedException e) {
// this is expected
} catch (Exception e) {
// Log the exception as the RuntimeException will be caught and handled silently by JUnit
LOG.error("Start secondary master error", e);
throw new RuntimeException(e + " \n Start Secondary Master Error \n" + e.getMessage(), e);
}
}
};
mSecondaryMasterThread = new Thread(runSecondaryMaster);
mSecondaryMasterThread
.setName("SecondaryMasterThread-" + System.identityHashCode(mSecondaryMasterThread));
mSecondaryMasterThread.start();
TestUtils.waitForReady(mSecondaryMaster);
}
|
[
"public",
"void",
"start",
"(",
")",
"{",
"mMasterProcess",
"=",
"AlluxioMasterProcess",
".",
"Factory",
".",
"create",
"(",
")",
";",
"Runnable",
"runMaster",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"LOG",
".",
"info",
"(",
"\"Starting Alluxio master {}.\"",
",",
"mMasterProcess",
")",
";",
"mMasterProcess",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// this is expected",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Log the exception as the RuntimeException will be caught and handled silently by JUnit",
"LOG",
".",
"error",
"(",
"\"Start master error\"",
",",
"e",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"e",
"+",
"\" \\n Start Master Error \\n\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
";",
"mMasterThread",
"=",
"new",
"Thread",
"(",
"runMaster",
")",
";",
"mMasterThread",
".",
"setName",
"(",
"\"MasterThread-\"",
"+",
"System",
".",
"identityHashCode",
"(",
"mMasterThread",
")",
")",
";",
"mMasterThread",
".",
"start",
"(",
")",
";",
"TestUtils",
".",
"waitForReady",
"(",
"mMasterProcess",
")",
";",
"// Don't start a secondary master when using the Raft journal.",
"if",
"(",
"ServerConfiguration",
".",
"getEnum",
"(",
"PropertyKey",
".",
"MASTER_JOURNAL_TYPE",
",",
"JournalType",
".",
"class",
")",
"==",
"JournalType",
".",
"EMBEDDED",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"mIncludeSecondary",
")",
"{",
"return",
";",
"}",
"mSecondaryMaster",
"=",
"new",
"AlluxioSecondaryMaster",
"(",
")",
";",
"Runnable",
"runSecondaryMaster",
"=",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"LOG",
".",
"info",
"(",
"\"Starting secondary master {}.\"",
",",
"mSecondaryMaster",
")",
";",
"mSecondaryMaster",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"// this is expected",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Log the exception as the RuntimeException will be caught and handled silently by JUnit",
"LOG",
".",
"error",
"(",
"\"Start secondary master error\"",
",",
"e",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"e",
"+",
"\" \\n Start Secondary Master Error \\n\"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"}",
";",
"mSecondaryMasterThread",
"=",
"new",
"Thread",
"(",
"runSecondaryMaster",
")",
";",
"mSecondaryMasterThread",
".",
"setName",
"(",
"\"SecondaryMasterThread-\"",
"+",
"System",
".",
"identityHashCode",
"(",
"mSecondaryMasterThread",
")",
")",
";",
"mSecondaryMasterThread",
".",
"start",
"(",
")",
";",
"TestUtils",
".",
"waitForReady",
"(",
"mSecondaryMaster",
")",
";",
"}"
] |
Starts the master.
|
[
"Starts",
"the",
"master",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java#L100-L150
|
19,077
|
Alluxio/alluxio
|
minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java
|
LocalAlluxioMaster.stop
|
public void stop() throws Exception {
if (mSecondaryMasterThread != null) {
mSecondaryMaster.stop();
while (mSecondaryMasterThread.isAlive()) {
LOG.info("Stopping thread {}.", mSecondaryMasterThread.getName());
mSecondaryMasterThread.join(1000);
}
mSecondaryMasterThread = null;
}
if (mMasterThread != null) {
mMasterProcess.stop();
while (mMasterThread.isAlive()) {
LOG.info("Stopping thread {}.", mMasterThread.getName());
mMasterThread.interrupt();
mMasterThread.join(1000);
}
mMasterThread = null;
}
clearClients();
System.clearProperty("alluxio.web.resources");
System.clearProperty("alluxio.master.min.worker.threads");
}
|
java
|
public void stop() throws Exception {
if (mSecondaryMasterThread != null) {
mSecondaryMaster.stop();
while (mSecondaryMasterThread.isAlive()) {
LOG.info("Stopping thread {}.", mSecondaryMasterThread.getName());
mSecondaryMasterThread.join(1000);
}
mSecondaryMasterThread = null;
}
if (mMasterThread != null) {
mMasterProcess.stop();
while (mMasterThread.isAlive()) {
LOG.info("Stopping thread {}.", mMasterThread.getName());
mMasterThread.interrupt();
mMasterThread.join(1000);
}
mMasterThread = null;
}
clearClients();
System.clearProperty("alluxio.web.resources");
System.clearProperty("alluxio.master.min.worker.threads");
}
|
[
"public",
"void",
"stop",
"(",
")",
"throws",
"Exception",
"{",
"if",
"(",
"mSecondaryMasterThread",
"!=",
"null",
")",
"{",
"mSecondaryMaster",
".",
"stop",
"(",
")",
";",
"while",
"(",
"mSecondaryMasterThread",
".",
"isAlive",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Stopping thread {}.\"",
",",
"mSecondaryMasterThread",
".",
"getName",
"(",
")",
")",
";",
"mSecondaryMasterThread",
".",
"join",
"(",
"1000",
")",
";",
"}",
"mSecondaryMasterThread",
"=",
"null",
";",
"}",
"if",
"(",
"mMasterThread",
"!=",
"null",
")",
"{",
"mMasterProcess",
".",
"stop",
"(",
")",
";",
"while",
"(",
"mMasterThread",
".",
"isAlive",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Stopping thread {}.\"",
",",
"mMasterThread",
".",
"getName",
"(",
")",
")",
";",
"mMasterThread",
".",
"interrupt",
"(",
")",
";",
"mMasterThread",
".",
"join",
"(",
"1000",
")",
";",
"}",
"mMasterThread",
"=",
"null",
";",
"}",
"clearClients",
"(",
")",
";",
"System",
".",
"clearProperty",
"(",
"\"alluxio.web.resources\"",
")",
";",
"System",
".",
"clearProperty",
"(",
"\"alluxio.master.min.worker.threads\"",
")",
";",
"}"
] |
Stops the master processes and cleans up client connections.
|
[
"Stops",
"the",
"master",
"processes",
"and",
"cleans",
"up",
"client",
"connections",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java#L162-L183
|
19,078
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/file/FileSystemContext.java
|
FileSystemContext.init
|
private synchronized void init(MasterInquireClient masterInquireClient) {
mMasterInquireClient = masterInquireClient;
mFileSystemMasterClientPool =
new FileSystemMasterClientPool(mClientContext, mMasterInquireClient);
mBlockMasterClientPool = new BlockMasterClientPool(mClientContext, mMasterInquireClient);
mClosed.set(false);
if (mClientContext.getConf().getBoolean(PropertyKey.USER_METRICS_COLLECTION_ENABLED)) {
// setup metrics master client sync
mMetricsMasterClient = new MetricsMasterClient(MasterClientContext
.newBuilder(mClientContext)
.setMasterInquireClient(mMasterInquireClient)
.build());
mClientMasterSync = new ClientMasterSync(mMetricsMasterClient, mAppId);
mExecutorService = Executors.newFixedThreadPool(1,
ThreadFactoryUtils.build("metrics-master-heartbeat-%d", true));
mExecutorService
.submit(new HeartbeatThread(HeartbeatContext.MASTER_METRICS_SYNC, mClientMasterSync,
(int) mClientContext.getConf().getMs(PropertyKey.USER_METRICS_HEARTBEAT_INTERVAL_MS),
mClientContext.getConf()));
// register the shutdown hook
try {
Runtime.getRuntime().addShutdownHook(new MetricsMasterSyncShutDownHook());
} catch (IllegalStateException e) {
// this exception is thrown when the system is already in the process of shutting down. In
// such a situation, we are about to shutdown anyway and there is no need to register this
// shutdown hook
} catch (SecurityException e) {
LOG.info("Not registering metrics shutdown hook due to security exception. Regular "
+ "heartbeats will still be performed to collect metrics data, but no final heartbeat "
+ "will be performed on JVM exit. Security exception: {}", e.toString());
}
}
}
|
java
|
private synchronized void init(MasterInquireClient masterInquireClient) {
mMasterInquireClient = masterInquireClient;
mFileSystemMasterClientPool =
new FileSystemMasterClientPool(mClientContext, mMasterInquireClient);
mBlockMasterClientPool = new BlockMasterClientPool(mClientContext, mMasterInquireClient);
mClosed.set(false);
if (mClientContext.getConf().getBoolean(PropertyKey.USER_METRICS_COLLECTION_ENABLED)) {
// setup metrics master client sync
mMetricsMasterClient = new MetricsMasterClient(MasterClientContext
.newBuilder(mClientContext)
.setMasterInquireClient(mMasterInquireClient)
.build());
mClientMasterSync = new ClientMasterSync(mMetricsMasterClient, mAppId);
mExecutorService = Executors.newFixedThreadPool(1,
ThreadFactoryUtils.build("metrics-master-heartbeat-%d", true));
mExecutorService
.submit(new HeartbeatThread(HeartbeatContext.MASTER_METRICS_SYNC, mClientMasterSync,
(int) mClientContext.getConf().getMs(PropertyKey.USER_METRICS_HEARTBEAT_INTERVAL_MS),
mClientContext.getConf()));
// register the shutdown hook
try {
Runtime.getRuntime().addShutdownHook(new MetricsMasterSyncShutDownHook());
} catch (IllegalStateException e) {
// this exception is thrown when the system is already in the process of shutting down. In
// such a situation, we are about to shutdown anyway and there is no need to register this
// shutdown hook
} catch (SecurityException e) {
LOG.info("Not registering metrics shutdown hook due to security exception. Regular "
+ "heartbeats will still be performed to collect metrics data, but no final heartbeat "
+ "will be performed on JVM exit. Security exception: {}", e.toString());
}
}
}
|
[
"private",
"synchronized",
"void",
"init",
"(",
"MasterInquireClient",
"masterInquireClient",
")",
"{",
"mMasterInquireClient",
"=",
"masterInquireClient",
";",
"mFileSystemMasterClientPool",
"=",
"new",
"FileSystemMasterClientPool",
"(",
"mClientContext",
",",
"mMasterInquireClient",
")",
";",
"mBlockMasterClientPool",
"=",
"new",
"BlockMasterClientPool",
"(",
"mClientContext",
",",
"mMasterInquireClient",
")",
";",
"mClosed",
".",
"set",
"(",
"false",
")",
";",
"if",
"(",
"mClientContext",
".",
"getConf",
"(",
")",
".",
"getBoolean",
"(",
"PropertyKey",
".",
"USER_METRICS_COLLECTION_ENABLED",
")",
")",
"{",
"// setup metrics master client sync",
"mMetricsMasterClient",
"=",
"new",
"MetricsMasterClient",
"(",
"MasterClientContext",
".",
"newBuilder",
"(",
"mClientContext",
")",
".",
"setMasterInquireClient",
"(",
"mMasterInquireClient",
")",
".",
"build",
"(",
")",
")",
";",
"mClientMasterSync",
"=",
"new",
"ClientMasterSync",
"(",
"mMetricsMasterClient",
",",
"mAppId",
")",
";",
"mExecutorService",
"=",
"Executors",
".",
"newFixedThreadPool",
"(",
"1",
",",
"ThreadFactoryUtils",
".",
"build",
"(",
"\"metrics-master-heartbeat-%d\"",
",",
"true",
")",
")",
";",
"mExecutorService",
".",
"submit",
"(",
"new",
"HeartbeatThread",
"(",
"HeartbeatContext",
".",
"MASTER_METRICS_SYNC",
",",
"mClientMasterSync",
",",
"(",
"int",
")",
"mClientContext",
".",
"getConf",
"(",
")",
".",
"getMs",
"(",
"PropertyKey",
".",
"USER_METRICS_HEARTBEAT_INTERVAL_MS",
")",
",",
"mClientContext",
".",
"getConf",
"(",
")",
")",
")",
";",
"// register the shutdown hook",
"try",
"{",
"Runtime",
".",
"getRuntime",
"(",
")",
".",
"addShutdownHook",
"(",
"new",
"MetricsMasterSyncShutDownHook",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IllegalStateException",
"e",
")",
"{",
"// this exception is thrown when the system is already in the process of shutting down. In",
"// such a situation, we are about to shutdown anyway and there is no need to register this",
"// shutdown hook",
"}",
"catch",
"(",
"SecurityException",
"e",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Not registering metrics shutdown hook due to security exception. Regular \"",
"+",
"\"heartbeats will still be performed to collect metrics data, but no final heartbeat \"",
"+",
"\"will be performed on JVM exit. Security exception: {}\"",
",",
"e",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Initializes the context. Only called in the factory methods.
@param masterInquireClient the client to use for determining the master
|
[
"Initializes",
"the",
"context",
".",
"Only",
"called",
"in",
"the",
"factory",
"methods",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/file/FileSystemContext.java#L227-L260
|
19,079
|
Alluxio/alluxio
|
core/client/fs/src/main/java/alluxio/client/file/FileSystemContext.java
|
FileSystemContext.releaseBlockWorkerClient
|
public void releaseBlockWorkerClient(WorkerNetAddress workerNetAddress,
BlockWorkerClient client) {
SocketAddress address = NetworkAddressUtils.getDataPortSocketAddress(workerNetAddress,
getClusterConf());
ClientPoolKey key = new ClientPoolKey(address, AuthenticationUserUtils.getImpersonationUser(
mClientContext.getSubject(), getClusterConf()));
if (mBlockWorkerClientPool.containsKey(key)) {
mBlockWorkerClientPool.get(key).release(client);
} else {
LOG.warn("No client pool for key {}, closing client instead. Context is closed: {}",
key, mClosed.get());
try {
client.close();
} catch (IOException e) {
LOG.warn("Error closing block worker client for key {}", key, e);
}
}
}
|
java
|
public void releaseBlockWorkerClient(WorkerNetAddress workerNetAddress,
BlockWorkerClient client) {
SocketAddress address = NetworkAddressUtils.getDataPortSocketAddress(workerNetAddress,
getClusterConf());
ClientPoolKey key = new ClientPoolKey(address, AuthenticationUserUtils.getImpersonationUser(
mClientContext.getSubject(), getClusterConf()));
if (mBlockWorkerClientPool.containsKey(key)) {
mBlockWorkerClientPool.get(key).release(client);
} else {
LOG.warn("No client pool for key {}, closing client instead. Context is closed: {}",
key, mClosed.get());
try {
client.close();
} catch (IOException e) {
LOG.warn("Error closing block worker client for key {}", key, e);
}
}
}
|
[
"public",
"void",
"releaseBlockWorkerClient",
"(",
"WorkerNetAddress",
"workerNetAddress",
",",
"BlockWorkerClient",
"client",
")",
"{",
"SocketAddress",
"address",
"=",
"NetworkAddressUtils",
".",
"getDataPortSocketAddress",
"(",
"workerNetAddress",
",",
"getClusterConf",
"(",
")",
")",
";",
"ClientPoolKey",
"key",
"=",
"new",
"ClientPoolKey",
"(",
"address",
",",
"AuthenticationUserUtils",
".",
"getImpersonationUser",
"(",
"mClientContext",
".",
"getSubject",
"(",
")",
",",
"getClusterConf",
"(",
")",
")",
")",
";",
"if",
"(",
"mBlockWorkerClientPool",
".",
"containsKey",
"(",
"key",
")",
")",
"{",
"mBlockWorkerClientPool",
".",
"get",
"(",
"key",
")",
".",
"release",
"(",
"client",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"warn",
"(",
"\"No client pool for key {}, closing client instead. Context is closed: {}\"",
",",
"key",
",",
"mClosed",
".",
"get",
"(",
")",
")",
";",
"try",
"{",
"client",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Error closing block worker client for key {}\"",
",",
"key",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Releases a block worker client to the client pools.
@param workerNetAddress the address of the channel
@param client the client to release
|
[
"Releases",
"a",
"block",
"worker",
"client",
"to",
"the",
"client",
"pools",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/client/fs/src/main/java/alluxio/client/file/FileSystemContext.java#L424-L441
|
19,080
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalReader.java
|
UfsJournalReader.readInternal
|
private Journal.JournalEntry readInternal() throws IOException {
if (mInputStream == null) {
return null;
}
JournalEntry entry = mInputStream.mReader.readEntry();
if (entry != null) {
return entry;
}
if (mInputStream.mFile.isIncompleteLog()) {
// Incomplete logs may end early.
return null;
} else {
Preconditions.checkState(mInputStream.mFile.isCompletedLog(),
"Expected log to be either checkpoint, incomplete, or complete");
ProcessUtils.fatalError(LOG, "Journal entry %s was truncated", mNextSequenceNumber);
return null;
}
}
|
java
|
private Journal.JournalEntry readInternal() throws IOException {
if (mInputStream == null) {
return null;
}
JournalEntry entry = mInputStream.mReader.readEntry();
if (entry != null) {
return entry;
}
if (mInputStream.mFile.isIncompleteLog()) {
// Incomplete logs may end early.
return null;
} else {
Preconditions.checkState(mInputStream.mFile.isCompletedLog(),
"Expected log to be either checkpoint, incomplete, or complete");
ProcessUtils.fatalError(LOG, "Journal entry %s was truncated", mNextSequenceNumber);
return null;
}
}
|
[
"private",
"Journal",
".",
"JournalEntry",
"readInternal",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mInputStream",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"JournalEntry",
"entry",
"=",
"mInputStream",
".",
"mReader",
".",
"readEntry",
"(",
")",
";",
"if",
"(",
"entry",
"!=",
"null",
")",
"{",
"return",
"entry",
";",
"}",
"if",
"(",
"mInputStream",
".",
"mFile",
".",
"isIncompleteLog",
"(",
")",
")",
"{",
"// Incomplete logs may end early.",
"return",
"null",
";",
"}",
"else",
"{",
"Preconditions",
".",
"checkState",
"(",
"mInputStream",
".",
"mFile",
".",
"isCompletedLog",
"(",
")",
",",
"\"Expected log to be either checkpoint, incomplete, or complete\"",
")",
";",
"ProcessUtils",
".",
"fatalError",
"(",
"LOG",
",",
"\"Journal entry %s was truncated\"",
",",
"mNextSequenceNumber",
")",
";",
"return",
"null",
";",
"}",
"}"
] |
Reads the next journal entry.
@return the journal entry, null if no journal entry is found
|
[
"Reads",
"the",
"next",
"journal",
"entry",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalReader.java#L188-L205
|
19,081
|
Alluxio/alluxio
|
core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalReader.java
|
UfsJournalReader.updateInputStream
|
private void updateInputStream() throws IOException {
if (mInputStream != null && (mInputStream.mFile.isIncompleteLog() || !mInputStream.isDone())) {
return;
}
if (mInputStream != null) {
mInputStream.close();
mInputStream = null;
}
if (mFilesToProcess.isEmpty()) {
UfsJournalSnapshot snapshot = UfsJournalSnapshot.getSnapshot(mJournal);
if (snapshot.getCheckpoints().isEmpty() && snapshot.getLogs().isEmpty()) {
return;
}
int index = 0;
if (!snapshot.getCheckpoints().isEmpty()) {
UfsJournalFile checkpoint = snapshot.getLatestCheckpoint();
if (mNextSequenceNumber < checkpoint.getEnd()) {
String location = checkpoint.getLocation().toString();
LOG.info("Reading checkpoint {}", location);
mCheckpointStream = new CheckpointInputStream(
mUfs.open(location, OpenOptions.defaults().setRecoverFailedOpen(true)));
mNextSequenceNumber = checkpoint.getEnd();
}
for (; index < snapshot.getLogs().size(); index++) {
UfsJournalFile file = snapshot.getLogs().get(index);
if (file.getEnd() > checkpoint.getEnd()) {
break;
}
}
// index now points to the first log with mEnd > checkpoint.mEnd.
}
for (; index < snapshot.getLogs().size(); index++) {
UfsJournalFile file = snapshot.getLogs().get(index);
if ((!mReadIncompleteLog && file.isIncompleteLog())
|| mNextSequenceNumber >= file.getEnd()) {
continue;
}
mFilesToProcess.add(snapshot.getLogs().get(index));
}
}
if (!mFilesToProcess.isEmpty()) {
mInputStream = new JournalInputStream(mFilesToProcess.poll());
}
}
|
java
|
private void updateInputStream() throws IOException {
if (mInputStream != null && (mInputStream.mFile.isIncompleteLog() || !mInputStream.isDone())) {
return;
}
if (mInputStream != null) {
mInputStream.close();
mInputStream = null;
}
if (mFilesToProcess.isEmpty()) {
UfsJournalSnapshot snapshot = UfsJournalSnapshot.getSnapshot(mJournal);
if (snapshot.getCheckpoints().isEmpty() && snapshot.getLogs().isEmpty()) {
return;
}
int index = 0;
if (!snapshot.getCheckpoints().isEmpty()) {
UfsJournalFile checkpoint = snapshot.getLatestCheckpoint();
if (mNextSequenceNumber < checkpoint.getEnd()) {
String location = checkpoint.getLocation().toString();
LOG.info("Reading checkpoint {}", location);
mCheckpointStream = new CheckpointInputStream(
mUfs.open(location, OpenOptions.defaults().setRecoverFailedOpen(true)));
mNextSequenceNumber = checkpoint.getEnd();
}
for (; index < snapshot.getLogs().size(); index++) {
UfsJournalFile file = snapshot.getLogs().get(index);
if (file.getEnd() > checkpoint.getEnd()) {
break;
}
}
// index now points to the first log with mEnd > checkpoint.mEnd.
}
for (; index < snapshot.getLogs().size(); index++) {
UfsJournalFile file = snapshot.getLogs().get(index);
if ((!mReadIncompleteLog && file.isIncompleteLog())
|| mNextSequenceNumber >= file.getEnd()) {
continue;
}
mFilesToProcess.add(snapshot.getLogs().get(index));
}
}
if (!mFilesToProcess.isEmpty()) {
mInputStream = new JournalInputStream(mFilesToProcess.poll());
}
}
|
[
"private",
"void",
"updateInputStream",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"mInputStream",
"!=",
"null",
"&&",
"(",
"mInputStream",
".",
"mFile",
".",
"isIncompleteLog",
"(",
")",
"||",
"!",
"mInputStream",
".",
"isDone",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"mInputStream",
"!=",
"null",
")",
"{",
"mInputStream",
".",
"close",
"(",
")",
";",
"mInputStream",
"=",
"null",
";",
"}",
"if",
"(",
"mFilesToProcess",
".",
"isEmpty",
"(",
")",
")",
"{",
"UfsJournalSnapshot",
"snapshot",
"=",
"UfsJournalSnapshot",
".",
"getSnapshot",
"(",
"mJournal",
")",
";",
"if",
"(",
"snapshot",
".",
"getCheckpoints",
"(",
")",
".",
"isEmpty",
"(",
")",
"&&",
"snapshot",
".",
"getLogs",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"int",
"index",
"=",
"0",
";",
"if",
"(",
"!",
"snapshot",
".",
"getCheckpoints",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"UfsJournalFile",
"checkpoint",
"=",
"snapshot",
".",
"getLatestCheckpoint",
"(",
")",
";",
"if",
"(",
"mNextSequenceNumber",
"<",
"checkpoint",
".",
"getEnd",
"(",
")",
")",
"{",
"String",
"location",
"=",
"checkpoint",
".",
"getLocation",
"(",
")",
".",
"toString",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Reading checkpoint {}\"",
",",
"location",
")",
";",
"mCheckpointStream",
"=",
"new",
"CheckpointInputStream",
"(",
"mUfs",
".",
"open",
"(",
"location",
",",
"OpenOptions",
".",
"defaults",
"(",
")",
".",
"setRecoverFailedOpen",
"(",
"true",
")",
")",
")",
";",
"mNextSequenceNumber",
"=",
"checkpoint",
".",
"getEnd",
"(",
")",
";",
"}",
"for",
"(",
";",
"index",
"<",
"snapshot",
".",
"getLogs",
"(",
")",
".",
"size",
"(",
")",
";",
"index",
"++",
")",
"{",
"UfsJournalFile",
"file",
"=",
"snapshot",
".",
"getLogs",
"(",
")",
".",
"get",
"(",
"index",
")",
";",
"if",
"(",
"file",
".",
"getEnd",
"(",
")",
">",
"checkpoint",
".",
"getEnd",
"(",
")",
")",
"{",
"break",
";",
"}",
"}",
"// index now points to the first log with mEnd > checkpoint.mEnd.",
"}",
"for",
"(",
";",
"index",
"<",
"snapshot",
".",
"getLogs",
"(",
")",
".",
"size",
"(",
")",
";",
"index",
"++",
")",
"{",
"UfsJournalFile",
"file",
"=",
"snapshot",
".",
"getLogs",
"(",
")",
".",
"get",
"(",
"index",
")",
";",
"if",
"(",
"(",
"!",
"mReadIncompleteLog",
"&&",
"file",
".",
"isIncompleteLog",
"(",
")",
")",
"||",
"mNextSequenceNumber",
">=",
"file",
".",
"getEnd",
"(",
")",
")",
"{",
"continue",
";",
"}",
"mFilesToProcess",
".",
"add",
"(",
"snapshot",
".",
"getLogs",
"(",
")",
".",
"get",
"(",
"index",
")",
")",
";",
"}",
"}",
"if",
"(",
"!",
"mFilesToProcess",
".",
"isEmpty",
"(",
")",
")",
"{",
"mInputStream",
"=",
"new",
"JournalInputStream",
"(",
"mFilesToProcess",
".",
"poll",
"(",
")",
")",
";",
"}",
"}"
] |
Updates the journal input stream by closing the current journal input stream if it is done and
opening a new one.
|
[
"Updates",
"the",
"journal",
"input",
"stream",
"by",
"closing",
"the",
"current",
"journal",
"input",
"stream",
"if",
"it",
"is",
"done",
"and",
"opening",
"a",
"new",
"one",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalReader.java#L211-L257
|
19,082
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/SummaryCommand.java
|
SummaryCommand.printMetaMasterInfo
|
private void printMetaMasterInfo() throws IOException {
mIndentationLevel++;
Set<MasterInfoField> masterInfoFilter = new HashSet<>(Arrays
.asList(MasterInfoField.LEADER_MASTER_ADDRESS, MasterInfoField.WEB_PORT,
MasterInfoField.RPC_PORT, MasterInfoField.START_TIME_MS,
MasterInfoField.UP_TIME_MS, MasterInfoField.VERSION,
MasterInfoField.SAFE_MODE, MasterInfoField.ZOOKEEPER_ADDRESSES));
MasterInfo masterInfo = mMetaMasterClient.getMasterInfo(masterInfoFilter);
print("Master Address: " + masterInfo.getLeaderMasterAddress());
print("Web Port: " + masterInfo.getWebPort());
print("Rpc Port: " + masterInfo.getRpcPort());
print("Started: " + CommonUtils.convertMsToDate(masterInfo.getStartTimeMs(),
mDateFormatPattern));
print("Uptime: " + CommonUtils.convertMsToClockTime(masterInfo.getUpTimeMs()));
print("Version: " + masterInfo.getVersion());
print("Safe Mode: " + masterInfo.getSafeMode());
List<String> zookeeperAddresses = masterInfo.getZookeeperAddressesList();
if (zookeeperAddresses == null || zookeeperAddresses.isEmpty()) {
print("Zookeeper Enabled: false");
} else {
print("Zookeeper Enabled: true");
print("Zookeeper Addresses: ");
mIndentationLevel++;
for (String zkAddress : zookeeperAddresses) {
print(zkAddress);
}
mIndentationLevel--;
}
}
|
java
|
private void printMetaMasterInfo() throws IOException {
mIndentationLevel++;
Set<MasterInfoField> masterInfoFilter = new HashSet<>(Arrays
.asList(MasterInfoField.LEADER_MASTER_ADDRESS, MasterInfoField.WEB_PORT,
MasterInfoField.RPC_PORT, MasterInfoField.START_TIME_MS,
MasterInfoField.UP_TIME_MS, MasterInfoField.VERSION,
MasterInfoField.SAFE_MODE, MasterInfoField.ZOOKEEPER_ADDRESSES));
MasterInfo masterInfo = mMetaMasterClient.getMasterInfo(masterInfoFilter);
print("Master Address: " + masterInfo.getLeaderMasterAddress());
print("Web Port: " + masterInfo.getWebPort());
print("Rpc Port: " + masterInfo.getRpcPort());
print("Started: " + CommonUtils.convertMsToDate(masterInfo.getStartTimeMs(),
mDateFormatPattern));
print("Uptime: " + CommonUtils.convertMsToClockTime(masterInfo.getUpTimeMs()));
print("Version: " + masterInfo.getVersion());
print("Safe Mode: " + masterInfo.getSafeMode());
List<String> zookeeperAddresses = masterInfo.getZookeeperAddressesList();
if (zookeeperAddresses == null || zookeeperAddresses.isEmpty()) {
print("Zookeeper Enabled: false");
} else {
print("Zookeeper Enabled: true");
print("Zookeeper Addresses: ");
mIndentationLevel++;
for (String zkAddress : zookeeperAddresses) {
print(zkAddress);
}
mIndentationLevel--;
}
}
|
[
"private",
"void",
"printMetaMasterInfo",
"(",
")",
"throws",
"IOException",
"{",
"mIndentationLevel",
"++",
";",
"Set",
"<",
"MasterInfoField",
">",
"masterInfoFilter",
"=",
"new",
"HashSet",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"MasterInfoField",
".",
"LEADER_MASTER_ADDRESS",
",",
"MasterInfoField",
".",
"WEB_PORT",
",",
"MasterInfoField",
".",
"RPC_PORT",
",",
"MasterInfoField",
".",
"START_TIME_MS",
",",
"MasterInfoField",
".",
"UP_TIME_MS",
",",
"MasterInfoField",
".",
"VERSION",
",",
"MasterInfoField",
".",
"SAFE_MODE",
",",
"MasterInfoField",
".",
"ZOOKEEPER_ADDRESSES",
")",
")",
";",
"MasterInfo",
"masterInfo",
"=",
"mMetaMasterClient",
".",
"getMasterInfo",
"(",
"masterInfoFilter",
")",
";",
"print",
"(",
"\"Master Address: \"",
"+",
"masterInfo",
".",
"getLeaderMasterAddress",
"(",
")",
")",
";",
"print",
"(",
"\"Web Port: \"",
"+",
"masterInfo",
".",
"getWebPort",
"(",
")",
")",
";",
"print",
"(",
"\"Rpc Port: \"",
"+",
"masterInfo",
".",
"getRpcPort",
"(",
")",
")",
";",
"print",
"(",
"\"Started: \"",
"+",
"CommonUtils",
".",
"convertMsToDate",
"(",
"masterInfo",
".",
"getStartTimeMs",
"(",
")",
",",
"mDateFormatPattern",
")",
")",
";",
"print",
"(",
"\"Uptime: \"",
"+",
"CommonUtils",
".",
"convertMsToClockTime",
"(",
"masterInfo",
".",
"getUpTimeMs",
"(",
")",
")",
")",
";",
"print",
"(",
"\"Version: \"",
"+",
"masterInfo",
".",
"getVersion",
"(",
")",
")",
";",
"print",
"(",
"\"Safe Mode: \"",
"+",
"masterInfo",
".",
"getSafeMode",
"(",
")",
")",
";",
"List",
"<",
"String",
">",
"zookeeperAddresses",
"=",
"masterInfo",
".",
"getZookeeperAddressesList",
"(",
")",
";",
"if",
"(",
"zookeeperAddresses",
"==",
"null",
"||",
"zookeeperAddresses",
".",
"isEmpty",
"(",
")",
")",
"{",
"print",
"(",
"\"Zookeeper Enabled: false\"",
")",
";",
"}",
"else",
"{",
"print",
"(",
"\"Zookeeper Enabled: true\"",
")",
";",
"print",
"(",
"\"Zookeeper Addresses: \"",
")",
";",
"mIndentationLevel",
"++",
";",
"for",
"(",
"String",
"zkAddress",
":",
"zookeeperAddresses",
")",
"{",
"print",
"(",
"zkAddress",
")",
";",
"}",
"mIndentationLevel",
"--",
";",
"}",
"}"
] |
Prints Alluxio meta master information.
|
[
"Prints",
"Alluxio",
"meta",
"master",
"information",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/SummaryCommand.java#L78-L108
|
19,083
|
Alluxio/alluxio
|
shell/src/main/java/alluxio/cli/fsadmin/report/SummaryCommand.java
|
SummaryCommand.printBlockMasterInfo
|
private void printBlockMasterInfo() throws IOException {
Set<BlockMasterInfoField> blockMasterInfoFilter = new HashSet<>(Arrays
.asList(BlockMasterInfoField.LIVE_WORKER_NUM, BlockMasterInfoField.LOST_WORKER_NUM,
BlockMasterInfoField.CAPACITY_BYTES, BlockMasterInfoField.USED_BYTES,
BlockMasterInfoField.FREE_BYTES, BlockMasterInfoField.CAPACITY_BYTES_ON_TIERS,
BlockMasterInfoField.USED_BYTES_ON_TIERS));
BlockMasterInfo blockMasterInfo = mBlockMasterClient.getBlockMasterInfo(blockMasterInfoFilter);
print("Live Workers: " + blockMasterInfo.getLiveWorkerNum());
print("Lost Workers: " + blockMasterInfo.getLostWorkerNum());
print("Total Capacity: "
+ FormatUtils.getSizeFromBytes(blockMasterInfo.getCapacityBytes()));
mIndentationLevel++;
Map<String, Long> totalCapacityOnTiers = new TreeMap<>((a, b)
-> (FileSystemAdminShellUtils.compareTierNames(a, b)));
totalCapacityOnTiers.putAll(blockMasterInfo.getCapacityBytesOnTiers());
for (Map.Entry<String, Long> capacityBytesTier : totalCapacityOnTiers.entrySet()) {
print("Tier: " + capacityBytesTier.getKey()
+ " Size: " + FormatUtils.getSizeFromBytes(capacityBytesTier.getValue()));
}
mIndentationLevel--;
print("Used Capacity: "
+ FormatUtils.getSizeFromBytes(blockMasterInfo.getUsedBytes()));
mIndentationLevel++;
Map<String, Long> usedCapacityOnTiers = new TreeMap<>((a, b)
-> (FileSystemAdminShellUtils.compareTierNames(a, b)));
usedCapacityOnTiers.putAll(blockMasterInfo.getUsedBytesOnTiers());
for (Map.Entry<String, Long> usedBytesTier: usedCapacityOnTiers.entrySet()) {
print("Tier: " + usedBytesTier.getKey()
+ " Size: " + FormatUtils.getSizeFromBytes(usedBytesTier.getValue()));
}
mIndentationLevel--;
print("Free Capacity: "
+ FormatUtils.getSizeFromBytes(blockMasterInfo.getFreeBytes()));
}
|
java
|
private void printBlockMasterInfo() throws IOException {
Set<BlockMasterInfoField> blockMasterInfoFilter = new HashSet<>(Arrays
.asList(BlockMasterInfoField.LIVE_WORKER_NUM, BlockMasterInfoField.LOST_WORKER_NUM,
BlockMasterInfoField.CAPACITY_BYTES, BlockMasterInfoField.USED_BYTES,
BlockMasterInfoField.FREE_BYTES, BlockMasterInfoField.CAPACITY_BYTES_ON_TIERS,
BlockMasterInfoField.USED_BYTES_ON_TIERS));
BlockMasterInfo blockMasterInfo = mBlockMasterClient.getBlockMasterInfo(blockMasterInfoFilter);
print("Live Workers: " + blockMasterInfo.getLiveWorkerNum());
print("Lost Workers: " + blockMasterInfo.getLostWorkerNum());
print("Total Capacity: "
+ FormatUtils.getSizeFromBytes(blockMasterInfo.getCapacityBytes()));
mIndentationLevel++;
Map<String, Long> totalCapacityOnTiers = new TreeMap<>((a, b)
-> (FileSystemAdminShellUtils.compareTierNames(a, b)));
totalCapacityOnTiers.putAll(blockMasterInfo.getCapacityBytesOnTiers());
for (Map.Entry<String, Long> capacityBytesTier : totalCapacityOnTiers.entrySet()) {
print("Tier: " + capacityBytesTier.getKey()
+ " Size: " + FormatUtils.getSizeFromBytes(capacityBytesTier.getValue()));
}
mIndentationLevel--;
print("Used Capacity: "
+ FormatUtils.getSizeFromBytes(blockMasterInfo.getUsedBytes()));
mIndentationLevel++;
Map<String, Long> usedCapacityOnTiers = new TreeMap<>((a, b)
-> (FileSystemAdminShellUtils.compareTierNames(a, b)));
usedCapacityOnTiers.putAll(blockMasterInfo.getUsedBytesOnTiers());
for (Map.Entry<String, Long> usedBytesTier: usedCapacityOnTiers.entrySet()) {
print("Tier: " + usedBytesTier.getKey()
+ " Size: " + FormatUtils.getSizeFromBytes(usedBytesTier.getValue()));
}
mIndentationLevel--;
print("Free Capacity: "
+ FormatUtils.getSizeFromBytes(blockMasterInfo.getFreeBytes()));
}
|
[
"private",
"void",
"printBlockMasterInfo",
"(",
")",
"throws",
"IOException",
"{",
"Set",
"<",
"BlockMasterInfoField",
">",
"blockMasterInfoFilter",
"=",
"new",
"HashSet",
"<>",
"(",
"Arrays",
".",
"asList",
"(",
"BlockMasterInfoField",
".",
"LIVE_WORKER_NUM",
",",
"BlockMasterInfoField",
".",
"LOST_WORKER_NUM",
",",
"BlockMasterInfoField",
".",
"CAPACITY_BYTES",
",",
"BlockMasterInfoField",
".",
"USED_BYTES",
",",
"BlockMasterInfoField",
".",
"FREE_BYTES",
",",
"BlockMasterInfoField",
".",
"CAPACITY_BYTES_ON_TIERS",
",",
"BlockMasterInfoField",
".",
"USED_BYTES_ON_TIERS",
")",
")",
";",
"BlockMasterInfo",
"blockMasterInfo",
"=",
"mBlockMasterClient",
".",
"getBlockMasterInfo",
"(",
"blockMasterInfoFilter",
")",
";",
"print",
"(",
"\"Live Workers: \"",
"+",
"blockMasterInfo",
".",
"getLiveWorkerNum",
"(",
")",
")",
";",
"print",
"(",
"\"Lost Workers: \"",
"+",
"blockMasterInfo",
".",
"getLostWorkerNum",
"(",
")",
")",
";",
"print",
"(",
"\"Total Capacity: \"",
"+",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"blockMasterInfo",
".",
"getCapacityBytes",
"(",
")",
")",
")",
";",
"mIndentationLevel",
"++",
";",
"Map",
"<",
"String",
",",
"Long",
">",
"totalCapacityOnTiers",
"=",
"new",
"TreeMap",
"<>",
"(",
"(",
"a",
",",
"b",
")",
"->",
"(",
"FileSystemAdminShellUtils",
".",
"compareTierNames",
"(",
"a",
",",
"b",
")",
")",
")",
";",
"totalCapacityOnTiers",
".",
"putAll",
"(",
"blockMasterInfo",
".",
"getCapacityBytesOnTiers",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Long",
">",
"capacityBytesTier",
":",
"totalCapacityOnTiers",
".",
"entrySet",
"(",
")",
")",
"{",
"print",
"(",
"\"Tier: \"",
"+",
"capacityBytesTier",
".",
"getKey",
"(",
")",
"+",
"\" Size: \"",
"+",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"capacityBytesTier",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"mIndentationLevel",
"--",
";",
"print",
"(",
"\"Used Capacity: \"",
"+",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"blockMasterInfo",
".",
"getUsedBytes",
"(",
")",
")",
")",
";",
"mIndentationLevel",
"++",
";",
"Map",
"<",
"String",
",",
"Long",
">",
"usedCapacityOnTiers",
"=",
"new",
"TreeMap",
"<>",
"(",
"(",
"a",
",",
"b",
")",
"->",
"(",
"FileSystemAdminShellUtils",
".",
"compareTierNames",
"(",
"a",
",",
"b",
")",
")",
")",
";",
"usedCapacityOnTiers",
".",
"putAll",
"(",
"blockMasterInfo",
".",
"getUsedBytesOnTiers",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Long",
">",
"usedBytesTier",
":",
"usedCapacityOnTiers",
".",
"entrySet",
"(",
")",
")",
"{",
"print",
"(",
"\"Tier: \"",
"+",
"usedBytesTier",
".",
"getKey",
"(",
")",
"+",
"\" Size: \"",
"+",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"usedBytesTier",
".",
"getValue",
"(",
")",
")",
")",
";",
"}",
"mIndentationLevel",
"--",
";",
"print",
"(",
"\"Free Capacity: \"",
"+",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"blockMasterInfo",
".",
"getFreeBytes",
"(",
")",
")",
")",
";",
"}"
] |
Prints Alluxio block master information.
|
[
"Prints",
"Alluxio",
"block",
"master",
"information",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/shell/src/main/java/alluxio/cli/fsadmin/report/SummaryCommand.java#L113-L152
|
19,084
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/RetryHandlingMetaMasterMasterClient.java
|
RetryHandlingMetaMasterMasterClient.getId
|
public long getId(final Address address) throws IOException {
return retryRPC(() -> mClient
.getMasterId(GetMasterIdPRequest.newBuilder().setMasterAddress(address.toProto()).build())
.getMasterId());
}
|
java
|
public long getId(final Address address) throws IOException {
return retryRPC(() -> mClient
.getMasterId(GetMasterIdPRequest.newBuilder().setMasterAddress(address.toProto()).build())
.getMasterId());
}
|
[
"public",
"long",
"getId",
"(",
"final",
"Address",
"address",
")",
"throws",
"IOException",
"{",
"return",
"retryRPC",
"(",
"(",
")",
"->",
"mClient",
".",
"getMasterId",
"(",
"GetMasterIdPRequest",
".",
"newBuilder",
"(",
")",
".",
"setMasterAddress",
"(",
"address",
".",
"toProto",
"(",
")",
")",
".",
"build",
"(",
")",
")",
".",
"getMasterId",
"(",
")",
")",
";",
"}"
] |
Returns a master id for a master address.
@param address the address to get a master id for
@return a master id
|
[
"Returns",
"a",
"master",
"id",
"for",
"a",
"master",
"address",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/RetryHandlingMetaMasterMasterClient.java#L75-L79
|
19,085
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/RetryHandlingMetaMasterMasterClient.java
|
RetryHandlingMetaMasterMasterClient.heartbeat
|
public MetaCommand heartbeat(final long masterId) throws IOException {
return retryRPC(() -> mClient
.masterHeartbeat(MasterHeartbeatPRequest.newBuilder().setMasterId(masterId).build())
.getCommand());
}
|
java
|
public MetaCommand heartbeat(final long masterId) throws IOException {
return retryRPC(() -> mClient
.masterHeartbeat(MasterHeartbeatPRequest.newBuilder().setMasterId(masterId).build())
.getCommand());
}
|
[
"public",
"MetaCommand",
"heartbeat",
"(",
"final",
"long",
"masterId",
")",
"throws",
"IOException",
"{",
"return",
"retryRPC",
"(",
"(",
")",
"->",
"mClient",
".",
"masterHeartbeat",
"(",
"MasterHeartbeatPRequest",
".",
"newBuilder",
"(",
")",
".",
"setMasterId",
"(",
"masterId",
")",
".",
"build",
"(",
")",
")",
".",
"getCommand",
"(",
")",
")",
";",
"}"
] |
Sends a heartbeat to the leader master. Standby masters periodically execute this method
so that the leader master knows they are still running.
@param masterId the master id
@return whether this master should re-register
|
[
"Sends",
"a",
"heartbeat",
"to",
"the",
"leader",
"master",
".",
"Standby",
"masters",
"periodically",
"execute",
"this",
"method",
"so",
"that",
"the",
"leader",
"master",
"knows",
"they",
"are",
"still",
"running",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/RetryHandlingMetaMasterMasterClient.java#L88-L92
|
19,086
|
Alluxio/alluxio
|
core/server/master/src/main/java/alluxio/master/meta/RetryHandlingMetaMasterMasterClient.java
|
RetryHandlingMetaMasterMasterClient.register
|
public void register(final long masterId, final List<ConfigProperty> configList)
throws IOException {
retryRPC(() -> {
mClient.registerMaster(RegisterMasterPRequest.newBuilder().setMasterId(masterId)
.setOptions(RegisterMasterPOptions.newBuilder().addAllConfigs(configList).build())
.build());
return null;
});
}
|
java
|
public void register(final long masterId, final List<ConfigProperty> configList)
throws IOException {
retryRPC(() -> {
mClient.registerMaster(RegisterMasterPRequest.newBuilder().setMasterId(masterId)
.setOptions(RegisterMasterPOptions.newBuilder().addAllConfigs(configList).build())
.build());
return null;
});
}
|
[
"public",
"void",
"register",
"(",
"final",
"long",
"masterId",
",",
"final",
"List",
"<",
"ConfigProperty",
">",
"configList",
")",
"throws",
"IOException",
"{",
"retryRPC",
"(",
"(",
")",
"->",
"{",
"mClient",
".",
"registerMaster",
"(",
"RegisterMasterPRequest",
".",
"newBuilder",
"(",
")",
".",
"setMasterId",
"(",
"masterId",
")",
".",
"setOptions",
"(",
"RegisterMasterPOptions",
".",
"newBuilder",
"(",
")",
".",
"addAllConfigs",
"(",
"configList",
")",
".",
"build",
"(",
")",
")",
".",
"build",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
")",
";",
"}"
] |
Registers with the leader master.
@param masterId the master id of the standby master registering
@param configList the configuration of this master
|
[
"Registers",
"with",
"the",
"leader",
"master",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/master/src/main/java/alluxio/master/meta/RetryHandlingMetaMasterMasterClient.java#L100-L108
|
19,087
|
Alluxio/alluxio
|
core/common/src/main/java/alluxio/security/group/provider/ShellBasedUnixGroupsMapping.java
|
ShellBasedUnixGroupsMapping.getGroups
|
@Override
public List<String> getGroups(String user) throws IOException {
List<String> groups = CommonUtils.getUnixGroups(user);
// remove duplicated primary group
return new ArrayList<>(new LinkedHashSet<>(groups));
}
|
java
|
@Override
public List<String> getGroups(String user) throws IOException {
List<String> groups = CommonUtils.getUnixGroups(user);
// remove duplicated primary group
return new ArrayList<>(new LinkedHashSet<>(groups));
}
|
[
"@",
"Override",
"public",
"List",
"<",
"String",
">",
"getGroups",
"(",
"String",
"user",
")",
"throws",
"IOException",
"{",
"List",
"<",
"String",
">",
"groups",
"=",
"CommonUtils",
".",
"getUnixGroups",
"(",
"user",
")",
";",
"// remove duplicated primary group",
"return",
"new",
"ArrayList",
"<>",
"(",
"new",
"LinkedHashSet",
"<>",
"(",
"groups",
")",
")",
";",
"}"
] |
Returns list of groups for a user.
@param user get groups for this user
@return list of groups for a given user
|
[
"Returns",
"list",
"of",
"groups",
"for",
"a",
"user",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/common/src/main/java/alluxio/security/group/provider/ShellBasedUnixGroupsMapping.java#L39-L44
|
19,088
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/AlluxioWorkerRestServiceHandler.java
|
AlluxioWorkerRestServiceHandler.getWebUIOverview
|
@GET
@Path(WEBUI_OVERVIEW)
@ReturnType("alluxio.wire.WorkerWebUIOverview")
public Response getWebUIOverview() {
return RestUtils.call(() -> {
WorkerWebUIOverview response = new WorkerWebUIOverview();
response.setWorkerInfo(new UIWorkerInfo(mWorkerProcess.getRpcAddress().toString(),
mWorkerProcess.getStartTimeMs(),
ServerConfiguration.get(PropertyKey.USER_DATE_FORMAT_PATTERN)));
BlockStoreMeta storeMeta = mBlockWorker.getStoreMeta();
long capacityBytes = 0L;
long usedBytes = 0L;
Map<String, Long> capacityBytesOnTiers = storeMeta.getCapacityBytesOnTiers();
Map<String, Long> usedBytesOnTiers = storeMeta.getUsedBytesOnTiers();
List<UIUsageOnTier> usageOnTiers = new ArrayList<>();
for (Map.Entry<String, Long> entry : capacityBytesOnTiers.entrySet()) {
String tier = entry.getKey();
long capacity = entry.getValue();
Long nullableUsed = usedBytesOnTiers.get(tier);
long used = nullableUsed == null ? 0 : nullableUsed;
capacityBytes += capacity;
usedBytes += used;
usageOnTiers.add(new UIUsageOnTier(tier, capacity, used));
}
response.setCapacityBytes(FormatUtils.getSizeFromBytes(capacityBytes))
.setUsedBytes(FormatUtils.getSizeFromBytes(usedBytes)).setUsageOnTiers(usageOnTiers)
.setVersion(RuntimeConstants.VERSION);
List<UIStorageDir> storageDirs = new ArrayList<>(storeMeta.getCapacityBytesOnDirs().size());
for (Pair<String, String> tierAndDirPath : storeMeta.getCapacityBytesOnDirs().keySet()) {
storageDirs.add(new UIStorageDir(tierAndDirPath.getFirst(), tierAndDirPath.getSecond(),
storeMeta.getCapacityBytesOnDirs().get(tierAndDirPath),
storeMeta.getUsedBytesOnDirs().get(tierAndDirPath)));
}
response.setStorageDirs(storageDirs);
return response;
}, ServerConfiguration.global());
}
|
java
|
@GET
@Path(WEBUI_OVERVIEW)
@ReturnType("alluxio.wire.WorkerWebUIOverview")
public Response getWebUIOverview() {
return RestUtils.call(() -> {
WorkerWebUIOverview response = new WorkerWebUIOverview();
response.setWorkerInfo(new UIWorkerInfo(mWorkerProcess.getRpcAddress().toString(),
mWorkerProcess.getStartTimeMs(),
ServerConfiguration.get(PropertyKey.USER_DATE_FORMAT_PATTERN)));
BlockStoreMeta storeMeta = mBlockWorker.getStoreMeta();
long capacityBytes = 0L;
long usedBytes = 0L;
Map<String, Long> capacityBytesOnTiers = storeMeta.getCapacityBytesOnTiers();
Map<String, Long> usedBytesOnTiers = storeMeta.getUsedBytesOnTiers();
List<UIUsageOnTier> usageOnTiers = new ArrayList<>();
for (Map.Entry<String, Long> entry : capacityBytesOnTiers.entrySet()) {
String tier = entry.getKey();
long capacity = entry.getValue();
Long nullableUsed = usedBytesOnTiers.get(tier);
long used = nullableUsed == null ? 0 : nullableUsed;
capacityBytes += capacity;
usedBytes += used;
usageOnTiers.add(new UIUsageOnTier(tier, capacity, used));
}
response.setCapacityBytes(FormatUtils.getSizeFromBytes(capacityBytes))
.setUsedBytes(FormatUtils.getSizeFromBytes(usedBytes)).setUsageOnTiers(usageOnTiers)
.setVersion(RuntimeConstants.VERSION);
List<UIStorageDir> storageDirs = new ArrayList<>(storeMeta.getCapacityBytesOnDirs().size());
for (Pair<String, String> tierAndDirPath : storeMeta.getCapacityBytesOnDirs().keySet()) {
storageDirs.add(new UIStorageDir(tierAndDirPath.getFirst(), tierAndDirPath.getSecond(),
storeMeta.getCapacityBytesOnDirs().get(tierAndDirPath),
storeMeta.getUsedBytesOnDirs().get(tierAndDirPath)));
}
response.setStorageDirs(storageDirs);
return response;
}, ServerConfiguration.global());
}
|
[
"@",
"GET",
"@",
"Path",
"(",
"WEBUI_OVERVIEW",
")",
"@",
"ReturnType",
"(",
"\"alluxio.wire.WorkerWebUIOverview\"",
")",
"public",
"Response",
"getWebUIOverview",
"(",
")",
"{",
"return",
"RestUtils",
".",
"call",
"(",
"(",
")",
"->",
"{",
"WorkerWebUIOverview",
"response",
"=",
"new",
"WorkerWebUIOverview",
"(",
")",
";",
"response",
".",
"setWorkerInfo",
"(",
"new",
"UIWorkerInfo",
"(",
"mWorkerProcess",
".",
"getRpcAddress",
"(",
")",
".",
"toString",
"(",
")",
",",
"mWorkerProcess",
".",
"getStartTimeMs",
"(",
")",
",",
"ServerConfiguration",
".",
"get",
"(",
"PropertyKey",
".",
"USER_DATE_FORMAT_PATTERN",
")",
")",
")",
";",
"BlockStoreMeta",
"storeMeta",
"=",
"mBlockWorker",
".",
"getStoreMeta",
"(",
")",
";",
"long",
"capacityBytes",
"=",
"0L",
";",
"long",
"usedBytes",
"=",
"0L",
";",
"Map",
"<",
"String",
",",
"Long",
">",
"capacityBytesOnTiers",
"=",
"storeMeta",
".",
"getCapacityBytesOnTiers",
"(",
")",
";",
"Map",
"<",
"String",
",",
"Long",
">",
"usedBytesOnTiers",
"=",
"storeMeta",
".",
"getUsedBytesOnTiers",
"(",
")",
";",
"List",
"<",
"UIUsageOnTier",
">",
"usageOnTiers",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Long",
">",
"entry",
":",
"capacityBytesOnTiers",
".",
"entrySet",
"(",
")",
")",
"{",
"String",
"tier",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"long",
"capacity",
"=",
"entry",
".",
"getValue",
"(",
")",
";",
"Long",
"nullableUsed",
"=",
"usedBytesOnTiers",
".",
"get",
"(",
"tier",
")",
";",
"long",
"used",
"=",
"nullableUsed",
"==",
"null",
"?",
"0",
":",
"nullableUsed",
";",
"capacityBytes",
"+=",
"capacity",
";",
"usedBytes",
"+=",
"used",
";",
"usageOnTiers",
".",
"add",
"(",
"new",
"UIUsageOnTier",
"(",
"tier",
",",
"capacity",
",",
"used",
")",
")",
";",
"}",
"response",
".",
"setCapacityBytes",
"(",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"capacityBytes",
")",
")",
".",
"setUsedBytes",
"(",
"FormatUtils",
".",
"getSizeFromBytes",
"(",
"usedBytes",
")",
")",
".",
"setUsageOnTiers",
"(",
"usageOnTiers",
")",
".",
"setVersion",
"(",
"RuntimeConstants",
".",
"VERSION",
")",
";",
"List",
"<",
"UIStorageDir",
">",
"storageDirs",
"=",
"new",
"ArrayList",
"<>",
"(",
"storeMeta",
".",
"getCapacityBytesOnDirs",
"(",
")",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Pair",
"<",
"String",
",",
"String",
">",
"tierAndDirPath",
":",
"storeMeta",
".",
"getCapacityBytesOnDirs",
"(",
")",
".",
"keySet",
"(",
")",
")",
"{",
"storageDirs",
".",
"add",
"(",
"new",
"UIStorageDir",
"(",
"tierAndDirPath",
".",
"getFirst",
"(",
")",
",",
"tierAndDirPath",
".",
"getSecond",
"(",
")",
",",
"storeMeta",
".",
"getCapacityBytesOnDirs",
"(",
")",
".",
"get",
"(",
"tierAndDirPath",
")",
",",
"storeMeta",
".",
"getUsedBytesOnDirs",
"(",
")",
".",
"get",
"(",
"tierAndDirPath",
")",
")",
")",
";",
"}",
"response",
".",
"setStorageDirs",
"(",
"storageDirs",
")",
";",
"return",
"response",
";",
"}",
",",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
";",
"}"
] |
Gets web ui overview page data.
@return the response object
|
[
"Gets",
"web",
"ui",
"overview",
"page",
"data",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/AlluxioWorkerRestServiceHandler.java#L208-L252
|
19,089
|
Alluxio/alluxio
|
core/server/worker/src/main/java/alluxio/worker/AlluxioWorkerRestServiceHandler.java
|
AlluxioWorkerRestServiceHandler.getWebUIMetrics
|
@GET
@Path(WEBUI_METRICS)
@ReturnType("alluxio.wire.WorkerWebUIMetrics")
public Response getWebUIMetrics() {
return RestUtils.call(() -> {
WorkerWebUIMetrics response = new WorkerWebUIMetrics();
MetricRegistry mr = MetricsSystem.METRIC_REGISTRY;
Long workerCapacityTotal = (Long) mr.getGauges()
.get(MetricsSystem.getMetricName(DefaultBlockWorker.Metrics.CAPACITY_TOTAL)).getValue();
Long workerCapacityUsed = (Long) mr.getGauges()
.get(MetricsSystem.getMetricName(DefaultBlockWorker.Metrics.CAPACITY_USED)).getValue();
int workerCapacityUsedPercentage =
(workerCapacityTotal > 0) ? (int) (100L * workerCapacityUsed / workerCapacityTotal) : 0;
response.setWorkerCapacityUsedPercentage(workerCapacityUsedPercentage);
response.setWorkerCapacityFreePercentage(100 - workerCapacityUsedPercentage);
Map<String, Counter> counters = mr.getCounters(new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
return !(name.endsWith("Ops"));
}
});
Map<String, Counter> rpcInvocations = mr.getCounters(new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
return name.endsWith("Ops");
}
});
Map<String, Metric> operations = new TreeMap<>();
// Remove the instance name from the metrics.
for (Map.Entry<String, Counter> entry : counters.entrySet()) {
operations.put(MetricsSystem.stripInstanceAndHost(entry.getKey()), entry.getValue());
}
String filesPinnedProperty = MetricsSystem.getMetricName(MasterMetrics.FILES_PINNED);
operations.put(MetricsSystem.stripInstanceAndHost(filesPinnedProperty),
mr.getGauges().get(filesPinnedProperty));
response.setOperationMetrics(operations);
Map<String, Counter> rpcInvocationsUpdated = new TreeMap<>();
for (Map.Entry<String, Counter> entry : rpcInvocations.entrySet()) {
rpcInvocationsUpdated
.put(MetricsSystem.stripInstanceAndHost(entry.getKey()), entry.getValue());
}
response.setRpcInvocationMetrics(rpcInvocations);
return response;
}, ServerConfiguration.global());
}
|
java
|
@GET
@Path(WEBUI_METRICS)
@ReturnType("alluxio.wire.WorkerWebUIMetrics")
public Response getWebUIMetrics() {
return RestUtils.call(() -> {
WorkerWebUIMetrics response = new WorkerWebUIMetrics();
MetricRegistry mr = MetricsSystem.METRIC_REGISTRY;
Long workerCapacityTotal = (Long) mr.getGauges()
.get(MetricsSystem.getMetricName(DefaultBlockWorker.Metrics.CAPACITY_TOTAL)).getValue();
Long workerCapacityUsed = (Long) mr.getGauges()
.get(MetricsSystem.getMetricName(DefaultBlockWorker.Metrics.CAPACITY_USED)).getValue();
int workerCapacityUsedPercentage =
(workerCapacityTotal > 0) ? (int) (100L * workerCapacityUsed / workerCapacityTotal) : 0;
response.setWorkerCapacityUsedPercentage(workerCapacityUsedPercentage);
response.setWorkerCapacityFreePercentage(100 - workerCapacityUsedPercentage);
Map<String, Counter> counters = mr.getCounters(new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
return !(name.endsWith("Ops"));
}
});
Map<String, Counter> rpcInvocations = mr.getCounters(new MetricFilter() {
@Override
public boolean matches(String name, Metric metric) {
return name.endsWith("Ops");
}
});
Map<String, Metric> operations = new TreeMap<>();
// Remove the instance name from the metrics.
for (Map.Entry<String, Counter> entry : counters.entrySet()) {
operations.put(MetricsSystem.stripInstanceAndHost(entry.getKey()), entry.getValue());
}
String filesPinnedProperty = MetricsSystem.getMetricName(MasterMetrics.FILES_PINNED);
operations.put(MetricsSystem.stripInstanceAndHost(filesPinnedProperty),
mr.getGauges().get(filesPinnedProperty));
response.setOperationMetrics(operations);
Map<String, Counter> rpcInvocationsUpdated = new TreeMap<>();
for (Map.Entry<String, Counter> entry : rpcInvocations.entrySet()) {
rpcInvocationsUpdated
.put(MetricsSystem.stripInstanceAndHost(entry.getKey()), entry.getValue());
}
response.setRpcInvocationMetrics(rpcInvocations);
return response;
}, ServerConfiguration.global());
}
|
[
"@",
"GET",
"@",
"Path",
"(",
"WEBUI_METRICS",
")",
"@",
"ReturnType",
"(",
"\"alluxio.wire.WorkerWebUIMetrics\"",
")",
"public",
"Response",
"getWebUIMetrics",
"(",
")",
"{",
"return",
"RestUtils",
".",
"call",
"(",
"(",
")",
"->",
"{",
"WorkerWebUIMetrics",
"response",
"=",
"new",
"WorkerWebUIMetrics",
"(",
")",
";",
"MetricRegistry",
"mr",
"=",
"MetricsSystem",
".",
"METRIC_REGISTRY",
";",
"Long",
"workerCapacityTotal",
"=",
"(",
"Long",
")",
"mr",
".",
"getGauges",
"(",
")",
".",
"get",
"(",
"MetricsSystem",
".",
"getMetricName",
"(",
"DefaultBlockWorker",
".",
"Metrics",
".",
"CAPACITY_TOTAL",
")",
")",
".",
"getValue",
"(",
")",
";",
"Long",
"workerCapacityUsed",
"=",
"(",
"Long",
")",
"mr",
".",
"getGauges",
"(",
")",
".",
"get",
"(",
"MetricsSystem",
".",
"getMetricName",
"(",
"DefaultBlockWorker",
".",
"Metrics",
".",
"CAPACITY_USED",
")",
")",
".",
"getValue",
"(",
")",
";",
"int",
"workerCapacityUsedPercentage",
"=",
"(",
"workerCapacityTotal",
">",
"0",
")",
"?",
"(",
"int",
")",
"(",
"100L",
"*",
"workerCapacityUsed",
"/",
"workerCapacityTotal",
")",
":",
"0",
";",
"response",
".",
"setWorkerCapacityUsedPercentage",
"(",
"workerCapacityUsedPercentage",
")",
";",
"response",
".",
"setWorkerCapacityFreePercentage",
"(",
"100",
"-",
"workerCapacityUsedPercentage",
")",
";",
"Map",
"<",
"String",
",",
"Counter",
">",
"counters",
"=",
"mr",
".",
"getCounters",
"(",
"new",
"MetricFilter",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"matches",
"(",
"String",
"name",
",",
"Metric",
"metric",
")",
"{",
"return",
"!",
"(",
"name",
".",
"endsWith",
"(",
"\"Ops\"",
")",
")",
";",
"}",
"}",
")",
";",
"Map",
"<",
"String",
",",
"Counter",
">",
"rpcInvocations",
"=",
"mr",
".",
"getCounters",
"(",
"new",
"MetricFilter",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"matches",
"(",
"String",
"name",
",",
"Metric",
"metric",
")",
"{",
"return",
"name",
".",
"endsWith",
"(",
"\"Ops\"",
")",
";",
"}",
"}",
")",
";",
"Map",
"<",
"String",
",",
"Metric",
">",
"operations",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"// Remove the instance name from the metrics.",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Counter",
">",
"entry",
":",
"counters",
".",
"entrySet",
"(",
")",
")",
"{",
"operations",
".",
"put",
"(",
"MetricsSystem",
".",
"stripInstanceAndHost",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"String",
"filesPinnedProperty",
"=",
"MetricsSystem",
".",
"getMetricName",
"(",
"MasterMetrics",
".",
"FILES_PINNED",
")",
";",
"operations",
".",
"put",
"(",
"MetricsSystem",
".",
"stripInstanceAndHost",
"(",
"filesPinnedProperty",
")",
",",
"mr",
".",
"getGauges",
"(",
")",
".",
"get",
"(",
"filesPinnedProperty",
")",
")",
";",
"response",
".",
"setOperationMetrics",
"(",
"operations",
")",
";",
"Map",
"<",
"String",
",",
"Counter",
">",
"rpcInvocationsUpdated",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"Counter",
">",
"entry",
":",
"rpcInvocations",
".",
"entrySet",
"(",
")",
")",
"{",
"rpcInvocationsUpdated",
".",
"put",
"(",
"MetricsSystem",
".",
"stripInstanceAndHost",
"(",
"entry",
".",
"getKey",
"(",
")",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"response",
".",
"setRpcInvocationMetrics",
"(",
"rpcInvocations",
")",
";",
"return",
"response",
";",
"}",
",",
"ServerConfiguration",
".",
"global",
"(",
")",
")",
";",
"}"
] |
Gets web ui metrics page data.
@return the response object
|
[
"Gets",
"web",
"ui",
"metrics",
"page",
"data",
"."
] |
af38cf3ab44613355b18217a3a4d961f8fec3a10
|
https://github.com/Alluxio/alluxio/blob/af38cf3ab44613355b18217a3a4d961f8fec3a10/core/server/worker/src/main/java/alluxio/worker/AlluxioWorkerRestServiceHandler.java#L372-L427
|
19,090
|
languagetool-org/languagetool
|
languagetool-core/src/main/java/org/languagetool/rules/patterns/RuleFilterEvaluator.java
|
RuleFilterEvaluator.getSkipCorrectedReference
|
private int getSkipCorrectedReference(List<Integer> tokenPositions, int refNumber) {
int correctedRef = 0;
int i = 0;
for (int tokenPosition : tokenPositions) {
if (i++ >= refNumber) {
break;
}
correctedRef += tokenPosition;
}
return correctedRef - 1;
}
|
java
|
private int getSkipCorrectedReference(List<Integer> tokenPositions, int refNumber) {
int correctedRef = 0;
int i = 0;
for (int tokenPosition : tokenPositions) {
if (i++ >= refNumber) {
break;
}
correctedRef += tokenPosition;
}
return correctedRef - 1;
}
|
[
"private",
"int",
"getSkipCorrectedReference",
"(",
"List",
"<",
"Integer",
">",
"tokenPositions",
",",
"int",
"refNumber",
")",
"{",
"int",
"correctedRef",
"=",
"0",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"int",
"tokenPosition",
":",
"tokenPositions",
")",
"{",
"if",
"(",
"i",
"++",
">=",
"refNumber",
")",
"{",
"break",
";",
"}",
"correctedRef",
"+=",
"tokenPosition",
";",
"}",
"return",
"correctedRef",
"-",
"1",
";",
"}"
] |
when there's a 'skip', we need to adapt the reference number
|
[
"when",
"there",
"s",
"a",
"skip",
"we",
"need",
"to",
"adapt",
"the",
"reference",
"number"
] |
b7a3d63883d242fb2525877c6382681c57a0a142
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/rules/patterns/RuleFilterEvaluator.java#L80-L90
|
19,091
|
languagetool-org/languagetool
|
languagetool-core/src/main/java/org/languagetool/rules/RuleMatch.java
|
RuleMatch.compareTo
|
@Override
public int compareTo(RuleMatch other) {
Objects.requireNonNull(other);
return Integer.compare(getFromPos(), other.getFromPos());
}
|
java
|
@Override
public int compareTo(RuleMatch other) {
Objects.requireNonNull(other);
return Integer.compare(getFromPos(), other.getFromPos());
}
|
[
"@",
"Override",
"public",
"int",
"compareTo",
"(",
"RuleMatch",
"other",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"other",
")",
";",
"return",
"Integer",
".",
"compare",
"(",
"getFromPos",
"(",
")",
",",
"other",
".",
"getFromPos",
"(",
")",
")",
";",
"}"
] |
Compare by start position.
|
[
"Compare",
"by",
"start",
"position",
"."
] |
b7a3d63883d242fb2525877c6382681c57a0a142
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/rules/RuleMatch.java#L369-L373
|
19,092
|
languagetool-org/languagetool
|
languagetool-language-modules/ca/src/main/java/org/languagetool/rules/ca/MorfologikCatalanSpellerRule.java
|
MorfologikCatalanSpellerRule.matchPostagRegexp
|
private boolean matchPostagRegexp(AnalyzedTokenReadings aToken, Pattern pattern) {
for (AnalyzedToken analyzedToken : aToken) {
String posTag = analyzedToken.getPOSTag();
if (posTag == null) {
posTag = "UNKNOWN";
}
final Matcher m = pattern.matcher(posTag);
if (m.matches()) {
return true;
}
}
return false;
}
|
java
|
private boolean matchPostagRegexp(AnalyzedTokenReadings aToken, Pattern pattern) {
for (AnalyzedToken analyzedToken : aToken) {
String posTag = analyzedToken.getPOSTag();
if (posTag == null) {
posTag = "UNKNOWN";
}
final Matcher m = pattern.matcher(posTag);
if (m.matches()) {
return true;
}
}
return false;
}
|
[
"private",
"boolean",
"matchPostagRegexp",
"(",
"AnalyzedTokenReadings",
"aToken",
",",
"Pattern",
"pattern",
")",
"{",
"for",
"(",
"AnalyzedToken",
"analyzedToken",
":",
"aToken",
")",
"{",
"String",
"posTag",
"=",
"analyzedToken",
".",
"getPOSTag",
"(",
")",
";",
"if",
"(",
"posTag",
"==",
"null",
")",
"{",
"posTag",
"=",
"\"UNKNOWN\"",
";",
"}",
"final",
"Matcher",
"m",
"=",
"pattern",
".",
"matcher",
"(",
"posTag",
")",
";",
"if",
"(",
"m",
".",
"matches",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Match POS tag with regular expression
|
[
"Match",
"POS",
"tag",
"with",
"regular",
"expression"
] |
b7a3d63883d242fb2525877c6382681c57a0a142
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-language-modules/ca/src/main/java/org/languagetool/rules/ca/MorfologikCatalanSpellerRule.java#L140-L152
|
19,093
|
languagetool-org/languagetool
|
languagetool-core/src/main/java/org/languagetool/Languages.java
|
Languages.getLanguageForName
|
@Nullable
public static Language getLanguageForName(String languageName) {
for (Language element : getStaticAndDynamicLanguages()) {
if (languageName.equals(element.getName())) {
return element;
}
}
return null;
}
|
java
|
@Nullable
public static Language getLanguageForName(String languageName) {
for (Language element : getStaticAndDynamicLanguages()) {
if (languageName.equals(element.getName())) {
return element;
}
}
return null;
}
|
[
"@",
"Nullable",
"public",
"static",
"Language",
"getLanguageForName",
"(",
"String",
"languageName",
")",
"{",
"for",
"(",
"Language",
"element",
":",
"getStaticAndDynamicLanguages",
"(",
")",
")",
"{",
"if",
"(",
"languageName",
".",
"equals",
"(",
"element",
".",
"getName",
"(",
")",
")",
")",
"{",
"return",
"element",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get the Language object for the given language name.
@param languageName e.g. <code>English</code> or <code>German</code> (case is significant)
@return a Language object or {@code null} if there is no such language
|
[
"Get",
"the",
"Language",
"object",
"for",
"the",
"given",
"language",
"name",
"."
] |
b7a3d63883d242fb2525877c6382681c57a0a142
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/Languages.java#L197-L205
|
19,094
|
languagetool-org/languagetool
|
languagetool-core/src/main/java/org/languagetool/Languages.java
|
Languages.getLanguageForShortCode
|
public static Language getLanguageForShortCode(String langCode, List<String> noopLanguageCodes) {
Language language = getLanguageForShortCodeOrNull(langCode);
if (language == null) {
if (noopLanguageCodes.contains(langCode)) {
return NOOP_LANGUAGE;
} else {
List<String> codes = new ArrayList<>();
for (Language realLanguage : getStaticAndDynamicLanguages()) {
codes.add(realLanguage.getShortCodeWithCountryAndVariant());
}
Collections.sort(codes);
throw new IllegalArgumentException("'" + langCode + "' is not a language code known to LanguageTool." +
" Supported language codes are: " + String.join(", ", codes) + ". The list of languages is read from " + PROPERTIES_PATH +
" in the Java classpath. See http://wiki.languagetool.org/java-api for details.");
}
}
return language;
}
|
java
|
public static Language getLanguageForShortCode(String langCode, List<String> noopLanguageCodes) {
Language language = getLanguageForShortCodeOrNull(langCode);
if (language == null) {
if (noopLanguageCodes.contains(langCode)) {
return NOOP_LANGUAGE;
} else {
List<String> codes = new ArrayList<>();
for (Language realLanguage : getStaticAndDynamicLanguages()) {
codes.add(realLanguage.getShortCodeWithCountryAndVariant());
}
Collections.sort(codes);
throw new IllegalArgumentException("'" + langCode + "' is not a language code known to LanguageTool." +
" Supported language codes are: " + String.join(", ", codes) + ". The list of languages is read from " + PROPERTIES_PATH +
" in the Java classpath. See http://wiki.languagetool.org/java-api for details.");
}
}
return language;
}
|
[
"public",
"static",
"Language",
"getLanguageForShortCode",
"(",
"String",
"langCode",
",",
"List",
"<",
"String",
">",
"noopLanguageCodes",
")",
"{",
"Language",
"language",
"=",
"getLanguageForShortCodeOrNull",
"(",
"langCode",
")",
";",
"if",
"(",
"language",
"==",
"null",
")",
"{",
"if",
"(",
"noopLanguageCodes",
".",
"contains",
"(",
"langCode",
")",
")",
"{",
"return",
"NOOP_LANGUAGE",
";",
"}",
"else",
"{",
"List",
"<",
"String",
">",
"codes",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"Language",
"realLanguage",
":",
"getStaticAndDynamicLanguages",
"(",
")",
")",
"{",
"codes",
".",
"add",
"(",
"realLanguage",
".",
"getShortCodeWithCountryAndVariant",
"(",
")",
")",
";",
"}",
"Collections",
".",
"sort",
"(",
"codes",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"'\"",
"+",
"langCode",
"+",
"\"' is not a language code known to LanguageTool.\"",
"+",
"\" Supported language codes are: \"",
"+",
"String",
".",
"join",
"(",
"\", \"",
",",
"codes",
")",
"+",
"\". The list of languages is read from \"",
"+",
"PROPERTIES_PATH",
"+",
"\" in the Java classpath. See http://wiki.languagetool.org/java-api for details.\"",
")",
";",
"}",
"}",
"return",
"language",
";",
"}"
] |
Get the Language object for the given language code.
@param langCode e.g. <code>en</code> or <code>en-US</code>
@param noopLanguageCodes list of languages that can be detected but that will not actually find any errors
(can be used so non-supported languages are not detected as some other language)
@throws IllegalArgumentException if the language is not supported or if the language code is invalid
@since 4.4
|
[
"Get",
"the",
"Language",
"object",
"for",
"the",
"given",
"language",
"code",
"."
] |
b7a3d63883d242fb2525877c6382681c57a0a142
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/Languages.java#L225-L242
|
19,095
|
languagetool-org/languagetool
|
languagetool-core/src/main/java/org/languagetool/rules/patterns/Unifier.java
|
Unifier.isSatisfied
|
protected final boolean isSatisfied(AnalyzedToken aToken,
Map<String, List<String>> uFeatures) {
if (allFeatsIn && equivalencesMatched.isEmpty()) {
return false;
}
if (uFeatures == null) {
throw new RuntimeException("isSatisfied called without features being set");
}
unificationFeats = uFeatures;
boolean unified = true;
if (allFeatsIn) {
unified = checkNext(aToken, uFeatures);
} else {
while (equivalencesMatched.size() <= tokCnt) {
equivalencesMatched.add(new ConcurrentHashMap<>());
}
for (Map.Entry<String, List<String>> feat : uFeatures.entrySet()) {
List<String> types = feat.getValue();
if (types == null || types.isEmpty()) {
types = equivalenceFeatures.get(feat.getKey());
}
for (String typeName : types) {
PatternToken testElem = equivalenceTypes
.get(new EquivalenceTypeLocator(feat.getKey(), typeName));
if (testElem == null) {
return false;
}
if (testElem.isMatched(aToken)) {
if (!equivalencesMatched.get(tokCnt).containsKey(feat.getKey())) {
Set<String> typeSet = new HashSet<>();
typeSet.add(typeName);
equivalencesMatched.get(tokCnt).put(feat.getKey(), typeSet);
} else {
equivalencesMatched.get(tokCnt).get(feat.getKey()).add(typeName);
}
}
}
unified = equivalencesMatched.get(tokCnt).containsKey(feat.getKey());
if (!unified) {
equivalencesMatched.remove(tokCnt);
break;
}
}
if (unified) {
if (tokCnt == 0 || tokSequence.isEmpty()) {
tokSequence.add(new AnalyzedTokenReadings(aToken, 0));
List<Map<String, Set<String>>> equivList = new ArrayList<>();
equivList.add(equivalencesMatched.get(tokCnt));
tokSequenceEquivalences.add(equivList);
} else {
tokSequence.get(0).addReading(aToken);
tokSequenceEquivalences.get(0).add(equivalencesMatched.get(tokCnt));
}
tokCnt++;
}
}
return unified;
}
|
java
|
protected final boolean isSatisfied(AnalyzedToken aToken,
Map<String, List<String>> uFeatures) {
if (allFeatsIn && equivalencesMatched.isEmpty()) {
return false;
}
if (uFeatures == null) {
throw new RuntimeException("isSatisfied called without features being set");
}
unificationFeats = uFeatures;
boolean unified = true;
if (allFeatsIn) {
unified = checkNext(aToken, uFeatures);
} else {
while (equivalencesMatched.size() <= tokCnt) {
equivalencesMatched.add(new ConcurrentHashMap<>());
}
for (Map.Entry<String, List<String>> feat : uFeatures.entrySet()) {
List<String> types = feat.getValue();
if (types == null || types.isEmpty()) {
types = equivalenceFeatures.get(feat.getKey());
}
for (String typeName : types) {
PatternToken testElem = equivalenceTypes
.get(new EquivalenceTypeLocator(feat.getKey(), typeName));
if (testElem == null) {
return false;
}
if (testElem.isMatched(aToken)) {
if (!equivalencesMatched.get(tokCnt).containsKey(feat.getKey())) {
Set<String> typeSet = new HashSet<>();
typeSet.add(typeName);
equivalencesMatched.get(tokCnt).put(feat.getKey(), typeSet);
} else {
equivalencesMatched.get(tokCnt).get(feat.getKey()).add(typeName);
}
}
}
unified = equivalencesMatched.get(tokCnt).containsKey(feat.getKey());
if (!unified) {
equivalencesMatched.remove(tokCnt);
break;
}
}
if (unified) {
if (tokCnt == 0 || tokSequence.isEmpty()) {
tokSequence.add(new AnalyzedTokenReadings(aToken, 0));
List<Map<String, Set<String>>> equivList = new ArrayList<>();
equivList.add(equivalencesMatched.get(tokCnt));
tokSequenceEquivalences.add(equivList);
} else {
tokSequence.get(0).addReading(aToken);
tokSequenceEquivalences.get(0).add(equivalencesMatched.get(tokCnt));
}
tokCnt++;
}
}
return unified;
}
|
[
"protected",
"final",
"boolean",
"isSatisfied",
"(",
"AnalyzedToken",
"aToken",
",",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"uFeatures",
")",
"{",
"if",
"(",
"allFeatsIn",
"&&",
"equivalencesMatched",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"uFeatures",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"isSatisfied called without features being set\"",
")",
";",
"}",
"unificationFeats",
"=",
"uFeatures",
";",
"boolean",
"unified",
"=",
"true",
";",
"if",
"(",
"allFeatsIn",
")",
"{",
"unified",
"=",
"checkNext",
"(",
"aToken",
",",
"uFeatures",
")",
";",
"}",
"else",
"{",
"while",
"(",
"equivalencesMatched",
".",
"size",
"(",
")",
"<=",
"tokCnt",
")",
"{",
"equivalencesMatched",
".",
"add",
"(",
"new",
"ConcurrentHashMap",
"<>",
"(",
")",
")",
";",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"feat",
":",
"uFeatures",
".",
"entrySet",
"(",
")",
")",
"{",
"List",
"<",
"String",
">",
"types",
"=",
"feat",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"types",
"==",
"null",
"||",
"types",
".",
"isEmpty",
"(",
")",
")",
"{",
"types",
"=",
"equivalenceFeatures",
".",
"get",
"(",
"feat",
".",
"getKey",
"(",
")",
")",
";",
"}",
"for",
"(",
"String",
"typeName",
":",
"types",
")",
"{",
"PatternToken",
"testElem",
"=",
"equivalenceTypes",
".",
"get",
"(",
"new",
"EquivalenceTypeLocator",
"(",
"feat",
".",
"getKey",
"(",
")",
",",
"typeName",
")",
")",
";",
"if",
"(",
"testElem",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"testElem",
".",
"isMatched",
"(",
"aToken",
")",
")",
"{",
"if",
"(",
"!",
"equivalencesMatched",
".",
"get",
"(",
"tokCnt",
")",
".",
"containsKey",
"(",
"feat",
".",
"getKey",
"(",
")",
")",
")",
"{",
"Set",
"<",
"String",
">",
"typeSet",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"typeSet",
".",
"add",
"(",
"typeName",
")",
";",
"equivalencesMatched",
".",
"get",
"(",
"tokCnt",
")",
".",
"put",
"(",
"feat",
".",
"getKey",
"(",
")",
",",
"typeSet",
")",
";",
"}",
"else",
"{",
"equivalencesMatched",
".",
"get",
"(",
"tokCnt",
")",
".",
"get",
"(",
"feat",
".",
"getKey",
"(",
")",
")",
".",
"add",
"(",
"typeName",
")",
";",
"}",
"}",
"}",
"unified",
"=",
"equivalencesMatched",
".",
"get",
"(",
"tokCnt",
")",
".",
"containsKey",
"(",
"feat",
".",
"getKey",
"(",
")",
")",
";",
"if",
"(",
"!",
"unified",
")",
"{",
"equivalencesMatched",
".",
"remove",
"(",
"tokCnt",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"unified",
")",
"{",
"if",
"(",
"tokCnt",
"==",
"0",
"||",
"tokSequence",
".",
"isEmpty",
"(",
")",
")",
"{",
"tokSequence",
".",
"add",
"(",
"new",
"AnalyzedTokenReadings",
"(",
"aToken",
",",
"0",
")",
")",
";",
"List",
"<",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
">",
"equivList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"equivList",
".",
"add",
"(",
"equivalencesMatched",
".",
"get",
"(",
"tokCnt",
")",
")",
";",
"tokSequenceEquivalences",
".",
"add",
"(",
"equivList",
")",
";",
"}",
"else",
"{",
"tokSequence",
".",
"get",
"(",
"0",
")",
".",
"addReading",
"(",
"aToken",
")",
";",
"tokSequenceEquivalences",
".",
"get",
"(",
"0",
")",
".",
"add",
"(",
"equivalencesMatched",
".",
"get",
"(",
"tokCnt",
")",
")",
";",
"}",
"tokCnt",
"++",
";",
"}",
"}",
"return",
"unified",
";",
"}"
] |
Tests if a token has shared features with other tokens.
@param aToken token to be tested
@param uFeatures features to be tested
@return true if the token shares this type of feature with other tokens
|
[
"Tests",
"if",
"a",
"token",
"has",
"shared",
"features",
"with",
"other",
"tokens",
"."
] |
b7a3d63883d242fb2525877c6382681c57a0a142
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/rules/patterns/Unifier.java#L107-L166
|
19,096
|
languagetool-org/languagetool
|
languagetool-core/src/main/java/org/languagetool/rules/patterns/Unifier.java
|
Unifier.startUnify
|
public final void startUnify() {
allFeatsIn = true;
for (int i = 0; i < tokCnt; i++) {
featuresFound.add(false);
}
tmpFeaturesFound = new ArrayList<>(featuresFound);
}
|
java
|
public final void startUnify() {
allFeatsIn = true;
for (int i = 0; i < tokCnt; i++) {
featuresFound.add(false);
}
tmpFeaturesFound = new ArrayList<>(featuresFound);
}
|
[
"public",
"final",
"void",
"startUnify",
"(",
")",
"{",
"allFeatsIn",
"=",
"true",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tokCnt",
";",
"i",
"++",
")",
"{",
"featuresFound",
".",
"add",
"(",
"false",
")",
";",
"}",
"tmpFeaturesFound",
"=",
"new",
"ArrayList",
"<>",
"(",
"featuresFound",
")",
";",
"}"
] |
Starts testing only those equivalences that were previously matched.
|
[
"Starts",
"testing",
"only",
"those",
"equivalences",
"that",
"were",
"previously",
"matched",
"."
] |
b7a3d63883d242fb2525877c6382681c57a0a142
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/rules/patterns/Unifier.java#L262-L268
|
19,097
|
languagetool-org/languagetool
|
languagetool-core/src/main/java/org/languagetool/rules/patterns/Unifier.java
|
Unifier.getFinalUnificationValue
|
public final boolean getFinalUnificationValue(Map<String, List<String>> uFeatures) {
int tokUnified = 0;
for (int j = 0; j < tokSequence.size(); j++) {
boolean unifiedTokensFound = false; // assume that nothing has been found
for (int i = 0; i < tokSequenceEquivalences.get(j).size(); i++) {
int featUnified = 0;
if (tokSequenceEquivalences.get(j).get(i).containsKey(UNIFY_IGNORE)) {
if (i == 0) {
tokUnified++;
}
unifiedTokensFound = true;
continue;
} else {
for (Map.Entry<String, List<String>> feat : uFeatures.entrySet()) {
if (tokSequenceEquivalences.get(j).get(i).containsKey(feat.getKey()) &&
tokSequenceEquivalences.get(j).get(i).get(feat.getKey()).isEmpty()) {
featUnified = 0;
} else {
featUnified++;
}
if (featUnified == unificationFeats.entrySet().size() && tokUnified <= j) {
tokUnified++;
unifiedTokensFound = true;
break;
}
}
}
}
if (!unifiedTokensFound) {
return false;
}
}
if (tokUnified == tokSequence.size()) {
return true;
}
return false;
}
|
java
|
public final boolean getFinalUnificationValue(Map<String, List<String>> uFeatures) {
int tokUnified = 0;
for (int j = 0; j < tokSequence.size(); j++) {
boolean unifiedTokensFound = false; // assume that nothing has been found
for (int i = 0; i < tokSequenceEquivalences.get(j).size(); i++) {
int featUnified = 0;
if (tokSequenceEquivalences.get(j).get(i).containsKey(UNIFY_IGNORE)) {
if (i == 0) {
tokUnified++;
}
unifiedTokensFound = true;
continue;
} else {
for (Map.Entry<String, List<String>> feat : uFeatures.entrySet()) {
if (tokSequenceEquivalences.get(j).get(i).containsKey(feat.getKey()) &&
tokSequenceEquivalences.get(j).get(i).get(feat.getKey()).isEmpty()) {
featUnified = 0;
} else {
featUnified++;
}
if (featUnified == unificationFeats.entrySet().size() && tokUnified <= j) {
tokUnified++;
unifiedTokensFound = true;
break;
}
}
}
}
if (!unifiedTokensFound) {
return false;
}
}
if (tokUnified == tokSequence.size()) {
return true;
}
return false;
}
|
[
"public",
"final",
"boolean",
"getFinalUnificationValue",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"uFeatures",
")",
"{",
"int",
"tokUnified",
"=",
"0",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"tokSequence",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"boolean",
"unifiedTokensFound",
"=",
"false",
";",
"// assume that nothing has been found",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tokSequenceEquivalences",
".",
"get",
"(",
"j",
")",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"int",
"featUnified",
"=",
"0",
";",
"if",
"(",
"tokSequenceEquivalences",
".",
"get",
"(",
"j",
")",
".",
"get",
"(",
"i",
")",
".",
"containsKey",
"(",
"UNIFY_IGNORE",
")",
")",
"{",
"if",
"(",
"i",
"==",
"0",
")",
"{",
"tokUnified",
"++",
";",
"}",
"unifiedTokensFound",
"=",
"true",
";",
"continue",
";",
"}",
"else",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"feat",
":",
"uFeatures",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"tokSequenceEquivalences",
".",
"get",
"(",
"j",
")",
".",
"get",
"(",
"i",
")",
".",
"containsKey",
"(",
"feat",
".",
"getKey",
"(",
")",
")",
"&&",
"tokSequenceEquivalences",
".",
"get",
"(",
"j",
")",
".",
"get",
"(",
"i",
")",
".",
"get",
"(",
"feat",
".",
"getKey",
"(",
")",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"featUnified",
"=",
"0",
";",
"}",
"else",
"{",
"featUnified",
"++",
";",
"}",
"if",
"(",
"featUnified",
"==",
"unificationFeats",
".",
"entrySet",
"(",
")",
".",
"size",
"(",
")",
"&&",
"tokUnified",
"<=",
"j",
")",
"{",
"tokUnified",
"++",
";",
"unifiedTokensFound",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"!",
"unifiedTokensFound",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"tokUnified",
"==",
"tokSequence",
".",
"size",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Make sure that we really matched all the required features of the unification.
@param uFeatures Features to be checked
@return True if the token sequence has been found.
@since 2.5
|
[
"Make",
"sure",
"that",
"we",
"really",
"matched",
"all",
"the",
"required",
"features",
"of",
"the",
"unification",
"."
] |
b7a3d63883d242fb2525877c6382681c57a0a142
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/rules/patterns/Unifier.java#L276-L313
|
19,098
|
languagetool-org/languagetool
|
languagetool-core/src/main/java/org/languagetool/rules/patterns/Unifier.java
|
Unifier.reset
|
public final void reset() {
equivalencesMatched.clear();
allFeatsIn = false;
tokCnt = 0;
featuresFound.clear();
tmpFeaturesFound.clear();
tokSequence.clear();
tokSequenceEquivalences.clear();
readingsCounter = 1;
uniMatched = false;
uniAllMatched = false;
inUnification = false;
}
|
java
|
public final void reset() {
equivalencesMatched.clear();
allFeatsIn = false;
tokCnt = 0;
featuresFound.clear();
tmpFeaturesFound.clear();
tokSequence.clear();
tokSequenceEquivalences.clear();
readingsCounter = 1;
uniMatched = false;
uniAllMatched = false;
inUnification = false;
}
|
[
"public",
"final",
"void",
"reset",
"(",
")",
"{",
"equivalencesMatched",
".",
"clear",
"(",
")",
";",
"allFeatsIn",
"=",
"false",
";",
"tokCnt",
"=",
"0",
";",
"featuresFound",
".",
"clear",
"(",
")",
";",
"tmpFeaturesFound",
".",
"clear",
"(",
")",
";",
"tokSequence",
".",
"clear",
"(",
")",
";",
"tokSequenceEquivalences",
".",
"clear",
"(",
")",
";",
"readingsCounter",
"=",
"1",
";",
"uniMatched",
"=",
"false",
";",
"uniAllMatched",
"=",
"false",
";",
"inUnification",
"=",
"false",
";",
"}"
] |
Resets after use of unification. Required.
|
[
"Resets",
"after",
"use",
"of",
"unification",
".",
"Required",
"."
] |
b7a3d63883d242fb2525877c6382681c57a0a142
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/rules/patterns/Unifier.java#L318-L330
|
19,099
|
languagetool-org/languagetool
|
languagetool-core/src/main/java/org/languagetool/rules/patterns/Unifier.java
|
Unifier.getUnifiedTokens
|
@Nullable
public final AnalyzedTokenReadings[] getUnifiedTokens() {
if (tokSequence.isEmpty()) {
return null;
}
List<AnalyzedTokenReadings> uTokens = new ArrayList<>();
for (int j = 0; j < tokSequence.size(); j++) {
boolean unifiedTokensFound = false; // assume that nothing has been found
for (int i = 0; i < tokSequenceEquivalences.get(j).size(); i++) {
int featUnified = 0;
if (tokSequenceEquivalences.get(j).get(i).containsKey(UNIFY_IGNORE)) {
addTokenToSequence(uTokens, tokSequence.get(j).getAnalyzedToken(i), j);
unifiedTokensFound = true;
} else {
for (Map.Entry<String, List<String>> feat : unificationFeats.entrySet()) {
if (tokSequenceEquivalences.get(j).get(i).containsKey(feat.getKey()) &&
tokSequenceEquivalences.get(j).get(i).get(feat.getKey()).isEmpty()) {
featUnified = 0;
} else {
featUnified++;
}
if (featUnified == unificationFeats.entrySet().size()) {
addTokenToSequence(uTokens, tokSequence.get(j).getAnalyzedToken(i), j);
unifiedTokensFound = true;
}
}
}
}
if (!unifiedTokensFound) {
return null;
}
}
return uTokens.toArray(new AnalyzedTokenReadings[0]);
}
|
java
|
@Nullable
public final AnalyzedTokenReadings[] getUnifiedTokens() {
if (tokSequence.isEmpty()) {
return null;
}
List<AnalyzedTokenReadings> uTokens = new ArrayList<>();
for (int j = 0; j < tokSequence.size(); j++) {
boolean unifiedTokensFound = false; // assume that nothing has been found
for (int i = 0; i < tokSequenceEquivalences.get(j).size(); i++) {
int featUnified = 0;
if (tokSequenceEquivalences.get(j).get(i).containsKey(UNIFY_IGNORE)) {
addTokenToSequence(uTokens, tokSequence.get(j).getAnalyzedToken(i), j);
unifiedTokensFound = true;
} else {
for (Map.Entry<String, List<String>> feat : unificationFeats.entrySet()) {
if (tokSequenceEquivalences.get(j).get(i).containsKey(feat.getKey()) &&
tokSequenceEquivalences.get(j).get(i).get(feat.getKey()).isEmpty()) {
featUnified = 0;
} else {
featUnified++;
}
if (featUnified == unificationFeats.entrySet().size()) {
addTokenToSequence(uTokens, tokSequence.get(j).getAnalyzedToken(i), j);
unifiedTokensFound = true;
}
}
}
}
if (!unifiedTokensFound) {
return null;
}
}
return uTokens.toArray(new AnalyzedTokenReadings[0]);
}
|
[
"@",
"Nullable",
"public",
"final",
"AnalyzedTokenReadings",
"[",
"]",
"getUnifiedTokens",
"(",
")",
"{",
"if",
"(",
"tokSequence",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"List",
"<",
"AnalyzedTokenReadings",
">",
"uTokens",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"tokSequence",
".",
"size",
"(",
")",
";",
"j",
"++",
")",
"{",
"boolean",
"unifiedTokensFound",
"=",
"false",
";",
"// assume that nothing has been found",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tokSequenceEquivalences",
".",
"get",
"(",
"j",
")",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"int",
"featUnified",
"=",
"0",
";",
"if",
"(",
"tokSequenceEquivalences",
".",
"get",
"(",
"j",
")",
".",
"get",
"(",
"i",
")",
".",
"containsKey",
"(",
"UNIFY_IGNORE",
")",
")",
"{",
"addTokenToSequence",
"(",
"uTokens",
",",
"tokSequence",
".",
"get",
"(",
"j",
")",
".",
"getAnalyzedToken",
"(",
"i",
")",
",",
"j",
")",
";",
"unifiedTokensFound",
"=",
"true",
";",
"}",
"else",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"feat",
":",
"unificationFeats",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"tokSequenceEquivalences",
".",
"get",
"(",
"j",
")",
".",
"get",
"(",
"i",
")",
".",
"containsKey",
"(",
"feat",
".",
"getKey",
"(",
")",
")",
"&&",
"tokSequenceEquivalences",
".",
"get",
"(",
"j",
")",
".",
"get",
"(",
"i",
")",
".",
"get",
"(",
"feat",
".",
"getKey",
"(",
")",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"featUnified",
"=",
"0",
";",
"}",
"else",
"{",
"featUnified",
"++",
";",
"}",
"if",
"(",
"featUnified",
"==",
"unificationFeats",
".",
"entrySet",
"(",
")",
".",
"size",
"(",
")",
")",
"{",
"addTokenToSequence",
"(",
"uTokens",
",",
"tokSequence",
".",
"get",
"(",
"j",
")",
".",
"getAnalyzedToken",
"(",
"i",
")",
",",
"j",
")",
";",
"unifiedTokensFound",
"=",
"true",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"!",
"unifiedTokensFound",
")",
"{",
"return",
"null",
";",
"}",
"}",
"return",
"uTokens",
".",
"toArray",
"(",
"new",
"AnalyzedTokenReadings",
"[",
"0",
"]",
")",
";",
"}"
] |
Gets a full sequence of filtered tokens.
@return Array of AnalyzedTokenReadings that match equivalence relation
defined for features tested, or {@code null}
|
[
"Gets",
"a",
"full",
"sequence",
"of",
"filtered",
"tokens",
"."
] |
b7a3d63883d242fb2525877c6382681c57a0a142
|
https://github.com/languagetool-org/languagetool/blob/b7a3d63883d242fb2525877c6382681c57a0a142/languagetool-core/src/main/java/org/languagetool/rules/patterns/Unifier.java#L337-L370
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.