當前位置: 首頁>>代碼示例>>Java>>正文


Java BookieSocketAddress類代碼示例

本文整理匯總了Java中org.apache.bookkeeper.net.BookieSocketAddress的典型用法代碼示例。如果您正苦於以下問題:Java BookieSocketAddress類的具體用法?Java BookieSocketAddress怎麽用?Java BookieSocketAddress使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BookieSocketAddress類屬於org.apache.bookkeeper.net包,在下文中一共展示了BookieSocketAddress類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getZkBookieRackMappingCache

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
public static ZooKeeperDataCache<Map<String, Map<BookieSocketAddress, BookieInfo>>> getZkBookieRackMappingCache(
        ZooKeeperCache zkCache) {
    ZooKeeperDataCache<Map<String, Map<BookieSocketAddress, BookieInfo>>> zkDataCache = new ZooKeeperDataCache<Map<String, Map<BookieSocketAddress, BookieInfo>>>(
            zkCache) {

        @Override
        public Map<String, Map<BookieSocketAddress, BookieInfo>> deserialize(String key, byte[] content)
                throws Exception {
            LOG.info("Reloading the bookie rack affinity mapping cache.");
            if (LOG.isDebugEnabled()) {
                LOG.debug("Loading the bookie mappings with bookie info data: {}", new String(content));
            }
            return jsonMapper.readValue(content, typeRef);
        }

    };
    return zkDataCache;
}
 
開發者ID:apache,項目名稱:incubator-pulsar,代碼行數:19,代碼來源:ZkBookieRackAffinityMapping.java

示例2: getRack

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
private String getRack(BookieSocketAddress bookieAddress) {
    String rack = NetworkTopology.DEFAULT_RACK;
    try {
        if (bookieMappingCache != null) {
            Map<String, Map<BookieSocketAddress, BookieInfo>> allGroupsBookieMapping = bookieMappingCache
                    .get(BOOKIE_INFO_ROOT_PATH)
                    .orElseThrow(() -> new KeeperException.NoNodeException(BOOKIE_INFO_ROOT_PATH));
            for (Map<BookieSocketAddress, BookieInfo> bookieMapping : allGroupsBookieMapping.values()) {
                BookieInfo bookieInfo = bookieMapping.get(bookieAddress);
                if (bookieInfo != null) {
                    rack = bookieInfo.getRack();
                    if (!rack.startsWith("/")) {
                        rack = "/" + rack;
                    }
                    break;
                }
            }
        }
    } catch (Exception e) {
        LOG.warn("Error getting bookie info from zk, using default rack node {}: {}", rack, e.getMessage());
    }
    return rack;
}
 
開發者ID:apache,項目名稱:incubator-pulsar,代碼行數:24,代碼來源:ZkBookieRackAffinityMapping.java

示例3: getBlacklistedBookies

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
private Set<BookieSocketAddress> getBlacklistedBookies() {
    Set<BookieSocketAddress> blacklistedBookies = new HashSet<BookieSocketAddress>();
    try {
        if (bookieMappingCache != null) {
            Map<String, Map<BookieSocketAddress, BookieInfo>> allGroupsBookieMapping = bookieMappingCache
                    .getData(ZkBookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, this)
                    .orElseThrow(() -> new KeeperException.NoNodeException(
                            ZkBookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH));
            for (String group : allGroupsBookieMapping.keySet()) {
                if (!isolationGroups.contains(group)) {
                    for (BookieSocketAddress bookieAddress : allGroupsBookieMapping.get(group).keySet()) {
                        blacklistedBookies.add(bookieAddress);
                    }
                }
            }
        }
    } catch (Exception e) {
        LOG.warn("Error getting bookie isolation info from zk: {}", e.getMessage());
    }
    return blacklistedBookies;
}
 
開發者ID:apache,項目名稱:incubator-pulsar,代碼行數:22,代碼來源:ZkIsolatedBookieEnsemblePlacementPolicy.java

示例4: bkQuery

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
private int bkQuery(BookKeeperAdmin bkAdmin, Set<BookieSocketAddress> bookieAddrs)
        throws InterruptedException, BKException {
    SortedMap<Long, LedgerMetadata> ledgersContainBookies =
            bkAdmin.getLedgersContainBookies(bookieAddrs);
    System.err.println("NOTE: Bookies in inspection list are marked with '*'.");
    for (Map.Entry<Long, LedgerMetadata> ledger : ledgersContainBookies.entrySet()) {
        System.out.println("ledger " + ledger.getKey() + " : " + ledger.getValue().getState());
        Map<Long, Integer> numBookiesToReplacePerEnsemble =
                inspectLedger(ledger.getValue(), bookieAddrs);
        System.out.print("summary: [");
        for (Map.Entry<Long, Integer> entry : numBookiesToReplacePerEnsemble.entrySet()) {
            System.out.print(entry.getKey() + "=" + entry.getValue() + ", ");
        }
        System.out.println("]");
        System.out.println();
    }
    System.out.println("Done");
    return 0;
}
 
開發者ID:twitter,項目名稱:distributedlog,代碼行數:20,代碼來源:DistributedLogTool.java

示例5: inspectLedger

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
private Map<Long, Integer> inspectLedger(LedgerMetadata metadata, Set<BookieSocketAddress> bookiesToInspect) {
    Map<Long, Integer> numBookiesToReplacePerEnsemble = new TreeMap<Long, Integer>();
    for (Map.Entry<Long, ArrayList<BookieSocketAddress>> ensemble : metadata.getEnsembles().entrySet()) {
        ArrayList<BookieSocketAddress> bookieList = ensemble.getValue();
        System.out.print(ensemble.getKey() + ":\t");
        int numBookiesToReplace = 0;
        for (BookieSocketAddress bookie: bookieList) {
            System.out.print(bookie.toString());
            if (bookiesToInspect.contains(bookie)) {
                System.out.print("*");
                ++numBookiesToReplace;
            } else {
                System.out.print(" ");
            }
            System.out.print(" ");
        }
        System.out.println();
        numBookiesToReplacePerEnsemble.put(ensemble.getKey(), numBookiesToReplace);
    }
    return numBookiesToReplacePerEnsemble;
}
 
開發者ID:twitter,項目名稱:distributedlog,代碼行數:22,代碼來源:DistributedLogTool.java

示例6: bkRecovery

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
private int bkRecovery(final LinkedBlockingQueue<Long> ledgers, final Set<BookieSocketAddress> bookieAddrs,
                       final boolean dryrun, final boolean skipOpenLedgers)
        throws Exception {
    return runBKCommand(new BKCommandRunner() {
        @Override
        public int run(ZooKeeperClient zkc, BookKeeperClient bkc) throws Exception {
            BookKeeperAdmin bkAdmin = new BookKeeperAdmin(bkc.get());
            try {
                bkRecovery(bkAdmin, ledgers, bookieAddrs, dryrun, skipOpenLedgers);
                return 0;
            } finally {
                bkAdmin.close();
            }
        }
    });
}
 
開發者ID:twitter,項目名稱:distributedlog,代碼行數:17,代碼來源:DistributedLogTool.java

示例7: onClusterChanged

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
@Override
public synchronized Set<BookieSocketAddress> onClusterChanged(Set<BookieSocketAddress> writableBookies,
    Set<BookieSocketAddress> readOnlyBookies) {
    HashSet<BookieSocketAddress> deadBookies;
    deadBookies = new HashSet<>(knownBookies);
    deadBookies.removeAll(writableBookies);
    // readonly bookies should not be treated as dead bookies
    deadBookies.removeAll(readOnlyBookies);
    knownBookies = writableBookies;
    return deadBookies;
}
 
開發者ID:diennea,項目名稱:herddb,代碼行數:12,代碼來源:PreferLocalBookiePlacementPolicy.java

示例8: replaceBookie

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
@Override
public BookieSocketAddress replaceBookie(int ensembleSize,
    int writeQuorumSize,
    int ackQuorumSize,
    Map<String, byte[]> customMetadata,
    Collection<BookieSocketAddress> currentEnsemble,
    BookieSocketAddress bookieToReplace,
    Set<BookieSocketAddress> excludeBookies)
    throws BKNotEnoughBookiesException {
    excludeBookies.addAll(currentEnsemble);
    ArrayList<BookieSocketAddress> addresses = newEnsemble(1, 1, 1, customMetadata, excludeBookies);
    return addresses.get(0);
}
 
開發者ID:diennea,項目名稱:herddb,代碼行數:14,代碼來源:PreferLocalBookiePlacementPolicy.java

示例9: reorderReadSequence

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
@Override
public DistributionSchedule.WriteSet reorderReadSequence(
    ArrayList<BookieSocketAddress> ensemble,
    Map<BookieSocketAddress, Long> bookieFailureHistory,
    DistributionSchedule.WriteSet writeSet) {
    return writeSet;
}
 
開發者ID:diennea,項目名稱:herddb,代碼行數:8,代碼來源:PreferLocalBookiePlacementPolicy.java

示例10: reorderReadLACSequence

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
@Override
public DistributionSchedule.WriteSet reorderReadLACSequence(
    ArrayList<BookieSocketAddress> ensemble,
    Map<BookieSocketAddress, Long> bookieFailureHistory,
    DistributionSchedule.WriteSet writeSet) {
    return writeSet;
}
 
開發者ID:diennea,項目名稱:herddb,代碼行數:8,代碼來源:PreferLocalBookiePlacementPolicy.java

示例11: testEnsamblePolicySingle

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
@Test
public void testEnsamblePolicySingle() throws Exception {

    BookieSocketAddress a = new BookieSocketAddress("a.localhost", 3181);

    Set<BookieSocketAddress> writableBookies = new HashSet<>();
    writableBookies.add(a);

    registerLocalBookieAddress.invoke(null, a);

    try {
        Set<BookieSocketAddress> readOnlyBookies = Collections.emptySet();

        PreferLocalBookiePlacementPolicy policy = new PreferLocalBookiePlacementPolicy();
        Set<BookieSocketAddress> deadBookies = policy.onClusterChanged(writableBookies, readOnlyBookies);

        assertTrue(deadBookies.isEmpty());

        ArrayList<BookieSocketAddress> ensemble =
                policy.newEnsemble(1, 1, 1, Collections.emptyMap(), Collections.emptySet());
        System.out.println(ensemble);
        assertEquals(1, ensemble.size());
        assertEquals(a, ensemble.get(0));
    } finally {
        unregisterLocalBookieAddress.invoke(null, a);
    }
}
 
開發者ID:diennea,項目名稱:herddb,代碼行數:28,代碼來源:PreferLocalBookiePlacementPolicyTest.java

示例12: testEnsamblePolicyMultiple

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
@Test
public void testEnsamblePolicyMultiple() throws Exception {

    BookieSocketAddress a = new BookieSocketAddress("a.localhost", 3181);
    BookieSocketAddress b = new BookieSocketAddress("b.localhost", 3181);
    BookieSocketAddress c = new BookieSocketAddress("c.localhost", 3181);
    BookieSocketAddress d = new BookieSocketAddress("d.localhost", 3181);
    BookieSocketAddress e = new BookieSocketAddress("e.localhost", 3181);

    Set<BookieSocketAddress> writableBookies = new HashSet<>();
    writableBookies.add(a);
    writableBookies.add(b);
    writableBookies.add(c);
    writableBookies.add(d);
    writableBookies.add(e);

    registerLocalBookieAddress.invoke(null, c);

    try {
        Set<BookieSocketAddress> readOnlyBookies = Collections.emptySet();

        PreferLocalBookiePlacementPolicy policy = new PreferLocalBookiePlacementPolicy();
        Set<BookieSocketAddress> deadBookies = policy.onClusterChanged(writableBookies, readOnlyBookies);

        assertTrue(deadBookies.isEmpty());

        ArrayList<BookieSocketAddress> ensemble =
                policy.newEnsemble(3, 2, 2, Collections.emptyMap(), Collections.emptySet());
        System.out.println(ensemble);
        assertEquals(3, ensemble.size());
        assertEquals(c, ensemble.get(0));
    } finally {
        unregisterLocalBookieAddress.invoke(null, c);
    }
}
 
開發者ID:diennea,項目名稱:herddb,代碼行數:36,代碼來源:PreferLocalBookiePlacementPolicyTest.java

示例13: getAndSetZkCache

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
private ZooKeeperDataCache<Map<String, Map<BookieSocketAddress, BookieInfo>>> getAndSetZkCache(Configuration conf) {
    ZooKeeperCache zkCache = null;
    if (conf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE) != null) {
        zkCache = (ZooKeeperCache) conf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE);
    } else {
        int zkTimeout;
        String zkServers;
        if (conf instanceof ClientConfiguration) {
            zkTimeout = ((ClientConfiguration) conf).getZkTimeout();
            zkServers = ((ClientConfiguration) conf).getZkServers();
            ZooKeeperWatcherBase w = new ZooKeeperWatcherBase(zkTimeout) {
            };
            try {
                ZooKeeper zkClient = ZkUtils.createConnectedZookeeperClient(zkServers, w);
                zkCache = new ZooKeeperCache(zkClient) {
                };
                conf.addProperty(ZooKeeperCache.ZK_CACHE_INSTANCE, zkCache);
            } catch (Exception e) {
                LOG.error("Error creating zookeeper client", e);
            }
        } else {
            LOG.error("No zk configurations available");
        }
    }
    ZooKeeperDataCache<Map<String, Map<BookieSocketAddress, BookieInfo>>> zkDataCache = getZkBookieRackMappingCache(
            zkCache);
    if (zkDataCache != null) {
        zkDataCache.registerListener(this);
    }
    return zkDataCache;
}
 
開發者ID:apache,項目名稱:incubator-pulsar,代碼行數:32,代碼來源:ZkBookieRackAffinityMapping.java

示例14: resolve

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
@Override
public List<String> resolve(List<BookieSocketAddress> bookieAddressList) {
    List<String> racks = new ArrayList<String>(bookieAddressList.size());
    for (BookieSocketAddress bookieAddress : bookieAddressList) {
        racks.add(getRack(bookieAddress));
    }
    return racks;
}
 
開發者ID:apache,項目名稱:incubator-pulsar,代碼行數:9,代碼來源:ZkBookieRackAffinityMapping.java

示例15: onUpdate

import org.apache.bookkeeper.net.BookieSocketAddress; //導入依賴的package包/類
@Override
public void onUpdate(String path, Map<String, Map<BookieSocketAddress, BookieInfo>> data, Stat stat) {
    if (rackawarePolicy != null) {
        LOG.info("Bookie rack info updated to {}. Notifying rackaware policy.", data.toString());
        List<BookieSocketAddress> bookieAddressList = new ArrayList<>();
        for (Map<BookieSocketAddress, BookieInfo> bookieMapping : data.values()) {
            bookieAddressList.addAll(bookieMapping.keySet());
        }
        rackawarePolicy.onBookieRackChange(bookieAddressList);
    }
}
 
開發者ID:apache,項目名稱:incubator-pulsar,代碼行數:12,代碼來源:ZkBookieRackAffinityMapping.java


注:本文中的org.apache.bookkeeper.net.BookieSocketAddress類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。