Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package com.facebook.presto.metadata;
 
 
 import java.net.URI;
 import java.util.List;
 import java.util.Set;
 import java.util.UUID;
 
 import static io.airlift.discovery.client.ServiceDescriptor.serviceDescriptor;
 import static io.airlift.testing.Assertions.assertEqualsIgnoreOrder;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotSame;
 
 @Test(singleThreaded = true)
 {
     private final NodeInfo nodeInfo = new NodeInfo("test");
     private NodeVersion expectedVersion;
     private List<PrestoNodeactiveNodes;
     private List<PrestoNodeinactiveNodes;
     private ServiceSelector selector;
 
     @BeforeMethod
     public void setup()
     {
          = new NodeVersion("1");
          = ImmutableList.of(
                 new PrestoNode(.getNodeId(), URI.create("http://192.0.1.1"), ),
                 new PrestoNode(UUID.randomUUID().toString(), URI.create("http://192.0.2.1:8080"), ),
                 new PrestoNode(UUID.randomUUID().toString(), URI.create("http://192.0.2.3"), ),
                 new PrestoNode(UUID.randomUUID().toString(), URI.create("https://192.0.2.8"), ));
          = ImmutableList.of(
                 new PrestoNode(UUID.randomUUID().toString(), URI.create("https://192.0.3.9"), .),
                 new PrestoNode(UUID.randomUUID().toString(), URI.create("https://192.0.4.9"), new NodeVersion("2"))
         );
 
         List<ServiceDescriptordescriptors = new ArrayList<>();
         for (PrestoNode node : Iterables.concat()) {
             descriptors.add(serviceDescriptor("presto")
                     .setNodeId(node.getNodeIdentifier())
                     .addProperty("http"node.getHttpUri().toString())
                     .addProperty("node_version"node.getNodeVersion().toString())
                     .build());
         }
 
          = new StaticServiceSelector(descriptors);
     }
 
     @Test
     public void testGetAllNodes()
             throws Exception
     {
         AllNodes allNodes = manager.getAllNodes();
 
         Set<NodeactiveNodes = allNodes.getActiveNodes();
         assertEqualsIgnoreOrder(activeNodesthis.);
 
         for (Node actual : activeNodes) {
             for (Node expected : this.) {
                 assertNotSame(actualexpected);
             }
         }
 
         Set<NodeinactiveNodes = allNodes.getInactiveNodes();
         assertEqualsIgnoreOrder(inactiveNodesthis.);
 
         for (Node actual : inactiveNodes) {
             for (Node expected : this.) {
                 assertNotSame(actualexpected);
             }
         }
     }
 
    @Test
    public void testGetCurrentNode()
    {
        Node expected = .get(0);
        NodeInfo nodeInfo = new NodeInfo(new NodeConfig()
                .setEnvironment("test")
                .setNodeId(expected.getNodeIdentifier()));
        DiscoveryNodeManager manager = new DiscoveryNodeManager(nodeInfonew NoOpFailureDetector(), );
        assertEquals(manager.getCurrentNode(), expected);
    }
    @SuppressWarnings("ResultOfObjectAllocationIgnored")
    @Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = ".* current node not returned .*")
    public void testGetCurrentNodeRequired()
    {
        new DiscoveryNodeManager(new NodeInfo("test"), new NoOpFailureDetector(), );
    }
New to GrepCode? Check out our FAQ X