Example usage for org.joda.time Duration ZERO

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

Introduction

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

Prototype

Duration ZERO

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

Click Source Link

Document

Constant representing zero millisecond duration

Usage

From source file:org.apache.beam.sdk.io.kinesis.KinesisIO.java

License:Apache License

/** Returns a new {@link Read} transform for reading from Kinesis. */
public static Read read() {
    return new AutoValue_KinesisIO_Read.Builder().setMaxNumRecords(Long.MAX_VALUE)
            .setUpToDateThreshold(Duration.ZERO)
            .setWatermarkPolicyFactory(WatermarkPolicyFactory.withArrivalTimePolicy()).build();
}

From source file:org.apache.beam.sdk.io.mongodb.MongoDbGridFSIO.java

License:Apache License

/** Read data from GridFS. Default behavior with String. */
public static Read<String> read() {
    return new AutoValue_MongoDbGridFSIO_Read.Builder<String>().setParser(TEXT_PARSER)
            .setCoder(StringUtf8Coder.of()).setConnectionConfiguration(ConnectionConfiguration.create())
            .setSkew(Duration.ZERO).build();
}

From source file:org.apache.beam.sdk.nexmark.queries.Query12.java

License:Apache License

@Override
public PCollection<BidsPerSession> expand(PCollection<Event> events) {
    return events.apply(NexmarkQueryUtil.JUST_BIDS).apply(ParDo.of(new DoFn<Bid, Long>() {
        @ProcessElement/*from  ww w .j  av  a2  s.co m*/
        public void processElement(ProcessContext c) {
            c.output(c.element().bidder);
        }
    })).apply(Window.<Long>into(new GlobalWindows())
            .triggering(Repeatedly.forever(AfterProcessingTime.pastFirstElementInPane()
                    .plusDelayOf(Duration.standardSeconds(configuration.windowSizeSec))))
            .discardingFiredPanes().withAllowedLateness(Duration.ZERO)).apply(Count.perElement())
            .apply(name + ".ToResult", ParDo.of(new DoFn<KV<Long, Long>, BidsPerSession>() {
                @ProcessElement
                public void processElement(ProcessContext c) {
                    c.output(new BidsPerSession(c.element().getKey(), c.element().getValue()));
                }
            }));
}

From source file:org.apache.beam.sdk.nexmark.queries.Query3.java

License:Apache License

@Override
public PCollection<NameCityStateId> expand(PCollection<Event> events) {
    int numEventsInPane = 30;

    PCollection<Event> eventsWindowed = events.apply(Window.<Event>into(new GlobalWindows())
            .triggering(Repeatedly.forever(AfterPane.elementCountAtLeast(numEventsInPane)))
            .discardingFiredPanes().withAllowedLateness(Duration.ZERO));
    PCollection<KV<Long, Auction>> auctionsBySellerId = eventsWindowed
            // Only want the new auction events.
            .apply(NexmarkQueryUtil.JUST_NEW_AUCTIONS)

            // We only want auctions in category 10.
            .apply(name + ".InCategory", Filter.by(auction -> auction.category == 10))

            // Key auctions by their seller id.
            .apply("AuctionBySeller", NexmarkQueryUtil.AUCTION_BY_SELLER);

    PCollection<KV<Long, Person>> personsById = eventsWindowed
            // Only want the new people events.
            .apply(NexmarkQueryUtil.JUST_NEW_PERSONS)

            // We only want people in OR, ID, CA.
            .apply(name + ".InState",
                    Filter.by(person -> "OR".equals(person.state) || "ID".equals(person.state)
                            || "CA".equals(person.state)))

            // Key people by their id.
            .apply("PersonById", NexmarkQueryUtil.PERSON_BY_ID);

    return// w w w . j  a v  a 2s.c  o m
    // Join auctions and people.
    // concatenate KeyedPCollections
    KeyedPCollectionTuple.of(NexmarkQueryUtil.AUCTION_TAG, auctionsBySellerId)
            .and(NexmarkQueryUtil.PERSON_TAG, personsById)
            // group auctions and persons by personId
            .apply(CoGroupByKey.create()).apply(name + ".Join", ParDo.of(joinDoFn))

            // Project what we want.
            .apply(name + ".Project", ParDo.of(new DoFn<KV<Auction, Person>, NameCityStateId>() {

                @ProcessElement
                public void processElement(ProcessContext c) {
                    Auction auction = c.element().getKey();
                    Person person = c.element().getValue();
                    c.output(new NameCityStateId(person.name, person.city, person.state, auction.id));
                }
            }));
}

From source file:org.apache.beam.sdk.nexmark.queries.Query6.java

License:Apache License

@Override
public PCollection<SellerPrice> expand(PCollection<Event> events) {
    return events.apply(Filter.by(new AuctionOrBid()))
            // Find the winning bid for each closed auction.
            .apply(new WinningBids(name + ".WinningBids", configuration))

            // Key the winning bid by the seller id.
            .apply(name + ".Rekey", ParDo.of(new DoFn<AuctionBid, KV<Long, Bid>>() {
                @ProcessElement/*from   w w w  .  j av a2  s  . c  o  m*/
                public void processElement(ProcessContext c) {
                    Auction auction = c.element().auction;
                    Bid bid = c.element().bid;
                    c.output(KV.of(auction.seller, bid));
                }
            }))

            // Re-window to update on every wining bid.
            .apply(Window.<KV<Long, Bid>>into(new GlobalWindows())
                    .triggering(Repeatedly.forever(AfterPane.elementCountAtLeast(1))).accumulatingFiredPanes()
                    .withAllowedLateness(Duration.ZERO))

            // Find the average of last 10 winning bids for each seller.
            .apply(Combine.perKey(new MovingMeanSellingPrice(10)))

            // Project into our datatype.
            .apply(name + ".Select", ParDo.of(new DoFn<KV<Long, Long>, SellerPrice>() {
                @ProcessElement
                public void processElement(ProcessContext c) {
                    c.output(new SellerPrice(c.element().getKey(), c.element().getValue()));
                }
            }));
}

From source file:org.apache.beam.sdk.transforms.Distinct.java

License:Apache License

private static <T, W extends BoundedWindow> void validateWindowStrategy(WindowingStrategy<T, W> strategy) {
    if (!strategy.getWindowFn().isNonMerging()
            && (!strategy.getTrigger().getClass().equals(DefaultTrigger.class)
                    || strategy.getAllowedLateness().isLongerThan(Duration.ZERO))) {
        throw new UnsupportedOperationException(
                String.format("%s does not support merging windowing strategies, except when using the default "
                        + "trigger and zero allowed lateness.", Distinct.class.getSimpleName()));
    }//from  w w w.j a v  a2 s . c  o m
}

From source file:org.apache.beam.sdk.transforms.windowing.WindowMappingFn.java

License:Apache License

/** Create a new {@link WindowMappingFn} with {@link Duration#ZERO zero} maximum lookback. */
protected WindowMappingFn() {
    this(Duration.ZERO);
}

From source file:org.apache.beam.sdk.util.IdentitySideInputWindowFn.java

License:Apache License

@Override
public WindowMappingFn<BoundedWindow> getDefaultWindowMappingFn() {
    return new WindowMappingFn<BoundedWindow>() {
        @Override//from  w  ww . j a  va2s.  c o  m
        public BoundedWindow getSideInputWindow(BoundedWindow window) {
            return window;
        }

        @Override
        public Duration maximumLookback() {
            return Duration.ZERO;
        }
    };
}

From source file:org.apache.cloudstack.outofbandmanagement.driver.OutOfBandManagementDriverCommand.java

License:Apache License

public OutOfBandManagementDriverCommand(final ImmutableMap<OutOfBandManagement.Option, String> options,
        final Long timeoutSeconds) {
    this.options = options;
    if (timeoutSeconds != null && timeoutSeconds > 0) {
        this.timeout = new Duration(timeoutSeconds * 1000);
    } else {//from  ww w.  java  2s .  c o m
        this.timeout = Duration.ZERO;
    }
}

From source file:org.cook_e.data.Recipe.java

License:Open Source License

/**
 * Returns the total estimated time of all the recipe's mSteps
 *///from   w w  w  . j a v a2  s  . co m
@NonNull
public Duration getTotalTime() {
    Duration time = Duration.ZERO;
    for (Step s : mSteps) {
        time = time.withDurationAdded(s.getTime(), 1);
    }
    return time;
}