use of java.util.Locale.ENGLISH in project presto by prestodb.
the class DiscoveryNodeManager method refreshNodesInternal.
private synchronized PrestoNode refreshNodesInternal() {
lastUpdateTimestamp = System.nanoTime();
// This is currently a blacklist.
// TODO: make it a whitelist (a failure-detecting service selector) and maybe build in support for injecting this in airlift
Set<ServiceDescriptor> services = serviceSelector.selectAllServices().stream().filter(service -> !failureDetector.getFailed().contains(service)).collect(toImmutableSet());
PrestoNode currentNode = null;
ImmutableSet.Builder<Node> activeNodesBuilder = ImmutableSet.builder();
ImmutableSet.Builder<Node> inactiveNodesBuilder = ImmutableSet.builder();
ImmutableSet.Builder<Node> shuttingDownNodesBuilder = ImmutableSet.builder();
ImmutableSet.Builder<Node> coordinatorsBuilder = ImmutableSet.builder();
ImmutableSetMultimap.Builder<ConnectorId, Node> byConnectorIdBuilder = ImmutableSetMultimap.builder();
for (ServiceDescriptor service : services) {
URI uri = getHttpUri(service);
NodeVersion nodeVersion = getNodeVersion(service);
boolean coordinator = isCoordinator(service);
if (uri != null && nodeVersion != null) {
PrestoNode node = new PrestoNode(service.getNodeId(), uri, nodeVersion, coordinator);
NodeState nodeState = getNodeState(node);
// record current node
if (node.getNodeIdentifier().equals(nodeInfo.getNodeId())) {
currentNode = node;
checkState(currentNode.getNodeVersion().equals(expectedNodeVersion), "INVARIANT: current node version (%s) should be equal to %s", currentNode.getNodeVersion(), expectedNodeVersion);
}
switch(nodeState) {
case ACTIVE:
activeNodesBuilder.add(node);
if (coordinator) {
coordinatorsBuilder.add(node);
}
// record available active nodes organized by connector id
String connectorIds = service.getProperties().get("connectorIds");
if (connectorIds != null) {
connectorIds = connectorIds.toLowerCase(ENGLISH);
for (String connectorId : CONNECTOR_ID_SPLITTER.split(connectorIds)) {
byConnectorIdBuilder.put(new ConnectorId(connectorId), node);
}
}
// always add system connector
byConnectorIdBuilder.put(new ConnectorId(GlobalSystemConnector.NAME), node);
break;
case INACTIVE:
inactiveNodesBuilder.add(node);
break;
case SHUTTING_DOWN:
shuttingDownNodesBuilder.add(node);
break;
default:
throw new IllegalArgumentException("Unknown node state " + nodeState);
}
}
}
if (allNodes != null) {
// log node that are no longer active (but not shutting down)
SetView<Node> missingNodes = difference(allNodes.getActiveNodes(), Sets.union(activeNodesBuilder.build(), shuttingDownNodesBuilder.build()));
for (Node missingNode : missingNodes) {
log.info("Previously active node is missing: %s (last seen at %s)", missingNode.getNodeIdentifier(), missingNode.getHostAndPort());
}
}
allNodes = new AllNodes(activeNodesBuilder.build(), inactiveNodesBuilder.build(), shuttingDownNodesBuilder.build());
activeNodesByConnectorId = byConnectorIdBuilder.build();
coordinators = coordinatorsBuilder.build();
checkState(currentNode != null, "INVARIANT: current node not returned from service selector");
return currentNode;
}
use of java.util.Locale.ENGLISH in project error-prone by google.
the class ErrorProneJavacPluginTest method hello.
@Test
public void hello() throws IOException {
FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix());
Path source = fileSystem.getPath("Test.java");
Files.write(source, ImmutableList.of("import java.util.HashSet;", "import java.util.Set;", "class Test {", " public static void main(String[] args) {", " Set<Short> s = new HashSet<>();", " for (short i = 0; i < 100; i++) {", " s.add(i);", " s.remove(i - 1);", " }", " System.out.println(s.size());", " }", "}"), UTF_8);
JavacFileManager fileManager = new JavacFileManager(new Context(), false, UTF_8);
DiagnosticCollector<JavaFileObject> diagnosticCollector = new DiagnosticCollector<>();
JavacTask task = JavacTool.create().getTask(null, fileManager, diagnosticCollector, ImmutableList.of("-Xplugin:ErrorProne"), ImmutableList.of(), fileManager.getJavaFileObjects(source));
assertThat(task.call()).isFalse();
Diagnostic<? extends JavaFileObject> diagnostic = diagnosticCollector.getDiagnostics().stream().filter(d -> d.getKind() == Diagnostic.Kind.ERROR).collect(onlyElement());
assertThat(diagnostic.getMessage(ENGLISH)).contains("[CollectionIncompatibleType]");
}
Aggregations