Example usage for org.joda.time Duration standardSeconds

List of usage examples for org.joda.time Duration standardSeconds

Introduction

In this page you can find the example usage for org.joda.time Duration standardSeconds.

Prototype

public static Duration standardSeconds(long seconds) 

Source Link

Document

Create a duration with the specified number of seconds assuming that there are the standard number of milliseconds in a second.

Usage

From source file:io.mesosphere.mesos.frameworks.cassandra.scheduler.PersistedCassandraFrameworkConfiguration.java

License:Apache License

@NotNull
public Duration healthCheckInterval() {
    return Duration.standardSeconds(get().getHealthCheckIntervalSeconds());
}

From source file:io.mesosphere.mesos.frameworks.cassandra.scheduler.PersistedCassandraFrameworkConfiguration.java

License:Apache License

@NotNull
public Duration bootstrapGraceTimeSeconds() {
    return Duration.standardSeconds(get().getBootstrapGraceTimeSeconds());
}

From source file:io.v.android.apps.syncslides.discovery.ParticipantPeer.java

License:Open Source License

/**
 * Make an RPC on the mServiceName to get title, snapshot, etc.
 *//*from   ww w  . j a va  2s  . com*/
@Override
public boolean refreshData() {
    if (mServiceName.equals(Unknown.SERVER_NAME)) {
        // Don't attempt refresh.
        return true;
    }
    Log.d(TAG, "refreshData");
    // Flush, since the server might have died and restarted, invalidating
    // cached endpoints.
    Log.d(TAG, "Flushing cache for service " + mServiceName);
    V23Manager.Singleton.get().flushServerFromCache(mServiceName);
    ParticipantClient client = ParticipantClientFactory.getParticipantClient(mServiceName);
    Log.d(TAG, "Got client = " + client.toString());
    try {
        Log.d(TAG, "Starting RPC to service \"" + mServiceName + "\"...");
        Presentation p = client
                .get(V23Manager.Singleton.get().getVContext().withTimeout(Duration.standardSeconds(5)));
        mDeck = mDeckFactory.make(p.getDeck(), p.getDeckId());
        mSyncgroupName = p.getSyncgroupName();
        mPresentationId = p.getPresentationId();
        mRefreshTime = DateTime.now();
        Log.d(TAG, "   Discovered:");
        Log.d(TAG, "               mDeck = " + mDeck);
        Log.d(TAG, "      mSyncgroupName = " + mSyncgroupName);
        Log.d(TAG, "     mPresentationId = " + mPresentationId);
        return true;
    } catch (VException e) {
        Log.d(TAG, "RPC failed, leaving current deck in place.");
        e.printStackTrace();
    }
    return false;
}

From source file:io.v.android.impl.google.services.beam.BeamActivity.java

License:Open Source License

@Override
public void onResume() {
    super.onResume();
    NdefMessage msgs[] = null;/*from  w  w w  .  j  a v a 2s.  c  om*/
    Intent intent = getIntent();

    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) {
        Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
        if (rawMsgs != null) {
            msgs = new NdefMessage[rawMsgs.length];
            for (int i = 0; i < rawMsgs.length; i++) {
                msgs[i] = (NdefMessage) rawMsgs[i];
            }
        }
    }
    if (msgs == null) {
        Log.d(TAG, "No ndef messages");
        finish();
        return;
    }
    VBeamManager.Data data = null;
    for (NdefMessage m : msgs) {
        data = VBeamManager.decodeMessage(m);
        if (data != null)
            break;
    }
    if (data == null) {
        Log.w(TAG, "Unable to deserialize data");
        finish();
        return;
    }
    Log.d(TAG, "connecting to " + data.name);
    VContext ctx = V.init(this).withTimeout(Duration.standardSeconds(2));
    Options opts = new Options();

    opts.set(OptionDefs.SERVER_AUTHORIZER, VSecurity.newPublicKeyAuthorizer(data.key));
    IntentBeamerClient client = IntentBeamerClientFactory.getIntentBeamerClient(data.name);
    ListenableFuture<IntentBeamerClient.GetIntentOut> out = client.getIntent(ctx, data.secret, opts);
    Futures.addCallback(out, new FutureCallback<IntentBeamerClient.GetIntentOut>() {
        @Override
        public void onSuccess(IntentBeamerClient.GetIntentOut result) {
            try {
                Log.d(TAG, "got intent " + result.intentUri);
                int flags = 0;
                if (result.intentUri.startsWith("intent:")) {
                    flags = Intent.URI_INTENT_SCHEME;
                } else {
                    flags = Intent.URI_ANDROID_APP_SCHEME;
                }
                Intent resultIntent = Intent.parseUri(result.intentUri, flags);
                resultIntent.putExtra(VBeamManager.EXTRA_VBEAM_PAYLOAD, result.payload);
                startActivity(resultIntent);
                finish();
            } catch (Throwable t) {
                t.printStackTrace();
            }
        }

        @Override
        public void onFailure(Throwable t) {
            t.printStackTrace();
            finish();
        }
    });
}

From source file:io.v.syncslidepresenter.Main.java

License:Open Source License

public void joinPresentation(final Presentation presentation, int joinTimeoutSeconds, String slideRowFormat)
        throws VException {
    Syncgroup syncgroup = db.getSyncgroup(presentation.getSyncgroupName());
    syncgroup.join(context.withTimeout(Duration.standardSeconds(joinTimeoutSeconds)),
            new SyncgroupMemberInfo((byte) 1, false));
    for (String member : syncgroup.getMembers(context).keySet()) {
        logger.info("Member: " + member);
    }// w  w w .  j  a  v  a  2s  .c o m

    for (KeyValue keyValue : presentations.scan(context, RowRange.prefix(""))) {
        System.out.println("Presentation: " + keyValue);
    }
    BatchDatabase batch = db.beginBatch(context, null);
    ResumeMarker marker = batch.getResumeMarker(context);
    String rowKey = Joiner.on("/").join(presentation.getDeckId(), presentation.getPresentationId(),
            "CurrentSlide");
    logger.info("going to watch row key " + rowKey);
    VIterable<WatchChange> changes = db.watch(context, presentations.name(), rowKey, marker);

    for (WatchChange change : changes) {
        logger.info("Change detected in " + change.getRowName());
        logger.info("Type: " + change.getChangeType());
        try {
            VCurrentSlide currentSlide = (VCurrentSlide) VomUtil.decode(change.getVomValue(),
                    VCurrentSlide.class);
            logger.info("Current slide: " + currentSlide);
            // Read the corresponding slide.
            String row = String.format(slideRowFormat, presentation.getDeckId(), currentSlide.getNum());
            VSlide slide = (VSlide) decks.getRow(row).get(context, VSlide.class);
            final BufferedImage image = ImageIO.read(new ByteArrayInputStream(slide.getThumbnail()));
            viewer.setImage(image);
        } catch (IOException | VException e) {
            logger.log(Level.WARNING, "exception encountered while handling change event", e);
        }
    }

    if (changes.error() != null) {
        logger.log(Level.WARNING, "Premature end of slide changes: " + changes.error());
    }
}

From source file:is.illuminati.block.spyros.garmin.model.Lap.java

License:Open Source License

/**
 * Get a list of all pauses in the lap./*  w  w  w  .  jav a2  s . c om*/
 * @return list of all pauses.
 */
public ImmutableList<Pause> getPauses() {
    ImmutableList.Builder<Pause> pausesBuilder = ImmutableList.builder();
    PeekingIterator<Track> it = Iterators.peekingIterator(tracks.iterator());
    while (it.hasNext()) {
        Track former = it.next();
        Track latter;
        if (it.hasNext()) {
            latter = it.peek();
        } else {
            break;
        }
        Duration gap = new Duration(former.getEndTime(), latter.getStartTime());
        if (gap.isLongerThan(Duration.standardSeconds(10))) {
            pausesBuilder.add(new Pause(former.getEndTime(), latter.getStartTime()));
        }
    }
    return pausesBuilder.build();
}

From source file:models.internal.NagiosExtension.java

License:Apache License

private NagiosExtension(final Builder builder) {
    _severity = builder._severity;//ww w.j a v  a  2  s.co m
    _notify = builder._notify;
    _maxCheckAttempts = builder._maxCheckAttempts;
    _freshnessThreshold = Duration.standardSeconds(builder._freshnessThresholdInSeconds);
}

From source file:net.schweerelos.timeline.ui.TimelinePanel.java

License:Open Source License

private Duration calculateSmallestVisibleDuration() {
    Duration visibleDuration = tModel.getDuration();
    float millisPerPixel = (float) visibleDuration.getMillis() / (float) getWidth();
    float secondsPerPixel = millisPerPixel / 1000;
    long minSeconds = (long) Math.ceil(secondsPerPixel * SHORTEST_VISIBLE_INTERVAL);
    return Duration.standardSeconds(minSeconds);
}

From source file:nz.co.testamation.testcommon.fixture.SomeFixture.java

License:Apache License

public static Duration someDuration() {
    return Duration.standardSeconds(someLong());
}

From source file:org.apache.apex.malhar.lib.dedup.TimeBasedDedupOperator.java

License:Apache License

@Override
public void setup(OperatorContext context) {
    MovingBoundaryTimeBucketAssigner timeBucketAssigner = new MovingBoundaryTimeBucketAssigner();
    timeBucketAssigner.setBucketSpan(Duration.standardSeconds(bucketSpan));
    timeBucketAssigner.setExpireBefore(Duration.standardSeconds(expireBefore));
    timeBucketAssigner.setReferenceInstant(new Instant(referenceInstant * 1000));
    managedState.setTimeBucketAssigner(timeBucketAssigner);
    super.setup(context);
}