Example usage for org.joda.time Duration Duration

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

Introduction

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

Prototype

public Duration(Object duration) 

Source Link

Document

Creates a duration from the specified object using the org.joda.time.convert.ConverterManager ConverterManager .

Usage

From source file:com.metamx.druid.indexing.coordinator.http.IndexerCoordinatorNode.java

License:Open Source License

private void initializeHttpClient() {
    if (httpClient == null) {
        httpClient = HttpClientInit//from www.  j  ava  2 s  .  c o  m
                .createClient(
                        HttpClientConfig.builder().withNumConnections(1)
                                .withReadTimeout(new Duration(
                                        PropUtils.getProperty(getProps(), "druid.emitter.timeOut")))
                                .build(),
                        getLifecycle());
    }
}

From source file:com.metamx.druid.merger.coordinator.http.IndexerCoordinatorNode.java

License:Open Source License

private void initializeEmitter() {
    if (emitter == null) {
        final HttpClient httpClient = HttpClientInit.createClient(HttpClientConfig.builder()
                .withNumConnections(1)//from  www  . j  a  va2s  .  co m
                .withReadTimeout(new Duration(PropUtils.getProperty(props, "druid.emitter.timeOut"))).build(),
                lifecycle);

        emitter = new ServiceEmitter(PropUtils.getProperty(props, "druid.service"),
                PropUtils.getProperty(props, "druid.host"),
                Emitters.create(props, httpClient, getJsonMapper(), lifecycle));
    }
    EmittingLogger.registerEmitter(emitter);
}

From source file:com.metamx.druid.merger.worker.http.WorkerNode.java

License:Open Source License

private void initializeHttpClient() {
    if (httpClient == null) {
        httpClient = HttpClientInit.createClient(HttpClientConfig.builder().withNumConnections(1)
                .withReadTimeout(new Duration(PropUtils.getProperty(props, "druid.emitter.timeOut"))).build(),
                lifecycle);/*from   ww  w  . j  a  v a  2  s  .  c om*/
    }
}

From source file:com.metamx.druid.QueryableNode.java

License:Open Source License

private void initializeEmitter() {
    if (emitter == null) {
        final HttpClientConfig.Builder configBuilder = HttpClientConfig.builder().withNumConnections(1);

        final String emitterTimeoutDuration = props.getProperty("druid.emitter.timeOut");
        if (emitterTimeoutDuration != null) {
            configBuilder.withReadTimeout(new Duration(emitterTimeoutDuration));
        }//from  www .j  av  a  2  s  . c  om

        final HttpClient httpClient = HttpClientInit.createClient(configBuilder.build(), lifecycle);

        setEmitter(new ServiceEmitter(PropUtils.getProperty(props, "druid.service"),
                PropUtils.getProperty(props, "druid.host"),
                Emitters.create(props, httpClient, jsonMapper, lifecycle)));
    }
    EmittingLogger.registerEmitter(emitter);
}

From source file:com.metamx.rdiclient.RdiClients.java

License:Apache License

/**
 * Generate HttpClient with default settings
 *
 * @param config default config.  1 connection. Timeout duration set in RdiClientConfig.
 * @param lifecycle lifecycle for HttpClient
 * @return HttpClient//  w w w. j ava  2 s.c  o m
 */
private static HttpClient makeDefaultHttpClient(final RdiClientConfig config, final Lifecycle lifecycle) {
    try {
        final HttpClientConfig httpClientConfig = new HttpClientConfig(config.getMaxConnectionCount(),
                SSLContext.getDefault(), new Duration(config.getPostTimeoutMillis()));
        return HttpClientInit.createClient(httpClientConfig, lifecycle);
    } catch (NoSuchAlgorithmException e) {
        throw Throwables.propagate(e);
    }
}

From source file:com.moosemorals.mediabrowser.FtpScanner.java

License:Open Source License

private void updateFromHMT(PVRFile file) throws IOException {
    synchronized (ftp) {
        HMTFile hmt = getHMTForTs(file);

        file.setDescription(hmt.getDesc());
        file.setTitle(hmt.getRecordingTitle());
        file.setStartTime(new DateTime(hmt.getStartTimestamp() * 1000, PVR.DEFAULT_TIMEZONE));
        file.setEndTime(new DateTime(hmt.getEndTimestamp() * 1000, PVR.DEFAULT_TIMEZONE));
        file.setLength(new Duration(hmt.getLength() * 1000));
        file.setHighDef(hmt.isHighDef());
        file.setLocked(hmt.isLocked());//ww w  .  j  a va 2s . c o m
        file.setChannelName(hmt.getChannelName());
        file.setFtpScanned(true);
    }
}

From source file:com.moss.joda.time.xml.DurationAdapter.java

License:Open Source License

@Override
public Duration unmarshal(Long milliseconds) throws Exception {
    if (milliseconds == null)
        return null;
    else/*from w  w  w.  j a v  a2  s  .c  o  m*/
        return new Duration(milliseconds.longValue());
}

From source file:com.moss.jodapersist.DurationUserType.java

License:Open Source License

public Object getFromResultSet(ResultSet results, String columnName) throws HibernateException, SQLException {
    Object value = results.getObject(columnName);
    if (value == null)
        return null;
    else/*from  w w w  .j  ava 2  s . c  o m*/
        return new Duration(((Number) value).longValue());
}

From source file:com.mycollab.module.crm.view.activity.CallReadFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(Object propertyId) {
    SimpleCall call = attachForm.getBean();

    if (propertyId.equals("assignuser")) {
        return new UserLinkViewField(call.getAssignuser(), call.getAssignUserAvatarId(),
                call.getAssignUserFullName());
    } else if (propertyId.equals("type")) {
        return new RelatedReadItemField(call);
    } else if (CallWithBLOBs.Field.status.equalTo(propertyId)) {
        StringBuilder value = new StringBuilder();
        if (call.getStatus() != null) {
            value.append(UserUIContext.getMessage(CallStatus.class, call.getStatus())).append(" ");
        }//  w w w.jav a  2  s.c  o m

        if (call.getCalltype() != null) {
            value.append(UserUIContext.getMessage(CallType.class, call.getCalltype()));
        }
        return new DefaultViewField(value.toString()).withStyleName(UIConstants.FIELD_NOTE);
    } else if (CallWithBLOBs.Field.durationinseconds.equalTo(propertyId)) {
        try {
            final long duration = Long.parseLong("" + call.getDurationinseconds() * 1000);

            Duration dur = new Duration(duration);
            PeriodFormatter formatter = new PeriodFormatterBuilder().appendDays().appendSuffix("d")
                    .appendHours().appendSuffix("h").appendMinutes().appendSuffix("m").appendSeconds()
                    .appendSuffix("s").toFormatter();
            String formatted = formatter.print(dur.toPeriod());
            return new DefaultViewField(formatted);
        } catch (NumberFormatException e) {
            return new DefaultViewField("");
        }

    } else if (CallWithBLOBs.Field.startdate.equalTo(propertyId)) {
        return new DateTimeViewField(call.getStartdate());
    } else if (CallWithBLOBs.Field.description.equalTo(propertyId)) {
        return new RichTextViewField(call.getDescription());
    }

    return null;
}

From source file:com.mycollab.vaadin.web.ui.field.DateTimeOptionField.java

License:Open Source License

private Date getDateValue() {
    Date selectDate = popupDateField.getValue();
    if (selectDate == null) {
        return null;
    }/*www  .j a va2  s  .c o  m*/

    DateTime jodaSelectDate = new DateTime(selectDate)
            .toDateTime(DateTimeZone.forTimeZone(UserUIContext.getUserTimeZone()));
    Date baseDate = new LocalDate(jodaSelectDate).toDate();
    if (hideTimeOption) {
        return new LocalDateTime(baseDate).toDateTime(DateTimeZone.forTimeZone(UserUIContext.getUserTimeZone()))
                .toDate();
    } else {
        Integer hour = (hourPickerComboBox.getValue() != null)
                ? Integer.parseInt((String) hourPickerComboBox.getValue())
                : 0;
        Integer minus = (minutePickerComboBox.getValue() != null)
                ? Integer.parseInt((String) minutePickerComboBox.getValue())
                : 0;
        String timeFormat = (timeFormatComboBox.getValue() != null) ? (String) timeFormatComboBox.getValue()
                : "AM";
        long milliseconds = calculateMilliSeconds(hour, minus, timeFormat);
        DateTime jodaTime = new DateTime(baseDate).plus(new Duration(milliseconds));
        return new LocalDateTime(jodaTime.getMillis())
                .toDateTime(DateTimeZone.forTimeZone(UserUIContext.getUserTimeZone())).toDate();
    }
}