Example usage for org.joda.time Duration standardMinutes

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

Introduction

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

Prototype

public static Duration standardMinutes(long minutes) 

Source Link

Document

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

Usage

From source file:gobblin.data.management.retention.policy.TimeBasedRetentionPolicy.java

License:Apache License

private static Duration getDuration(Config config) {
    Preconditions.checkArgument(/*from ww w  . j a va 2s. c  om*/
            config.hasPath(RETENTION_TIMEBASED_DURATION_KEY) || config.hasPath(RETENTION_MINUTES_KEY),
            String.format("Either %s or %s needs to be set", RETENTION_TIMEBASED_DURATION_KEY,
                    RETENTION_MINUTES_KEY));

    if (config.hasPath(RETENTION_TIMEBASED_DURATION_KEY)) {
        return parseDuration(config.getString(RETENTION_TIMEBASED_DURATION_KEY));
    } else {
        return Duration.standardMinutes(Long.parseLong(config.getString(RETENTION_MINUTES_KEY)));
    }
}

From source file:google.registry.config.ConfigModule.java

License:Open Source License

/**
 * Maximum amount of time it should ever take to upload an escrow deposit, before killing.
 *
 * @see google.registry.rde.RdeUploadAction
 *///from  www . j  av  a  2s  .  c o  m
@Provides
@Config("rdeUploadLockTimeout")
public static Duration provideRdeUploadLockTimeout() {
    return Duration.standardMinutes(30);
}

From source file:google.registry.config.ConfigModule.java

License:Open Source License

/**
 * Duration after watermark where we shouldn't deposit, because transactions might be pending.
 *
 * @see google.registry.rde.RdeStagingAction
 *///  w  ww  .j a  v  a  2s.  c o  m
@Provides
@Config("transactionCooldown")
public static Duration provideTransactionCooldown() {
    return Duration.standardMinutes(5);
}

From source file:google.registry.config.RegistryConfig.java

License:Open Source License

/** Returns the amount of time a singleton should be cached, before expiring. */
public static Duration getSingletonCacheRefreshDuration() {
    switch (RegistryEnvironment.get()) {
    case UNITTEST:
        // All cache durations are set to zero so that unit tests can update and then retrieve data
        // immediately without failure.
        return Duration.ZERO;
    default://from w  w w  .j  a  v  a2s. c o  m
        return Duration.standardMinutes(10);
    }
}

From source file:io.v.android.libs.discovery.ble.BlePlugin.java

License:Open Source License

public BlePlugin(Context androidContext) {
    this.androidContext = androidContext;
    cachedDevices = new DeviceCache(Duration.standardMinutes(1));
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (bluetoothAdapter == null || !bluetoothAdapter.isEnabled()) {
        return;/*w  ww  .j av  a 2s  .c  om*/
    }

    if (!hasPermission(Manifest.permission.ACCESS_COARSE_LOCATION)
            && !hasPermission(Manifest.permission.ACCESS_FINE_LOCATION)) {
        return;
    }
    isEnabled = true;
    bluetoothLeAdvertise = BluetoothAdapter.getDefaultAdapter().getBluetoothLeAdvertiser();
    bluetoothLeScanner = BluetoothAdapter.getDefaultAdapter().getBluetoothLeScanner();
    BluetoothManager manager = (BluetoothManager) androidContext.getSystemService(Context.BLUETOOTH_SERVICE);
    bluetoothGattServer = manager.openGattServer(androidContext, new BluetoothGattServerCallback() {
        @Override
        public void onConnectionStateChange(BluetoothDevice device, int status, int newState) {
            super.onConnectionStateChange(device, status, newState);
        }

        @Override
        public void onCharacteristicReadRequest(BluetoothDevice device, int requestId, int offset,
                BluetoothGattCharacteristic characteristic) {
            super.onCharacteristicReadRequest(device, requestId, offset, characteristic);
            byte[] total = characteristic.getValue();
            byte[] res = {};
            // Only send MTU - 1 bytes. The first byte of all packets is the op code.
            if (offset < total.length) {
                int finalByte = offset + MTU - 1;
                if (finalByte > total.length) {
                    finalByte = total.length;
                }
                res = Arrays.copyOfRange(total, offset, finalByte);
                bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, res);
            } else {
                // This should probably be an error, but a bug in the paypal/gatt code causes an
                // infinite loop if this returns an error rather than the empty value.
                bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, 0, res);
            }
        }
    });
}

From source file:net.oauth.signatures.SignedJsonAssertionToken.java

License:Apache License

@Override
protected String computeSignatureBaseString() {
    if (getIssuedAt() == null) {
        setIssuedAt(clock.now());// w w w  .j a va  2 s .c o  m
    }
    if (getExpiration() == null) {
        setExpiration(getIssuedAt().plus(Duration.standardMinutes(DEFAULT_LIFETIME_IN_MINS)));
    }
    return super.computeSignatureBaseString();
}

From source file:no.digipost.api.client.MessageSender.java

License:Apache License

public DigipostPublicKey getEncryptionKeyForPrint() {
    DateTime now = DateTime.now();/*from   ww  w.  j a  va2 s  .c o m*/

    if (printKeyCachedTime == null
            || new Duration(printKeyCachedTime, now).isLongerThan(Duration.standardMinutes(5))) {
        log("*** STARTER INTERAKSJON MED API: HENT KRYPTERINGSNKKEL FOR PRINT ***");
        Response response = apiService.getEncryptionKeyForPrint();
        checkResponse(response);
        EncryptionKey encryptionKey = response.readEntity(EncryptionKey.class);
        cachedPrintKey = new DigipostPublicKey(encryptionKey);
        printKeyCachedTime = now;
        return cachedPrintKey;
    } else {
        log("Bruker cachet krypteringsnkkel for print");
        return cachedPrintKey;
    }
}

From source file:org.apache.apex.examples.nyctaxi.Application.java

License:Apache License

@Override
public void populateDAG(DAG dag, Configuration conf) {
    dag.setAttribute(DAG.STREAMING_WINDOW_SIZE_MILLIS, 1000);
    NycTaxiDataReader inputOperator = new NycTaxiDataReader();
    inputOperator.setDirectory("/user/" + System.getProperty("user.name") + "/nyctaxidata");
    inputOperator.getScanner().setFilePatternRegexp(".*\\.csv$");
    dag.addOperator("NycTaxiDataReader", inputOperator);
    NycTaxiCsvParser parser = dag.addOperator("NycTaxiCsvParser", new NycTaxiCsvParser());
    NycTaxiZipFareExtractor extractor = dag.addOperator("NycTaxiZipFareExtractor",
            new NycTaxiZipFareExtractor());

    KeyedWindowedOperatorImpl<String, Double, MutableDouble, Double> windowedOperator = new KeyedWindowedOperatorImpl<>();

    // 5-minute windows slide by 1 minute
    windowedOperator.setWindowOption(/*from   w w  w .  j  av a  2  s  . co  m*/
            new WindowOption.TimeWindows(Duration.standardMinutes(5)).slideBy(Duration.standardMinutes(1)));

    // Because we only care about the last 5 minutes, and the watermark is set at t-1 minutes, lateness horizon is set to 4 minutes.
    windowedOperator.setAllowedLateness(Duration.standardMinutes(4));
    windowedOperator.setAccumulation(new SumDouble());
    windowedOperator.setTriggerOption(TriggerOption.AtWatermark());
    windowedOperator.setDataStorage(new InMemoryWindowedKeyedStorage<String, MutableDouble>());
    windowedOperator.setWindowStateStorage(new InMemoryWindowedStorage<WindowState>());

    dag.addOperator("WindowedOperator", windowedOperator);

    NycTaxiDataServer dataServer = dag.addOperator("NycTaxiDataServer", new NycTaxiDataServer());
    ConsoleOutputOperator console = dag.addOperator("console", new ConsoleOutputOperator());
    dag.addStream("input_to_parser", inputOperator.output, parser.input);
    dag.addStream("parser_to_extractor", parser.output, extractor.input);
    dag.addStream("extractor_to_windowed", extractor.output, windowedOperator.input);
    dag.addStream("extractor_watermark", extractor.watermarkOutput, windowedOperator.controlInput);
    dag.addStream("windowed_to_console", windowedOperator.output, dataServer.input, console.input);

    PubSubWebSocketAppDataQuery wsQuery = new PubSubWebSocketAppDataQuery();
    wsQuery.enableEmbeddedMode();
    wsQuery.setTopic("nyctaxi.query");
    try {
        wsQuery.setUri(new URI("ws://" + java.net.InetAddress.getLocalHost().getHostName() + ":8890/pubsub"));
    } catch (URISyntaxException | UnknownHostException ex) {
        throw Throwables.propagate(ex);
    }
    dataServer.setEmbeddableQueryInfoProvider(wsQuery);
    PubSubWebSocketAppDataResult wsResult = dag.addOperator("QueryResult", new PubSubWebSocketAppDataResult());
    wsResult.setTopic("nyctaxi.result");
    try {
        wsResult.setUri(new URI("ws://" + java.net.InetAddress.getLocalHost().getHostName() + ":8890/pubsub"));
    } catch (URISyntaxException | UnknownHostException ex) {
        throw Throwables.propagate(ex);
    }
    dag.addStream("server_to_query_output", dataServer.queryResult, wsResult.input);
}

From source file:org.apache.apex.malhar.lib.window.sample.wordcount.Application.java

License:Apache License

@Override
public void populateDAG(DAG dag, Configuration configuration) {
    WordGenerator inputOperator = new WordGenerator();
    KeyedWindowedOperatorImpl<String, Long, MutableLong, Long> windowedOperator = new KeyedWindowedOperatorImpl<>();
    Accumulation<Long, MutableLong, Long> sum = new SumAccumulation();

    windowedOperator.setAccumulation(sum);
    windowedOperator.setDataStorage(new InMemoryWindowedKeyedStorage<String, MutableLong>());
    windowedOperator.setRetractionStorage(new InMemoryWindowedKeyedStorage<String, Long>());
    windowedOperator.setWindowStateStorage(new InMemoryWindowedStorage<WindowState>());
    windowedOperator.setWindowOption(new WindowOption.TimeWindows(Duration.standardMinutes(1)));
    windowedOperator.setTriggerOption(TriggerOption.AtWatermark().withEarlyFiringsAtEvery(Duration.millis(1000))
            .accumulatingAndRetractingFiredPanes());
    //windowedOperator.setAllowedLateness(Duration.millis(14000));

    ConsoleOutputOperator outputOperator = new ConsoleOutputOperator();
    dag.addOperator("inputOperator", inputOperator);
    dag.addOperator("windowedOperator", windowedOperator);
    dag.addOperator("outputOperator", outputOperator);
    dag.addStream("input_windowed", inputOperator.output, windowedOperator.input);
    dag.addStream("windowed_output", windowedOperator.output, outputOperator.input);
}

From source file:org.apache.apex.malhar.stream.sample.complete.TrafficRoutes.java

License:Apache License

@Override
public void populateDAG(DAG dag, Configuration conf) {
    InfoGen infoGen = new InfoGen();
    Collector collector = new Collector();

    // Create a stream from the input operator.
    ApexStream<Tuple.TimestampedTuple<String>> stream = StreamFactory
            .fromInput(infoGen, infoGen.output, name("infoGen"))

            // Extract the timestamp from the input and wrap it into a TimestampedTuple.
            .map(new ExtractTimestamps(), name("ExtractTimestamps"));

    stream//  w w w.j  av a2  s .c  o m
            // Extract the average speed of a station.
            .flatMap(new ExtractStationSpeedFn(), name("ExtractStationSpeedFn"))

            // Apply window and trigger option.
            .window(new WindowOption.SlidingTimeWindows(Duration.standardMinutes(WINDOW_DURATION),
                    Duration.standardMinutes(WINDOW_SLIDE_EVERY)),
                    new TriggerOption().withEarlyFiringsAtEvery(Duration.millis(5000)).accumulatingFiredPanes())

            // Apply TrackSpeed composite transformation to compute the route information.
            .addCompositeStreams(new TrackSpeed())

            // print the result to console.
            .print(name("console")).endWith(collector, collector.input, name("Collector")).populateDag(dag);
}