Package com.addthis.meshy.service.message

Examples of com.addthis.meshy.service.message.InternalHandler


                close();
                log.info("Shutdown hook complete.");
            }
        };
        Runtime.getRuntime().addShutdownHook(shutdownThread);
        messageFileSystem.addPath("/meshy/" + getUUID() + "/stats", new InternalHandler() {
            @Override
            public byte[] handleMessageRequest(String fileName, Map<String, String> options) {
                StringBuilder sb = new StringBuilder();
                for (String line : group.getLastStats()) {
                    sb.append(line);
                    sb.append("\n");
                }
                return Bytes.toBytes(sb.toString());
            }
        });
        messageFileSystem.addPath("/meshy/statsMap", new InternalHandler() {
            @Override
            public byte[] handleMessageRequest(String fileName, Map<String, String> options) {
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                Map<String, Integer> stats = group.getLastStatsMap();
                try {
View Full Code Here


        addMessageFileSystemPaths();
        initialized = true;
    }

    private void addMessageFileSystemPaths() {
        messageFileSystem.addPath("/meshy/" + getUUID() + "/stats", new InternalHandler() {
            @Override
            public byte[] handleMessageRequest(String fileName, Map<String, String> options) {
                StringBuilder sb = new StringBuilder();
                for (String line : group.getLastStats()) {
                    sb.append(line);
                    sb.append("\n");
                }
                return Bytes.toBytes(sb.toString());
            }
        });
        messageFileSystem.addPath("/meshy/statsMap", new InternalHandler() {
            @Override
            public byte[] handleMessageRequest(String fileName, Map<String, String> options) {
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                Map<String, Integer> stats = group.getLastStatsMap();
                try {
                    Bytes.writeInt(stats.size(), out);
                    for (Map.Entry<String, Integer> e : stats.entrySet()) {
                        Bytes.writeString(e.getKey(), out);
                        Bytes.writeInt(e.getValue(), out);
                    }
                } catch (IOException e) {
                    //ByteArrayOutputStreams do not throw IOExceptions
                }
                return out.toByteArray();
            }
        });
        messageFileSystem.addPath("/meshy/host/ban", new InternalHandler() {
            /**
             * If host option exists, then ban that host. Otherwise, list currently
             * banned hosts.
             */
            @Override
View Full Code Here

TOP

Related Classes of com.addthis.meshy.service.message.InternalHandler

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.