Examples of Clusters


Examples of com.emc.vipr.client.core.Clusters

    public Hosts hosts() {
        return new Hosts(this, client);
    }

    public Clusters clusters() {
        return new Clusters(this, client);
    }
View Full Code Here

Examples of com.sun.enterprise.config.serverbeans.Clusters

            Server instanceBean = ServerBeansFactory.getServerBean(configCtx);
            appRef = instanceBean.getApplicationRefByRef(mBeanName);
                                                                                                                                              
            if (appRef == null) {
                //check at cluster level, if this instance is part of cluster
                Clusters clusters = domain.getClusters();
                Cluster[] cluster = clusters.getCluster();
                for (Cluster val : cluster) {
                    if ((val.getServerRefByRef(instanceName)) != null) {
                        appRef = val.getApplicationRefByRef(mBeanName);
                        break;
                    }
View Full Code Here

Examples of edu.gslis.ttg.clusters.Clusters

      JSONObject topicObj = (JSONObject) parseObj.get("topics");
      Set<String> topics = topicObj.keySet();
      Iterator<String> topicIt = topics.iterator();
      while (topicIt.hasNext()) { // for each topic
        String topic = topicIt.next();
        clusterMembership.put(topic, new Clusters());
        JSONArray clusters = (JSONArray) ((JSONObject) topicObj.get(topic)).get("clusters");
        Iterator<JSONArray> clusterIt = clusters.iterator();
        while (clusterIt.hasNext()) { // for each cluster in the topic
          JSONArray cluster = (JSONArray) clusterIt.next();
          Cluster c = new Cluster();
          Iterator<String> clusterMemberIt = cluster.iterator();
          while (clusterMemberIt.hasNext()) { // for each docId in the cluster
            String member = clusterMemberIt.next();
            long memberId = Long.parseLong(member);
            c.add(memberId);
          }
          clusterMembership.get(topic).add(c);
        }
      }
    } catch (Exception e) {
      err.println("Error reading training data.");
      e.printStackTrace();
      System.exit(-1);
    }
   
    // instantiate search client
    TrecSearchThriftClient client = new TrecSearchThriftClient(params.getParamValue(HOST_OPTION),
        trainingPort, group, token);

    SimpleSearcher searcher = new SimpleSearcher(client, numResults);
   
    err.println("=== Train Queries ===");
   
    List<Double> thresholds = new ArrayList<Double>();
    double averageThreshold = 0;
    Iterator<GQuery> queryIterator = trainingQueries.iterator();
    while(queryIterator.hasNext()) {
      GQuery query = queryIterator.next();
     
      Map<Long, TResult> seenResults = searcher.search(query);
     
      SimpleJaccardClusterer clusterer = new SimpleJaccardClusterer(new ArrayList<TResult>(seenResults.values()));
     
      // sweep through jaccard steps, calculating F1
      double maxF1 = 0;
      double maxF1Threshold = 1;
      for (double j = 1.0; j >= 0.0; j -= stepSize) { // for each jaccard threshold step
        Clusters clusters = clusterer.cluster(j);
       
        // all clusters are created now, get a finalized set of results
        Set<Long> allResults = new HashSet<Long>(seenResults.keySet());
        allResults.removeAll(clusters.getAllClusteredResults()); // allResults includes unclustered plus one representative from each cluster
        for (Cluster c : clusters) {
          allResults.add(c.getFirstMember());
        }
       
        // calculate f1 on the finalized set
        Clusters seenClusters = new Clusters();
        Clusters trueClusters = clusterMembership.get(query.getTitle());
        Iterator<Long> resultIt = allResults.iterator();
        while (resultIt.hasNext()) {
          long result = resultIt.next();
          Cluster trueCluster = trueClusters.findCluster(result);
          if (trueCluster != null) { // if it is relevant, it will have a true cluster; if this is null, it's non-relevant
            seenClusters.add(trueCluster);
          }
        }
       
        int numRetrievedClusters = seenClusters.size();
        int numResultsReturned = allResults.size();
        int numTrueClusters = trueClusters.size();

        double precision = 0;
        double recall = 0;
        double f1 = 0;
        if (evalType.equals("unweighted")) {
          precision = numRetrievedClusters / (double) numResultsReturned;
          recall = numRetrievedClusters / (double) numTrueClusters;
          f1 = 2 * precision * recall / (precision + recall);
        } else {       
          // for weighted measurements, we need the weight of each cluster
          int retrievedWeight = 0;
          for (Cluster cluster : seenClusters) {
            int w = cluster.getWeight(query, qrels);
            retrievedWeight += w;
          }
          int resultsWeight = 0;
          for (long result : allResults) {
            int w = 0;
            if (seenClusters.findCluster(result) == null)
            resultsWeight += w;
          }
          int trueWeight = 0;
          for (Cluster cluster : trueClusters) {
            int w = cluster.getWeight(query, qrels);
            trueWeight += w;
          }
         
          precision = retrievedWeight / (double) resultsWeight; // <--- ??????
          recall = retrievedWeight / (double) trueWeight;
          f1 = 2 * precision * recall / (precision + recall);
        }
        if (f1 > maxF1) {
          maxF1 = f1;
          maxF1Threshold = j;
        }
      }
      thresholds.add(maxF1Threshold);
      err.println("F1: "+df.format(maxF1)+"; Jaccard: "+df.format(maxF1Threshold));
     
    }
   
    // get the average threshold
    for (double threshold : thresholds) {
      averageThreshold += threshold;
    }
    averageThreshold /= thresholds.size();
    err.println("Average Jaccard: "+averageThreshold);
   
    err.println("=== Test Queries ===");
   
    // now cluster the test queries and output
    queryIterator = queries.iterator();
    while(queryIterator.hasNext()) {
      GQuery query = queryIterator.next();
      err.println(query.getTitle());
     
      client = new TrecSearchThriftClient(params.getParamValue(HOST_OPTION), testingPort, group, token);
      searcher = new SimpleSearcher(client, numResults);
      Map<Long, TResult> seenResults = searcher.search(query);
     
      SimpleJaccardClusterer clusterer = new SimpleJaccardClusterer(new ArrayList<TResult>(seenResults.values()));
      Clusters clusters = clusterer.cluster(averageThreshold);
     
      // all clusters are created now, get a finalized set of results
      Set<Long> allResults = new HashSet<Long>(seenResults.keySet());
      allResults.removeAll(clusters.getAllClusteredResults()); // allResults includes unclustered plus one representative from each cluster
      for (Cluster c : clusters) {
        allResults.add(c.getFirstMember());
      }
     
      int i = 0;
View Full Code Here

Examples of edu.gslis.ttg.clusters.Clusters

    this.results = results;
    this.jaccardScores = computeJaccardSimilarity();
  }
 
  public Clusters cluster(double threshold) {
    Clusters clusters = new Clusters();
   
    NavigableMap<Double, List<long[]>> thresholdPairs = jaccardScores.getDocsGreaterThanScore(threshold);
    Iterator<Double> pairsIt = thresholdPairs.keySet().iterator();
    while (pairsIt.hasNext()) { // for each pair of documents matching this jaccard score
      List<long[]> docPairs = thresholdPairs.get(pairsIt.next());
      Iterator<long[]> docPairIt = docPairs.iterator();
      while (docPairIt.hasNext()) { //
        long[] docs = docPairIt.next();
        clusters.mergeMembers(docs[0], docs[1]);
      }
    }
   
    return clusters;
  }
View Full Code Here

Examples of org.apache.ambari.server.state.Clusters

    Resource.Type type = Resource.Type.Request;

    AmbariManagementController managementController = createMock(AmbariManagementController.class);
    ActionManager actionManager = createNiceMock(ActionManager.class);
    HostRoleCommand hostRoleCommand = createNiceMock(HostRoleCommand.class);
    Clusters clusters = createNiceMock(Clusters.class);
    Cluster cluster = createNiceMock(Cluster.class);

    List<HostRoleCommand> hostRoleCommands = new LinkedList<HostRoleCommand>();
    hostRoleCommands.add(hostRoleCommand);

    org.apache.ambari.server.actionmanager.Request requestMock =
        createNiceMock(org.apache.ambari.server.actionmanager.Request.class);
    expect(requestMock.getCommands()).andReturn(hostRoleCommands).anyTimes();
    expect(requestMock.getRequestContext()).andReturn("this is a context").anyTimes();
    expect(requestMock.getClusterName()).andReturn("c1").anyTimes();
    expect(requestMock.getRequestId()).andReturn(100L).anyTimes();

    Capture<Collection<Long>> requestIdsCapture = new Capture<Collection<Long>>();

    // set expectations
    expect(managementController.getActionManager()).andReturn(actionManager).anyTimes();
    expect(managementController.getClusters()).andReturn(clusters).anyTimes();
    expect(clusters.getCluster("c1")).andReturn(cluster).anyTimes();
    expect(clusters.getCluster("bad-cluster")).andThrow(new AmbariException("bad cluster!")).anyTimes();
    expect(actionManager.getRequests(capture(requestIdsCapture))).andReturn(Collections.singletonList(requestMock));
    expect(hostRoleCommand.getRequestId()).andReturn(100L).anyTimes();
    expect(hostRoleCommand.getStatus()).andReturn(HostRoleStatus.IN_PROGRESS);

    // replay
View Full Code Here

Examples of org.apache.ambari.server.state.Clusters

  }

  @Test
  public void testStateCommandsGeneration() throws AmbariException, InterruptedException,
          InvalidStateTransitionException {
    Clusters clusters = injector.getInstance(Clusters.class);
    clusters.addHost(hostname1);
    clusters.getHost(hostname1).setOsType("centos6");
    clusters.getHost(hostname1).persist();
    clusters.addHost(hostname2);
    clusters.getHost(hostname2).setOsType("centos6");
    clusters.getHost(hostname2).persist();
    clusters.addCluster(clusterName);
    Cluster cluster = clusters.getCluster(clusterName);
    cluster.setDesiredStackVersion(new StackId("HDP-0.1"));
    Set<String> hostNames = new HashSet<String>(){{
      add(hostname1);
      add(hostname2);
    }};
   
    ConfigFactory configFactory = injector.getInstance(ConfigFactory.class);
    Config config = configFactory.createNew(cluster, "global",
        new HashMap<String,String>() {{ put("a", "b"); }});
    config.setVersionTag("version1");
    cluster.addConfig(config);
    cluster.addDesiredConfig("_test", config);
   
   
    clusters.mapHostsToCluster(hostNames, clusterName);
    Service hdfs = cluster.addService(serviceName);
    hdfs.persist();
    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1).persist();
    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
View Full Code Here

Examples of org.apache.ambari.server.state.Clusters

    assertTrue("HeartbeatMonitor should not generate StatusCommands for host2 because it has no services", cmds.isEmpty());
  }

  @Test
  public void testStatusCommandForAnyComponents() throws Exception {
    Clusters clusters = injector.getInstance(Clusters.class);
    clusters.addHost(hostname1);
    clusters.getHost(hostname1).setOsType("centos6");
    clusters.getHost(hostname1).persist();
    clusters.addHost(hostname2);
    clusters.getHost(hostname2).setOsType("centos6");
    clusters.getHost(hostname2).persist();
    clusters.addCluster(clusterName);
    Cluster cluster = clusters.getCluster(clusterName);
    cluster.setDesiredStackVersion(new StackId("HDP-0.1"));
    Set<String> hostNames = new HashSet<String>() {{
      add(hostname1);
      add(hostname2);
    }};

    ConfigFactory configFactory = injector.getInstance(ConfigFactory.class);
    Config config = configFactory.createNew(cluster, "global",
      new HashMap<String, String>() {{
        put("a", "b");
      }});
    config.setVersionTag("version1");
    cluster.addConfig(config);
    cluster.addDesiredConfig("_test", config);


    clusters.mapHostsToCluster(hostNames, clusterName);
    Service hdfs = cluster.addService(serviceName);
    hdfs.persist();
    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost
      (hostname1).persist();
View Full Code Here

Examples of org.apache.ambari.server.state.Clusters

  }

  @Test
  public void testHeartbeatStateCommandsEnqueueing() throws AmbariException, InterruptedException,
          InvalidStateTransitionException {
    Clusters clusters = injector.getInstance(Clusters.class);
    clusters.addHost(hostname1);
    clusters.getHost(hostname1).setOsType("centos5");
    clusters.getHost(hostname1).persist();
    clusters.addCluster(clusterName);
    Cluster cluster = clusters.getCluster(clusterName);
    cluster.setDesiredStackVersion(new StackId("HDP-0.1"));

    Set<String> hostNames = new HashSet<String>(){{
      add(hostname1);
     }};

    clusters.mapHostsToCluster(hostNames, clusterName);

    Service hdfs = cluster.addService(serviceName);
    hdfs.persist();
    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1).persist();
    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1).persist();
    hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name()).persist();
    hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1).persist();

    ActionQueue aqMock = mock(ActionQueue.class);
    ArgumentCaptor<AgentCommand> commandCaptor=ArgumentCaptor.
            forClass(AgentCommand.class);

    ActionManager am = mock(ActionManager.class);
    HeartbeatMonitor hm = new HeartbeatMonitor(clusters, aqMock, am,
      heartbeatMonitorWakeupIntervalMS, injector);
    HeartBeatHandler handler = new HeartBeatHandler(clusters, aqMock, am,
        injector);
    Register reg = new Register();
    reg.setHostname(hostname1);
    reg.setResponseId(12);
    reg.setTimestamp(System.currentTimeMillis() - 15);
    reg.setAgentVersion(ambariMetaInfo.getServerVersion());
    HostInfo hi = new HostInfo();
    hi.setOS("Centos5");
    reg.setHardwareProfile(hi);
    handler.handleRegistration(reg);
    HeartBeat hb = new HeartBeat();
    hb.setHostname(hostname1);
    hb.setNodeStatus(new HostStatus(HostStatus.Status.HEALTHY, "cool"));
    hb.setTimestamp(System.currentTimeMillis());
    hb.setResponseId(13);
    handler.handleHeartBeat(hb);
    LOG.info("YYY");
    clusters.getHost(hostname1).setLastHeartbeatTime(System.currentTimeMillis() - 15);
    hm.start();
    Thread.sleep(3 * heartbeatMonitorWakeupIntervalMS);
    hm.shutdown();
    hm.join(2*heartbeatMonitorWakeupIntervalMS);
    if (hm.isAlive()) {
View Full Code Here

Examples of org.apache.ambari.server.state.Clusters

  }

  @Test
  public void testHeartbeatLoss() throws AmbariException, InterruptedException,
          InvalidStateTransitionException {
    Clusters fsm = injector.getInstance(Clusters.class);
    String hostname = "host1";
    fsm.addHost(hostname);
    ActionQueue aq = new ActionQueue();
    ActionManager am = mock(ActionManager.class);
    HeartbeatMonitor hm = new HeartbeatMonitor(fsm, aq, am, 10, injector);
    HeartBeatHandler handler = new HeartBeatHandler(fsm, aq, am, injector);
    Register reg = new Register();
    reg.setHostname(hostname);
    reg.setResponseId(12);
    reg.setTimestamp(System.currentTimeMillis() - 300);
    reg.setAgentVersion(ambariMetaInfo.getServerVersion());
    HostInfo hi = new HostInfo();
    hi.setOS("Centos5");
    reg.setHardwareProfile(hi);
    handler.handleRegistration(reg);
    HeartBeat hb = new HeartBeat();
    hb.setHostname(hostname);
    hb.setNodeStatus(new HostStatus(HostStatus.Status.HEALTHY, "cool"));
    hb.setTimestamp(System.currentTimeMillis());
    hb.setResponseId(12);
    handler.handleHeartBeat(hb);
    hm.start();
    aq.enqueue(hostname, new ExecutionCommand());
    //Heartbeat will expire and action queue will be flushed
    while (aq.size(hostname) != 0) {
      Thread.sleep(1);
    }
    assertEquals(fsm.getHost(hostname).getState(), HostState.HEARTBEAT_LOST);
  }
View Full Code Here

Examples of org.apache.ambari.server.state.Clusters

  }
 
  @Test
  public void testHeartbeatLossWithComponent() throws AmbariException, InterruptedException,
          InvalidStateTransitionException {
    Clusters clusters = injector.getInstance(Clusters.class);
    clusters.addHost(hostname1);
    clusters.getHost(hostname1).setOsType("centos5");
    clusters.getHost(hostname1).persist();
   
    clusters.addCluster(clusterName);
    Cluster cluster = clusters.getCluster(clusterName);
    cluster.setDesiredStackVersion(new StackId("HDP-0.1"));

    Set<String> hostNames = new HashSet<String>(){{
      add(hostname1);
     }};

    clusters.mapHostsToCluster(hostNames, clusterName);

    Service hdfs = cluster.addService(serviceName);
    hdfs.persist();
    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1).persist();
    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1).persist();
    hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name()).persist();
    hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1).persist();
    hdfs.addServiceComponent(Role.HDFS_CLIENT.name()).persist();
    hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost(hostname1);
   
    ActionQueue aq = new ActionQueue();
    ActionManager am = mock(ActionManager.class);
    HeartbeatMonitor hm = new HeartbeatMonitor(clusters, aq, am, 10, injector);
    HeartBeatHandler handler = new HeartBeatHandler(clusters, aq, am, injector);
   
    Register reg = new Register();
    reg.setHostname(hostname1);
    reg.setResponseId(12);
    reg.setTimestamp(System.currentTimeMillis() - 300);
    reg.setAgentVersion(ambariMetaInfo.getServerVersion());
    HostInfo hi = new HostInfo();
    hi.setOS("Centos5");
    reg.setHardwareProfile(hi);
    handler.handleRegistration(reg);
   
    cluster = clusters.getClustersForHost(hostname1).iterator().next();
    for (ServiceComponentHost sch : cluster.getServiceComponentHosts(hostname1)) {
      if (sch.getServiceComponentName().equals("NAMENODE")) {
        // installing
        sch.handleEvent(new ServiceComponentHostInstallEvent(
            sch.getServiceComponentName(), sch.getHostName(), System.currentTimeMillis(), "HDP-0.1"));
       
        // installed
        sch.handleEvent(new ServiceComponentHostOpSucceededEvent(sch.getServiceComponentName(),
            sch.getHostName(), System.currentTimeMillis()));
       
        // started
        sch.handleEvent(new ServiceComponentHostStartedEvent(sch.getServiceComponentName(),
            sch.getHostName(), System.currentTimeMillis()));
      }
      else if (sch.getServiceComponentName().equals("DATANODE")) {
        // installing
        sch.handleEvent(new ServiceComponentHostInstallEvent(
            sch.getServiceComponentName(), sch.getHostName(), System.currentTimeMillis(), "HDP-0.1"));
      } else if (sch.getServiceComponentName().equals("SECONDARY_NAMENODE"))  {
        // installing
        sch.handleEvent(new ServiceComponentHostInstallEvent(
          sch.getServiceComponentName(), sch.getHostName(), System.currentTimeMillis(), "HDP-0.1"));

        // installed
        sch.handleEvent(new ServiceComponentHostOpSucceededEvent(sch.getServiceComponentName(),
          sch.getHostName(), System.currentTimeMillis()));

        // disabled
        sch.handleEvent(new ServiceComponentHostDisableEvent(sch.getServiceComponentName(),
          sch.getHostName(), System.currentTimeMillis()));
      }
    }
   
    HeartBeat hb = new HeartBeat();
    hb.setHostname(hostname1);
    hb.setNodeStatus(new HostStatus(HostStatus.Status.HEALTHY, "cool"));
    hb.setTimestamp(System.currentTimeMillis());
    hb.setResponseId(12);
    handler.handleHeartBeat(hb);
   
    hm.start();
    aq.enqueue(hostname1, new ExecutionCommand());
    //Heartbeat will expire and action queue will be flushed
    while (aq.size(hostname1) != 0) {
      Thread.sleep(1);
    }
    hm.shutdown();
   

    cluster = clusters.getClustersForHost(hostname1).iterator().next();
    for (ServiceComponentHost sch : cluster.getServiceComponentHosts(hostname1)) {
      Service s = cluster.getService(sch.getServiceName());
      ServiceComponent sc = s.getServiceComponent(sch.getServiceComponentName());
      if (sch.getServiceComponentName().equals("NAMENODE"))
        assertEquals(sch.getServiceComponentName(), State.UNKNOWN, sch.getState());
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.