Examples of HubInfo


Examples of org.apache.hedwig.server.topics.HubInfo

                        logErrorAndFinishOperation("Could not read ownership for topic " + topic.toStringUtf8(),
                                callback, ctx, rc);
                        return;
                    }

                    HubInfo owner = null;
                    try {
                        byte[] data = value.getValue().getField(OWNER_FIELD);
                        if (data != null) {
                            owner = HubInfo.parse(new String(data));
                        }
View Full Code Here

Examples of org.apache.hedwig.server.topics.HubInfo

            }
        }

        protected boolean describeTopic(String topic) throws Exception {
            ByteString btopic = ByteString.copyFromUtf8(topic);
            HubInfo owner = admin.getTopicOwner(btopic);
            List<LedgerRange> ranges = admin.getTopicLedgers(btopic);
            Map<ByteString, SubscriptionData> states = admin.getTopicSubscriptions(btopic);

            System.out.println("===== Topic Information : " + topic + " =====");
            System.out.println();
            System.out.println("Owner : " + (owner == null ? "NULL" :
                               owner.toString().trim().replaceAll("\n", ", ")));
            System.out.println();

            // print ledgers
            printTopicLedgers(ranges);
            // print subscriptions
View Full Code Here

Examples of org.apache.hedwig.server.topics.HubInfo

                        KeeperException e = ZkUtils.logErrorAndCreateZKException("Could not read ownership for topic: "
                                            + topic.toStringUtf8(), path, rc);
                        callback.operationFailed(ctx, new PubSubException.ServiceDownException(e));
                        return;
                    }
                    HubInfo owner = null;
                    try {
                        owner = HubInfo.parse(new String(data));
                    } catch (HubInfo.InvalidHubInfoException ihie) {
                        logger.warn("Failed to parse hub info for topic " + topic.toStringUtf8() + " : ", ihie);
                    }
View Full Code Here

Examples of org.apache.hedwig.server.topics.HubInfo

                byte[] data = zk.getData(zkHubPath, false, stat);
                if (data == null) {
                    continue;
                }
                HubLoad load = HubLoad.parse(new String(data));
                HubInfo info = new HubInfo(addr, stat.getCzxid());
                hubs.put(addr, new HubStats(info, load));
            } catch (KeeperException ke) {
                LOG.warn("Couldn't read hub data from ZooKeeper", ke);
            } catch (InterruptedException ie) {
                LOG.warn("Interrupted during read", ie);
View Full Code Here

Examples of org.apache.hedwig.server.topics.HubInfo

        StubCallback<Versioned<HubInfo>> readCallback = new StubCallback<Versioned<HubInfo>>();
        StubCallback<Version> writeCallback = new StubCallback<Version>();
        StubCallback<Void> deleteCallback = new StubCallback<Void>();

        Either<Version, PubSubException> res;
        HubInfo owner = new HubInfo(new HedwigSocketAddress("127.0.0.1", 8008), 999);

        // Write non-existed owner info
        toManager.writeOwnerInfo(topic, owner, Version.NEW, writeCallback, null);
        res = writeCallback.queue.take();
        Assert.assertEquals(null, res.right());
        Version v1 = res.left();

        // read owner info
        toManager.readOwnerInfo(topic, readCallback, null);
        Versioned<HubInfo> hubInfo = readCallback.queue.take().left();
        Assert.assertEquals(Version.Occurred.CONCURRENTLY, v1.compare(hubInfo.getVersion()));
        Assert.assertEquals(owner, hubInfo.getValue());

        HubInfo newOwner = new HubInfo(new HedwigSocketAddress("127.0.0.1", 8008), 1000);

        // write exsited owner info with null version
        toManager.writeOwnerInfo(topic, newOwner, Version.NEW, writeCallback, null);
        res = writeCallback.queue.take();
        Assert.assertNotNull(res.right());
        Assert.assertTrue(res.right() instanceof PubSubException.TopicOwnerInfoExistsException);

        // write existed owner info with right version
        toManager.writeOwnerInfo(topic, newOwner, v1, writeCallback, null);
        res = writeCallback.queue.take();
        Assert.assertEquals(null, res.right());
        Version v2 = res.left();
        Assert.assertEquals(Version.Occurred.AFTER, v2.compare(v1));

        // read owner info
        toManager.readOwnerInfo(topic, readCallback, null);
        hubInfo = readCallback.queue.take().left();
        Assert.assertEquals(Version.Occurred.CONCURRENTLY, v2.compare(hubInfo.getVersion()));
        Assert.assertEquals(newOwner, hubInfo.getValue());

        HubInfo newOwner2 = new HubInfo(new HedwigSocketAddress("127.0.0.1", 8008), 1001);

        // write existed owner info with bad version
        toManager.writeOwnerInfo(topic, newOwner2, v1,
                                 writeCallback, null);
        res = writeCallback.queue.take();
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.