Package org.apache.giraph.examples

Examples of org.apache.giraph.examples.LongSumAggregator


                LongSumAggregator.class);
        }

        @Override
        public void preSuperstep() {
            LongSumAggregator superstepBytesAggregator =
                (LongSumAggregator) getAggregator(AGG_SUPERSTEP_TOTAL_BYTES);
            LongSumAggregator superstepMessagesAggregator =
                (LongSumAggregator) getAggregator(AGG_SUPERSTEP_TOTAL_MESSAGES);
            LongSumAggregator superstepMillisAggregator =
                (LongSumAggregator) getAggregator(AGG_SUPERSTEP_TOTAL_MILLIS);
            LongSumAggregator workersAggregator =
                (LongSumAggregator) getAggregator(WORKERS);

            // For timing and tracking the supersteps
            // - superstep 0 starts the time, but cannot display any stats
            //   since nothing has been aggregated yet
            // - supersteps > 0 can display the stats
            if (getSuperstep() == 0) {
                startSuperstepMillis = System.currentTimeMillis();
            } else {
                totalBytes +=
                        superstepBytesAggregator.getAggregatedValue().get();
                totalMessages +=
                        superstepMessagesAggregator.getAggregatedValue().get();
                totalMillis +=
                        superstepMillisAggregator.getAggregatedValue().get();
                double superstepMegabytesPerSecond =
                        superstepBytesAggregator.getAggregatedValue().get() *
                        workersAggregator.getAggregatedValue().get() *
                        1000d / 1024d / 1024d /
                        superstepMillisAggregator.getAggregatedValue().get();
                double megabytesPerSecond = totalBytes *
                        workersAggregator.getAggregatedValue().get() *
                        1000d / 1024d / 1024d / totalMillis;
                double superstepMessagesPerSecond =
                        superstepMessagesAggregator.getAggregatedValue().get() *
                        workersAggregator.getAggregatedValue().get() * 1000d /
                        superstepMillisAggregator.getAggregatedValue().get();
                double messagesPerSecond = totalMessages *
                        workersAggregator.getAggregatedValue().get() * 1000d /
                        totalMillis;
                if (LOG.isInfoEnabled()) {
                    LOG.info("Outputing statistics for superstep " +
                             getSuperstep());
                    LOG.info(AGG_SUPERSTEP_TOTAL_BYTES + " : " +
                             superstepBytesAggregator.getAggregatedValue());
                    LOG.info(AGG_TOTAL_BYTES + " : " + totalBytes);
                    LOG.info(AGG_SUPERSTEP_TOTAL_MESSAGES + " : " +
                             superstepMessagesAggregator.getAggregatedValue());
                    LOG.info(AGG_TOTAL_MESSAGES + " : " + totalMessages);
                    LOG.info(AGG_SUPERSTEP_TOTAL_MILLIS + " : " +
                             superstepMillisAggregator.getAggregatedValue());
                    LOG.info(AGG_TOTAL_MILLIS + " : " + totalMillis);
                    LOG.info(WORKERS + " : " +
                             workersAggregator.getAggregatedValue());
                    LOG.info("Superstep megabytes / second = " +
                             superstepMegabytesPerSecond);
                    LOG.info("Total megabytes / second = " +
                             megabytesPerSecond);
                    LOG.info("Superstep messages / second = " +
                             superstepMessagesPerSecond);
                    LOG.info("Total messages / second = " +
                             messagesPerSecond);
                    LOG.info("Superstep megabytes / second / worker = " +
                             superstepMegabytesPerSecond /
                             workersAggregator.getAggregatedValue().get());
                    LOG.info("Total megabytes / second / worker = " +
                             megabytesPerSecond /
                             workersAggregator.getAggregatedValue().get());
                    LOG.info("Superstep messages / second / worker = " +
                             superstepMessagesPerSecond /
                             workersAggregator.getAggregatedValue().get());
                    LOG.info("Total messages / second / worker = " +
                             messagesPerSecond /
                             workersAggregator.getAggregatedValue().get());
                }
            }

            superstepBytesAggregator.setAggregatedValue(
                new LongWritable(0L));
            superstepMessagesAggregator.setAggregatedValue(
                new LongWritable(0L));
            workersAggregator.setAggregatedValue(
                new LongWritable(1L));
            useAggregator(AGG_SUPERSTEP_TOTAL_BYTES);
            useAggregator(AGG_SUPERSTEP_TOTAL_MILLIS);
            useAggregator(AGG_SUPERSTEP_TOTAL_MESSAGES);
            useAggregator(WORKERS);
View Full Code Here


            useAggregator(WORKERS);
        }

        @Override
        public void postSuperstep() {
            LongSumAggregator superstepMillisAggregator =
                (LongSumAggregator) getAggregator(AGG_SUPERSTEP_TOTAL_MILLIS);
            long endSuperstepMillis = System.currentTimeMillis();
            long superstepMillis = endSuperstepMillis - startSuperstepMillis;
            startSuperstepMillis = endSuperstepMillis;
            superstepMillisAggregator.setAggregatedValue(
                new LongWritable(superstepMillis));
        }
View Full Code Here

        @Override
        public void compute(Iterator<BytesWritable> msgIterator) {
            RandomMessageBenchmarkWorkerContext workerContext =
                (RandomMessageBenchmarkWorkerContext) getWorkerContext();
            LongSumAggregator superstepBytesAggregator =
                (LongSumAggregator) getAggregator(AGG_SUPERSTEP_TOTAL_BYTES);
            LongSumAggregator superstepMessagesAggregator =
                (LongSumAggregator) getAggregator(AGG_SUPERSTEP_TOTAL_MESSAGES);
            if (getSuperstep() < workerContext.getNumSupersteps()) {
                for (int i = 0; i < workerContext.getNumMessagePerEdge();
                        i++) {
                    workerContext.randomizeMessageBytes();
                    sendMsgToAllEdges(
                        new BytesWritable(workerContext.getMessageBytes()));
                    long bytesSent = workerContext.getMessageBytes().length *
                        getNumOutEdges();
                    superstepBytesAggregator.aggregate(bytesSent);
                    superstepMessagesAggregator.aggregate(getNumOutEdges());
                }
            } else {
                voteToHalt();
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.giraph.examples.LongSumAggregator

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.