当前位置: 首页>>代码示例>>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;未经允许,请勿转载。