Package org.voltdb.catalog

Examples of org.voltdb.catalog.Cluster


     */
    public static Collection<Partition> getLocalPartitions(Database catalog_db, int base_partition) {
        Set<Partition> partitions = new ListOrderedSet<Partition>();

        // First figure out what partition we are in the catalog
        Cluster catalog_clus = CatalogUtil.getCluster(catalog_db);
        assert (catalog_clus != null);
        Partition catalog_part = CatalogUtil.getPartitionById(catalog_clus, base_partition);
        assert (catalog_part != null);
        Site catalog_site = catalog_part.getParent();
        assert (catalog_site != null);
        Host catalog_host = catalog_site.getHost();
        assert (catalog_host != null);

        // Now look at what other partitions are on the same host that we are
        for (Site other_site : catalog_clus.getSites()) {
            if (other_site.getHost().equals(catalog_host) == false)
                continue;
            LOG.trace(catalog_host + " => " + CatalogUtil.debug(other_site.getPartitions()));
            CollectionUtil.addAll(partitions, other_site.getPartitions());
        } // FOR
View Full Code Here


       
        return (m);
    }
   
    public Map<String, Integer>[] getHostsInfo(boolean full) {
        Cluster catalog_clus = CatalogUtil.getCluster(this.catalog);
        Map<String, Integer> m[] = (Map<String, Integer>[])new Map<?, ?>[2];
        int idx = -1;
       
        m[++idx] = new LinkedHashMap<String, Integer>();
        m[idx].put("Hosts", catalog_clus.getHosts().size());
        m[idx].put("Sites", catalog_clus.getSites().size());
        m[idx].put("Partitions", CatalogUtil.getNumberOfPartitions(catalog_clus));
       
        return (m);
    }
View Full Code Here

        TreeMap<Integer, Integer> site_host = new TreeMap<Integer, Integer>();
        Iterator<Cluster> cluster_it = catalogDb.getCatalog().getClusters().iterator();
        int total_sites = 0;
        int host = 0;
        while (cluster_it.hasNext()) {
            Cluster c = cluster_it.next();
            Iterator<Host> host_it = c.getHosts().iterator();
            while (host_it.hasNext()) {
                Host h = host_it.next();
                Iterator<Site> site_it = CatalogUtil.getSitesForHost(h).iterator();
                while (site_it.hasNext()) {
                    site_host.put(site_it.next().getId(), host);
View Full Code Here

            } // FOR
            Catalog c = FixCatalog.cloneCatalog(catalog, cc);
            this.init(this.last_type, new CatalogContext(c, catalogContext.jarPath));
           
        }
        Cluster cluster = CatalogUtil.getCluster(catalog_db);
        assertEquals(num_partitions, cluster.getNum_partitions());
        assertEquals(num_partitions, catalogContext.numberOfPartitions);
    }
View Full Code Here

            String hostFormat = (num_hosts == 1 ? "localhost" : "host%02d");
            Catalog c = FixCatalog.cloneCatalog(catalog, hostFormat, num_hosts, num_sites, num_partitions);
            CatalogContext cc = new CatalogContext(c, catalogContext.jarPath);
            this.init(this.last_type, cc);
        }
        Cluster cluster = catalogContext.cluster;
        assertEquals(num_hosts, catalogContext.numberOfHosts);
        assertEquals((num_hosts * num_sites), catalogContext.numberOfSites);
        assertEquals((num_hosts * num_sites * num_partitions), catalogContext.numberOfPartitions);
        assertEquals((num_hosts * num_sites * num_partitions), cluster.getNum_partitions());
    }
View Full Code Here

     */
    public void testGetLocalPartitions() throws Exception {
        //
        // Add in some fake partitions
        //
        Cluster cluster = catalogContext.cluster;
        assertNotNull(cluster);
        Map<Host, Set<Partition>> host_partitions = new HashMap<Host, Set<Partition>>();

        for (Host catalog_host : cluster.getHosts()) {
            host_partitions.put(catalog_host, new HashSet<Partition>());
            for (Site catalog_site : CatalogUtil.getSitesForHost(catalog_host)) {
                for (Partition catalog_part : catalog_site.getPartitions()) {
                    host_partitions.get(catalog_host).add(catalog_part);
                } // FOR
View Full Code Here

    /**
     * testGetSitesForHost
     */
    public void testGetSitesForHost() throws Exception {
        Map<Host, List<Site>> host_sites = new HashMap<Host, List<Site>>();
        Cluster catalog_clus = catalogContext.cluster;

        for (Site catalog_site : catalog_clus.getSites()) {
            Host catalog_host = catalog_site.getHost();
            assertNotNull(catalog_host);
            if (!host_sites.containsKey(catalog_host)) {
                host_sites.put(catalog_host, new ArrayList<Site>());
            }
            host_sites.get(catalog_host).add(catalog_site);
        } // FOR

        for (Host catalog_host : catalog_clus.getHosts()) {
            Collection<Site> sites = CatalogUtil.getSitesForHost(catalog_host);
            Collection<Site> expected = host_sites.get(catalog_host);
            assertEquals(expected.size(), sites.size());
            assert (sites.containsAll(expected));
        } // FOR
View Full Code Here

    /**
     * testGetCluster
     */
    @SuppressWarnings("deprecation")
    public void testGetCluster() {
        Cluster catalog_clus = catalogContext.cluster;
        assertNotNull(catalog_clus);

        Set<Cluster> clusters = new HashSet<Cluster>();
        for (Cluster c : catalog.getClusters()) {
            clusters.add(c);
View Full Code Here

                                long value = table.getLong(index);
                                assert (value < Long.MAX_VALUE);
                                break;
                            }
                            case STRING: {
                                Cluster catalog_clus = CatalogUtil.getCluster(catalog);
                                // Host catalog_host =
                                // catalog_clus.getHosts().get("XYZ");
                                // List<Site> catalog_sites =
                                // CatalogUtil.getSitesForHost(catalog_host);
                                // catalog_sites.get(0).getPartitions();
View Full Code Here

                                long value = table.getLong(index);
                                assert(value < Long.MAX_VALUE);
                                break;
                            }
                            case STRING: {
                                Cluster catalog_clus = CatalogUtil.getCluster(catalog);
//                              Host catalog_host = catalog_clus.getHosts().get("XYZ");
//                              List<Site> catalog_sites = CatalogUtil.getSitesForHost(catalog_host);
//                              catalog_sites.get(0).getPartitions();
//                              int a_id = 20;
//                              TheHashinator.hashToPartition(a_id, catalog_clus.getNum_partitions());
View Full Code Here

TOP

Related Classes of org.voltdb.catalog.Cluster

Copyright © 2018 www.massapicom. 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.