Examples of NodeService


Examples of org.elasticsearch.node.service.NodeService

public class NodePortExpressionTest {

    @Test
    public void testNoHttpServerAvailable() throws Exception {
        NodeService nodeService = mock(NodeService.class);
        NodeInfo nodeInfo = mock(NodeInfo.class);
        when(nodeService.info()).thenReturn(nodeInfo);
        when(nodeInfo.getHttp()).thenReturn(null);


        NodePortExpression nodePortExpression = new NodePortExpression(nodeService);
        Object value = nodePortExpression.getChildImplementation(NodePortExpression.HTTP).value();
View Full Code Here

Examples of org.elasticsearch.node.service.NodeService

            OsStats osStats = mock(OsStats.class);
            when(osService.stats()).thenReturn(osStats);
            when(osStats.loadAverage()).thenReturn(new double[]{1, 5, 15});
            bind(OsService.class).toInstance(osService);

            NodeService nodeService = mock(NodeService.class);
            bind(NodeService.class).toInstance(nodeService);

            ClusterService clusterService = mock(ClusterService.class);
            bind(ClusterService.class).toInstance(clusterService);
View Full Code Here

Examples of org.elasticsearch.node.service.NodeService

            when(mem.usedPercent()).thenReturn((short) 22);
            when(mem.freePercent()).thenReturn((short) 78);

            bind(OsService.class).toInstance(osService);

            NodeService nodeService = mock(NodeService.class);
            NodeStats nodeStats = mock(NodeStats.class);
            when(nodeService.stats()).thenReturn(nodeStats);
            when(nodeStats.getHostname()).thenReturn("localhost");

            DiscoveryNode node = mock(DiscoveryNode.class);
            when(nodeStats.getNode()).thenReturn(node);

            when(nodeStats.getOs()).thenReturn(osStats);
            when(osStats.uptime()).thenReturn(new TimeValue(3600000));
            OsStats.Cpu cpu = mock(OsStats.Cpu.class);
            when(osStats.cpu()).thenReturn(cpu);
            when(cpu.sys()).thenReturn((short) 2);
            when(cpu.user()).thenReturn((short) 4);
            when(cpu.idle()).thenReturn((short) 94);
            when(cpu.stolen()).thenReturn((short) 10);

            ProcessStats processStats = mock(ProcessStats.class);
            when(nodeStats.getProcess()).thenReturn(processStats);
            when(processStats.getOpenFileDescriptors()).thenReturn(42L);

            NodeInfo nodeInfo = mock(NodeInfo.class);
            when(nodeService.info()).thenReturn(nodeInfo);

            ProcessInfo processInfo = mock(ProcessInfo.class);
            when(nodeInfo.getProcess()).thenReturn(processInfo);
            when(processInfo.getMaxFileDescriptors()).thenReturn(1000L);
View Full Code Here

Examples of org.graylog2.cluster.NodeService

                finalServiceManager.stopAsync().awaitStopped();
            }
        });

        // Register this node.
        final NodeService nodeService = injector.getInstance(NodeService.class);
        nodeService.registerServer(serverStatus.getNodeId().toString(), configuration.isMaster(), configuration.getRestTransportUri());

        if (configuration.isMaster() && !nodeService.isOnlyMaster(serverStatus.getNodeId())) {
            LOG.warn("Detected another master in the cluster. Retrying in {} seconds to make sure it is not "
                    + "an old stale instance.", configuration.getStaleMasterTimeout());
            try {
                Thread.sleep(configuration.getStaleMasterTimeout());
            } catch (InterruptedException e) { /* nope */ }
           
            if (!nodeService.isOnlyMaster(serverStatus.getNodeId())) {
                // All devils here.
                String what = "Detected other master node in the cluster! Starting as non-master! "
                        + "This is a mis-configuration you should fix.";
                LOG.warn(what);
                activityWriter.write(new Activity(what, Main.class));
View Full Code Here

Examples of org.hudsonci.service.NodeService

        List<Node> nodes = new ArrayList<Node>();
        nodes.add(node);
        Node masterNode = hudson;

        NodeService inst = spy(getInst());

        doReturn(nodes).when(hudson).getNodes();
        doReturn(hudson).when(inst).getMasterNode();
        doReturn(true).when(security).hasPermission(masterNode, Permission.READ);

        List<Node> result = inst.getAllNodes();

        assertThat(result, not(contains(node)));
        assertThat(result, contains(masterNode));
        Mockito.verify(security).hasPermission(node, Permission.READ);
        Mockito.verify(security).hasPermission(masterNode, Permission.READ);
View Full Code Here

Examples of org.hudsonci.service.NodeService

    public void getNodesSecurity() {

        List<Node> nodes = new ArrayList<Node>();
        nodes.add(node);

        NodeService inst = spy(getInst());

        doReturn(nodes).when(hudson).getNodes();
        doReturn(true).when(security).hasPermission(node, Permission.READ);

        List<Node> result = inst.getNodes();

        assertThat(result, contains(node));

        Mockito.verify(security).hasPermission(node, Permission.READ);
View Full Code Here

Examples of org.hudsonci.service.NodeService

        List<Node> nodes = new ArrayList<Node>();
        nodes.add(node);
        Node masterNode = hudson;

        NodeService inst = spy(getInst());

        doReturn(nodes).when(hudson).getNodes();
        doReturn(true).when(security).hasPermission(node, Permission.READ);
        // try to fake it out
        doReturn(hudson).when(inst).getMasterNode();
        doReturn(true).when(security).hasPermission(masterNode, Permission.READ);

        List<Node> result = inst.getNodes();

        assertThat(result, contains(node));
        assertThat(result, not(contains(masterNode)));
    }
View Full Code Here

Examples of org.structr.core.graph.NodeService

  @Override
  public void index(GraphObject entity, Object value) {

    if (entity instanceof AbstractNode) {

      NodeService nodeService = Services.getInstance().getService(NodeService.class);
      AbstractNode node       = (AbstractNode)entity;
      Node dbNode             = node.getNode();

      for (NodeIndex indexName : nodeIndices()) {

        Index<Node> index = nodeService.getNodeIndex(indexName);
        if (index != null) {

          try {

            synchronized (index) {

              index.remove(dbNode, dbName);

              if (value != null && !StringUtils.isBlank(value.toString())) {
                  index.add(dbNode, dbName, value);

              } else if (isIndexedWhenEmpty()) {

                value = getValueForEmptyFields();
                if (value != null) {

                  index.add(dbNode, dbName, value);
                }
              }
            }

          } catch (Throwable t) {

            logger.log(Level.INFO, "Unable to index property with dbName {0} and value {1} of type {2} on {3}: {4}", new Object[] { dbName, value, this.getClass().getSimpleName(), entity, t } );
          }
        }
      }

    } else {

      NodeService nodeService  = Services.getInstance().getService(NodeService.class);
      AbstractRelationship rel = (AbstractRelationship)entity;
      Relationship dbRel       = rel.getRelationship();

      for (RelationshipIndex indexName : relationshipIndices()) {

        Index<Relationship> index = nodeService.getRelationshipIndex(indexName);
        if (index != null) {

          try {

            synchronized (index) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.