Search in sources :

Example 41 with Stopwatch

use of com.ms.silverking.time.Stopwatch in project SilverKing by Morgan-Stanley.

the class MessageGroupTest method runQueueingConnectionTestClient.

private void runQueueingConnectionTestClient(double durationSeconds) throws IOException {
    MessageGroup msg;
    Stopwatch sw;
    Stopwatch displaySW;
    // msg = createMessage(NumConversion.intToBytes(index));
    sw = new SimpleStopwatch();
    displaySW = new SimpleStopwatch();
    do {
        msg = createMessage(NumConversion.intToBytes(clientPort));
        // System.out.println("Sending");
        messagesSent.incrementAndGet();
        paServer.send(serverAddr, msg, false, Long.MAX_VALUE);
        try {
            semaphore.acquire();
        } catch (InterruptedException ie) {
        }
        // rewindBuffers(msg);
        if (displaySW.getSplitSeconds() > displayIntervalSeconds) {
            displayStats(sw.getSplitSeconds());
            displaySW.reset();
        }
    } while (sw.getSplitSeconds() < durationSeconds);
    sw.stop();
    displayStats(sw.getElapsedSeconds());
}
Also used : MessageGroup(com.ms.silverking.cloud.dht.net.MessageGroup) Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch)

Example 42 with Stopwatch

use of com.ms.silverking.time.Stopwatch in project SilverKing by Morgan-Stanley.

the class JVMMonitor method run.

public void run() {
    Stopwatch displaySW;
    ThreadUtil.randomSleep(minUpdateIntervalMillis);
    finalizationSW.reset();
    displaySW = new SimpleStopwatch();
    while (running) {
        try {
            monitor();
            if (display) {
                boolean displayTriggered;
                displayTriggered = false;
                if (displaySW.getSplitMillis() > maxUpdateIntervalMillis) {
                    displayTriggered = true;
                }
                if (deltaTriggered) {
                    displayTriggered = true;
                }
                if (displayTriggered) {
                    deltaTriggered = false;
                    displaySW.reset();
                    displayStatus();
                }
            }
            ThreadUtil.sleep(minUpdateIntervalMillis);
        } catch (Exception e) {
            Log.logErrorSevere(e, "JVMMonitor", "run");
            ThreadUtil.pauseAfterException();
        }
    }
}
Also used : SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch) Stopwatch(com.ms.silverking.time.Stopwatch) SimpleStopwatch(com.ms.silverking.time.SimpleStopwatch)

Aggregations

Stopwatch (com.ms.silverking.time.Stopwatch)42 SimpleStopwatch (com.ms.silverking.time.SimpleStopwatch)41 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)7 IOException (java.io.IOException)5 ByteBuffer (java.nio.ByteBuffer)5 DHTSession (com.ms.silverking.cloud.dht.client.DHTSession)2 DHTKeyIntEntry (com.ms.silverking.cloud.dht.collection.DHTKeyIntEntry)2 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)2 StatSeries (com.ms.silverking.numeric.StatSeries)2 SimpleTimer (com.ms.silverking.time.SimpleTimer)2 Timer (com.ms.silverking.time.Timer)2 FileOutputStream (java.io.FileOutputStream)2 Date (java.util.Date)2 Random (java.util.Random)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 GetOptions (com.ms.silverking.cloud.dht.GetOptions)1 NamespaceOptions (com.ms.silverking.cloud.dht.NamespaceOptions)1 NamespaceVersionMode (com.ms.silverking.cloud.dht.NamespaceVersionMode)1 PutOptions (com.ms.silverking.cloud.dht.PutOptions)1 SessionOptions (com.ms.silverking.cloud.dht.SessionOptions)1