Example usage for org.joda.time Period ZERO

List of usage examples for org.joda.time Period ZERO

Introduction

In this page you can find the example usage for org.joda.time Period ZERO.

Prototype

Period ZERO

To view the source code for org.joda.time Period ZERO.

Click Source Link

Document

A period of zero length and standard period type.

Usage

From source file:com.arpnetworking.tsdcore.sinks.circonus.CirconusSinkActor.java

License:Apache License

/**
 * Public constructor./*www . j a v a  2  s  .  c  o  m*/
 *
 * @param client Circonus client
 * @param broker Circonus broker to push to
 * @param maximumConcurrency the maximum number of parallel metric submissions
 * @param maximumQueueSize the maximum size of the pending metrics queue
 * @param spreadPeriod the maximum wait time before starting to send metrics
 * @param enableHistograms true to turn on histogram publication
 * @param partitionSet the partition set to partition the check bundles with
 */
public CirconusSinkActor(final CirconusClient client, final String broker, final int maximumConcurrency,
        final int maximumQueueSize, final Period spreadPeriod, final boolean enableHistograms,
        final PartitionSet partitionSet) {
    _client = client;
    _brokerName = broker;
    _maximumConcurrency = maximumConcurrency;
    _enableHistograms = enableHistograms;
    _partitionSet = partitionSet;
    _pendingRequests = EvictingQueue.create(maximumQueueSize);
    if (Period.ZERO.equals(spreadPeriod)) {
        _spreadingDelayMillis = 0;
    } else {
        _spreadingDelayMillis = new Random().nextInt((int) spreadPeriod.toStandardDuration().getMillis());
    }
    _dispatcher = getContext().system().dispatcher();
    context().actorOf(BrokerRefresher.props(_client), "broker-refresher");
    _checkBundleRefresher = context().actorOf(CheckBundleActivator.props(_client), "check-bundle-refresher");
}

From source file:com.arpnetworking.tsdcore.sinks.HttpSinkActor.java

License:Apache License

/**
 * Public constructor.//from w  ww  .  j a v a  2s. c o m
 *
 * @param client Http client to create requests from.
 * @param sink Sink that controls request creation and data serialization.
 * @param maximumConcurrency Maximum number of concurrent requests.
 * @param maximumQueueSize Maximum number of pending requests.
 * @param spreadPeriod Maximum time to delay sending new aggregates to spread load.
 */
public HttpSinkActor(final AsyncHttpClient client, final HttpPostSink sink, final int maximumConcurrency,
        final int maximumQueueSize, final Period spreadPeriod) {
    _client = client;
    _sink = sink;
    _maximumConcurrency = maximumConcurrency;
    _pendingRequests = EvictingQueue.create(maximumQueueSize);
    if (Period.ZERO.equals(spreadPeriod)) {
        _spreadingDelayMillis = 0;
    } else {
        _spreadingDelayMillis = new Random().nextInt((int) spreadPeriod.toStandardDuration().getMillis());
    }
}

From source file:com.planyourexchange.fragments.airfare.AirFareFragment.java

License:Open Source License

@Override
protected void renderSingleModel(AirFare airFare, View rowView) {
    ViewHolder viewHolder = new ViewHolder(rowView);

    // -- First line with price, origin and destination of AirFare
    viewHolder.price.setText(MoneyUtils.newPrice(airFare.getPriceCurrency(), airFare.getPrice()));
    viewHolder.origin.setText(airFare.getOriginAirport());
    viewHolder.destination.setText(airFare.getDestinationAirport());

    // -- Total time period and stops
    Period timeTotal = Period.ZERO;
    Set<String> stops = new HashSet<>();

    for (AirTrip airtrip : airFare.getAirTrips()) {
        // -- Inflates a new rowLayout and populate all specific trip data
        LayoutInflater inflater = (LayoutInflater) getLayoutInflater(null);
        View airTripRow = inflater.inflate(R.layout.airtrip_list, null, true);
        RowHolder rowHolder = new RowHolder(airTripRow);

        rowHolder.operatedBy.setText(airtrip.getOperatedBy());
        rowHolder.origin.setText(airtrip.getOrigin());
        rowHolder.destination.setText(airtrip.getDestination());
        rowHolder.flightDuration.setText(DateUtils.toString(airtrip.getFlightDuration()));
        rowHolder.flightLayover.setText(DateUtils.toString(airtrip.getAirportLayover()));

        viewHolder.layout.addView(airTripRow);

        // -- Calculate total time adding this airTrip
        // -- Stops that this trip can have
        timeTotal = DateUtils.sum(timeTotal, airtrip.getFlightDuration(), airtrip.getAirportLayover());
        stops.add(airtrip.getOrigin());/*from  w w  w  . ja va2  s  .c o  m*/
        stops.add(airtrip.getDestination());
    }
    // -- Removes origin and destination because they're not stops
    stops.remove(airFare.getOrigin());
    stops.remove(airFare.getDestination());
    // -- Setting total time and stops
    viewHolder.timeTotal.setText(DateUtils.toTimeDelta(timeTotal));
    viewHolder.stops.setText(stops.toString());
}

From source file:com.quant.TimeSeries.java

License:Open Source License

/**
 * Splits the time series into sub-series lasting sliceDuration.<br>
 * The current time series is splitted every splitDuration.<br>
 * The last sub-series may last less than sliceDuration.
 * @param splitDuration the duration between 2 splits
 * @param sliceDuration the duration of each sub-series
 * @return a list of sub-series//from  w  ww .  j  ava 2  s  . c o  m
 */
public List<TimeSeries> split(Period splitDuration, Period sliceDuration) {
    ArrayList<TimeSeries> subseries = new ArrayList<TimeSeries>();
    if (splitDuration != null && !splitDuration.equals(Period.ZERO) && sliceDuration != null
            && !sliceDuration.equals(Period.ZERO)) {

        List<Integer> beginIndexes = getSplitBeginIndexes(splitDuration);
        for (Integer subseriesBegin : beginIndexes) {
            subseries.add(subseries(subseriesBegin, sliceDuration));
        }
    }
    return subseries;
}

From source file:com.quant.TimeSeries.java

License:Open Source License

/**
 * Computes the time period of the series.
 *///from   w  ww.  j a  va 2s.  com
private void computeTimePeriod() {

    Period minPeriod = null;
    for (int i = beginIndex; i < endIndex; i++) {
        // For each tick interval...
        // Looking for the minimum period.
        long currentPeriodMillis = getTick(i + 1).getEndTime().getMillis()
                - getTick(i).getEndTime().getMillis();
        if (minPeriod == null) {
            minPeriod = new Period(currentPeriodMillis);
        } else {
            long minPeriodMillis = minPeriod.getMillis();
            if (minPeriodMillis > currentPeriodMillis) {
                minPeriod = new Period(currentPeriodMillis);
            }
        }
    }
    if (minPeriod == null || Period.ZERO.equals(minPeriod)) {
        // Minimum period not found (or zero ms found)
        // --> Use a one-day period
        minPeriod = Period.days(1);
    }
    timePeriod = minPeriod;
}

From source file:google.registry.model.domain.fee.BaseFee.java

License:Open Source License

public Period getGracePeriod() {
    return firstNonNull(gracePeriod, Period.ZERO);
}

From source file:google.registry.model.domain.fee.BaseFee.java

License:Open Source License

public boolean hasDefaultAttributes() {
    return getGracePeriod().equals(Period.ZERO) && getApplied().equals(AppliedType.IMMEDIATE)
            && getRefundable();
}

From source file:il.ac.technion.datacenter.sla.SLA.java

/**
 * @return A percentage of yearly recorded availability.
 * e.g. 99.95, 99.99, 99.999 // w w  w. j a  v  a2 s  .c om
 */
@Ensures({ "result <= 100.0", "result >= 0.0" })
public double availability() {
    return availability(Period.ZERO);
}

From source file:il.ac.technion.datacenter.sla.TableSLA.java

@Requires({ "billingPeriod != null", "compensationTable != null" })
public TableSLA(Period billingPeriod, Map<Range, Double> compensationTable) {
    super(billingPeriod);
    if (billingPeriod.equals(Period.ZERO))
        throw new IllegalArgumentException("SLA definition must have a non-empty billing period");
    if (!verifyTable(compensationTable))
        throw new IllegalArgumentException("Invalid compensationTable");
    this.compensationTable = compensationTable;
    this.contractAvailability = findRange(100.0, compensationTable.keySet()).left;
}

From source file:il.ac.technion.datacenter.sla.TableSLA.java

@Override
public double compensation() {
    return compensation(Period.ZERO);
}