Examples of ClusterView


Examples of com.linkedin.helix.ClusterView

  public static ClusterView convertStateModelMapToClusterView(String outFile, String instanceName,
      StateModelFactory<StateModel> stateModelFactory)
  {
    Map<String, StateModel> currentStateMap = stateModelFactory.getStateModelMap();
    ClusterView curView = new ClusterView();

    ClusterView.MemberInstance memberInstance = curView.getMemberInstance(instanceName, true);
    List<ZNRecord> curStateList = new ArrayList<ZNRecord>();

    for (Map.Entry<String, StateModel> entry : currentStateMap.entrySet())
    {
      String stateUnitKey = entry.getKey();
View Full Code Here

Examples of com.linkedin.helix.ClusterView

  public static boolean verifyFileBasedClusterStates(String instanceName, String expectedFile,
      String curFile)
  {
    boolean ret = true;
    ClusterView expectedView = ClusterViewSerializer.deserialize(new File(expectedFile));
    ClusterView curView = ClusterViewSerializer.deserialize(new File(curFile));

    // ideal_state for instance with the given instanceName
    Map<String, String> idealStates = new HashMap<String, String>();
    for (ZNRecord idealStateItem : expectedView.getPropertyList(PropertyType.IDEALSTATES))
    {
      Map<String, Map<String, String>> allIdealStates = idealStateItem.getMapFields();

      for (Map.Entry<String, Map<String, String>> entry : allIdealStates.entrySet())
      {
        if (entry.getValue().containsKey(instanceName))
        {
          String state = entry.getValue().get(instanceName);
          idealStates.put(entry.getKey(), state);
        }
      }
    }

    ClusterView.MemberInstance memberInstance = curView.getMemberInstance(instanceName, false);
    List<ZNRecord> curStateList = memberInstance.getInstanceProperty(PropertyType.CURRENTSTATES);

    if (curStateList == null && idealStates.size() > 0)
    {
      LOG.info("current state is null");
View Full Code Here

Examples of com.linkedin.helix.ClusterView

    // "localhost:8902", "localhost:8903",
    // "localhost:8904" };
    String[] nodesInfo = { "localhost:12918" };
    int replication = 0;

    ClusterView view = StaticFileHelixManager.generateStaticConfigClusterView(nodesInfo, dbParams, replication);
    view.setExternalView(new LinkedList<ZNRecord>());
    String file = "/tmp/clusterView.json";
    // ClusterViewSerializer serializer = new ClusterViewSerializer(file);

    // byte[] bytes;
    ClusterViewSerializer.serialize(view, new File(file));
    // String str1 = new String(bytes);
    ClusterView restoredView = ClusterViewSerializer.deserialize(new File(file));
    // logger.info(restoredView);

    // byte[] bytes2 = serializer.serialize(restoredView);

    VerifyClusterViews(view, restoredView);
View Full Code Here

Examples of org.apache.sling.discovery.ClusterView

        pw.println("</tr>");
        pw.println("</thead>");
        pw.println("<tbody>");

        Set<ClusterView> clusters = topology.getClusterViews();
        ClusterView myCluster = topology.getLocalInstance().getClusterView();
        boolean odd = true;
        renderCluster(pw, myCluster, myCluster, odd);

        for (Iterator<ClusterView> it = clusters.iterator(); it.hasNext();) {
            ClusterView clusterView = it.next();
            if (clusterView.equals(myCluster)) {
                // skip - I already rendered that
                continue;
            }
            odd = !odd;
            renderCluster(pw, clusterView, myCluster, odd);
View Full Code Here

Examples of org.apache.sling.discovery.ClusterView

        }
        pw.println();
        pw.println();

        final Set<ClusterView> clusters = topology.getClusterViews();
        final ClusterView myCluster = topology.getLocalInstance().getClusterView();
        printCluster(pw, myCluster, myCluster);

        for (Iterator<ClusterView> it = clusters.iterator(); it.hasNext();) {
            ClusterView clusterView = it.next();
            if (clusterView.equals(myCluster)) {
                // skip - I already rendered that
                continue;
            }
            printCluster(pw, clusterView, myCluster);
        }
View Full Code Here

Examples of org.apache.sling.discovery.ClusterView

        return ann;
    }
   
    @Test
    public void testExpiry() throws InterruptedException, NoSuchFieldException {
        ClusterView cluster1 = createCluster(4);
        ClusterView cluster2 = createCluster(3);
        ClusterView cluster3 = createCluster(5);
       
        ClusterView myCluster = createCluster(slingId);
       
        Announcement ann1 = createAnnouncement(cluster1, 0, true);
        Announcement ann2 = createAnnouncement(cluster2, 1, true);
        Announcement ann3 = createAnnouncement(cluster3, 1, false);
       
View Full Code Here

Examples of org.apache.sling.discovery.ClusterView

       
    }
   
    @Test
    public void testCluster() throws Exception {
        ClusterView cluster1 = createCluster(2);
        ClusterView cluster2 = createCluster(4);
        ClusterView cluster3 = createCluster(7);
       
        Announcement ann1 = createAnnouncement(cluster1, 1, true);
        Announcement ann2 = createAnnouncement(cluster2, 2, true);
        Announcement ann3 = createAnnouncement(cluster3, 3, false);
       
        final String instance1 = UUID.randomUUID().toString();
        final String instance2 = UUID.randomUUID().toString();
        final String instance3 = UUID.randomUUID().toString();
        ClusterView myCluster = createCluster(instance1, instance2, instance3);

        AnnouncementRegistryImpl registry1 = (AnnouncementRegistryImpl) OSGiFactory.createITopologyAnnouncementRegistry(
                resourceResolverFactory, config, instance1);
        AnnouncementRegistryImpl registry2 = (AnnouncementRegistryImpl) OSGiFactory.createITopologyAnnouncementRegistry(
                resourceResolverFactory, config, instance2);
View Full Code Here

Examples of org.apache.sling.discovery.ClusterView

        logger.info("testGetters: start");
        assertNotNull(instance);
        logger.info("sling id=" + instance.getSlingId());
        assertNotNull(instance.getClusterViewService().getClusterView());

        ClusterView cv = instance.getClusterViewService().getClusterView();
        logger.info("cluster view: id=" + cv.getId());
        assertNotNull(cv.getId());
        assertNotSame(cv.getId(), "");

        List<InstanceDescription> instances = cv.getInstances();
        assertNotNull(instances);
        assertTrue(instances.size() == 1);

        InstanceDescription myInstance = instances.get(0);
        assertNotNull(myInstance);
View Full Code Here

Examples of org.apache.sling.discovery.ClusterView

    }

    @Test
    public void testBootstrap() throws Throwable {
        logger.info("testBootstrap: start");
        ClusterView initialClusterView = instance.getClusterViewService()
                .getClusterView();
        assertNotNull(initialClusterView);

        AssertingTopologyEventListener ada = new AssertingTopologyEventListener();
        ada.addExpected(Type.TOPOLOGY_INIT);
        instance.bindTopologyEventListener(ada);
        assertEquals(1, ada.getEvents().size());
        TopologyEvent initEvent = ada.getEvents().remove(0);
        assertNotNull(initEvent);

        assertEquals(initialClusterView.getId(), initEvent.getNewView()
                .getClusterViews().iterator().next().getId());
        assertEquals(initialClusterView.getInstances().get(0).getSlingId(),
                initEvent.getNewView().getLocalInstance().getSlingId());

        // hard assumption that the class we get is an
        // IsolatedInstanceDescription
        // this is because we dont have any established clusterview yet - hence
        // still entirely isolated
        assertEquals(IsolatedInstanceDescription.class, initialClusterView
                .getInstances().get(0).getClass());
        assertEquals(IsolatedInstanceDescription.class, instance
                .getClusterViewService().getClusterView().getInstances().get(0)
                .getClass());
        instance.runHeartbeatOnce();
View Full Code Here

Examples of org.apache.sling.discovery.ClusterView

                    "DiscoveryService not yet initialized with IClusterViewService");
        }
        // create a new topology view
        final TopologyViewImpl topology = new TopologyViewImpl();

        final ClusterView localClusterView = clusterViewService.getClusterView();

        final List<InstanceDescription> localInstances = localClusterView.getInstances();
        topology.addInstances(localInstances);

        Collection<InstanceDescription> attachedInstances = announcementRegistry
                .listInstances(localClusterView);
        topology.addInstances(attachedInstances);
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.