List of usage examples for org.joda.time Interval toString
public String toString()
From source file:org.apache.abdera2.activities.io.gson.IntervalAdapter.java
License:Apache License
protected String serialize(Interval t) { return t.toString(); }
From source file:org.apache.calcite.adapter.druid.DruidQuery.java
License:Apache License
protected static void writeObject(JsonGenerator generator, Object o) throws IOException { if (o instanceof String) { String s = (String) o; generator.writeString(s);/*from w w w . ja v a2 s.co m*/ } else if (o instanceof Interval) { Interval i = (Interval) o; generator.writeString(i.toString()); } else if (o instanceof Integer) { Integer i = (Integer) o; generator.writeNumber(i); } else if (o instanceof List) { writeArray(generator, (List<?>) o); } else if (o instanceof Json) { ((Json) o).write(generator); } else { throw new AssertionError("not a json object: " + o); } }
From source file:org.apache.druid.client.coordinator.CoordinatorClient.java
License:Apache License
public List<ImmutableSegmentLoadInfo> fetchServerView(String dataSource, Interval interval, boolean incompleteOk) { try {/*from w w w . j a va 2 s . co m*/ FullResponseHolder response = druidLeaderClient.go(druidLeaderClient.makeRequest(HttpMethod.GET, StringUtils.format("/druid/coordinator/v1/datasources/%s/intervals/%s/serverview?partial=%s", StringUtils.urlEncode(dataSource), interval.toString().replace('/', '_'), incompleteOk))); if (!response.getStatus().equals(HttpResponseStatus.OK)) { throw new ISE("Error while fetching serverView status[%s] content[%s]", response.getStatus(), response.getContent()); } return jsonMapper.readValue(response.getContent(), new TypeReference<List<ImmutableSegmentLoadInfo>>() { }); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.apache.druid.java.util.common.granularity.ArbitraryGranularity.java
License:Apache License
private String getPrettyIntervals() { StringBuilder bob = new StringBuilder('['); boolean hit = false; for (Interval interval : intervals) { if (hit) { bob.append(','); }/*w w w. ja v a2s . c o m*/ bob.append(interval.toString()); hit = true; } bob.append(']'); return bob.toString(); }
From source file:org.apache.druid.segment.realtime.plumber.RealtimePlumber.java
License:Apache License
protected File computePersistDir(DataSchema schema, Interval interval) { return new File(computeBaseDir(schema), interval.toString().replace('/', '_')); }
From source file:org.apache.druid.server.ClientInfoResource.java
License:Apache License
@GET @Path("/{dataSourceName}") @Produces(MediaType.APPLICATION_JSON)// w w w . j a va 2s. c o m @ResourceFilters(DatasourceResourceFilter.class) public Map<String, Object> getDatasource(@PathParam("dataSourceName") String dataSourceName, @QueryParam("interval") String interval, @QueryParam("full") String full) { if (full == null) { return ImmutableMap.of(KEY_DIMENSIONS, getDataSourceDimensions(dataSourceName, interval), KEY_METRICS, getDataSourceMetrics(dataSourceName, interval)); } Interval theInterval; if (interval == null || interval.isEmpty()) { DateTime now = getCurrentTime(); theInterval = new Interval(segmentMetadataQueryConfig.getDefaultHistory(), now); } else { theInterval = Intervals.of(interval); } TimelineLookup<String, ServerSelector> timeline = timelineServerView .getTimeline(new TableDataSource(dataSourceName)); Iterable<TimelineObjectHolder<String, ServerSelector>> serversLookup = timeline != null ? timeline.lookup(theInterval) : null; if (serversLookup == null || Iterables.isEmpty(serversLookup)) { return Collections.EMPTY_MAP; } Map<Interval, Object> servedIntervals = new TreeMap<>(new Comparator<Interval>() { @Override public int compare(Interval o1, Interval o2) { if (o1.equals(o2) || o1.overlaps(o2)) { return 0; } else { return o1.isBefore(o2) ? -1 : 1; } } }); for (TimelineObjectHolder<String, ServerSelector> holder : serversLookup) { final Set<Object> dimensions = new HashSet<>(); final Set<Object> metrics = new HashSet<>(); final PartitionHolder<ServerSelector> partitionHolder = holder.getObject(); if (partitionHolder.isComplete()) { for (ServerSelector server : partitionHolder.payloads()) { final DataSegment segment = server.getSegment(); dimensions.addAll(segment.getDimensions()); metrics.addAll(segment.getMetrics()); } } servedIntervals.put(holder.getInterval(), ImmutableMap.of(KEY_DIMENSIONS, dimensions, KEY_METRICS, metrics)); } //collapse intervals if they abut and have same set of columns Map<String, Object> result = Maps.newLinkedHashMap(); Interval curr = null; Map<String, Set<String>> cols = null; for (Map.Entry<Interval, Object> e : servedIntervals.entrySet()) { Interval ival = e.getKey(); if (curr != null && curr.abuts(ival) && cols.equals(e.getValue())) { curr = curr.withEnd(ival.getEnd()); } else { if (curr != null) { result.put(curr.toString(), cols); } curr = ival; cols = (Map<String, Set<String>>) e.getValue(); } } //add the last one in if (curr != null) { result.put(curr.toString(), cols); } return result; }
From source file:org.apache.druid.testing.clients.CoordinatorResourceTestClient.java
License:Apache License
public void deleteSegmentsDataSource(String dataSource, Interval interval) { try {//w ww.j a v a 2 s . co m makeRequest(HttpMethod.DELETE, StringUtils.format("%sdatasources/%s/intervals/%s", getCoordinatorURL(), StringUtils.urlEncode(dataSource), interval.toString().replace('/', '_'))); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:org.apache.hadoop.hive.ql.optimizer.calcite.druid.DruidQuery.java
License:Apache License
private static void writeObject(JsonGenerator generator, Object o) throws IOException { if (o instanceof String) { String s = (String) o; generator.writeString(s);/*from w w w. ja v a 2 s . c o m*/ } else if (o instanceof Interval) { Interval i = (Interval) o; generator.writeString(i.toString()); } else if (o instanceof Integer) { Integer i = (Integer) o; generator.writeNumber(i); } else if (o instanceof List) { writeArray(generator, (List<?>) o); } else if (o instanceof Json) { ((Json) o).write(generator); } else { throw new AssertionError("not a json object: " + o); } }
From source file:org.datanucleus.store.types.jodatime.converters.JodaIntervalStringConverter.java
License:Open Source License
public String toDatastoreType(Interval itv) { return (itv != null ? itv.toString() : null); }
From source file:org.filteredpush.qc.date.DateUtils.java
License:Apache License
/** * Compare two strings that should represent event dates (ingoring time, if not a date range) * /*from w ww .j a v a 2s . com*/ * @param eventDate to compare with second event date * @param secondEventDate to compare with * @return true if the two provided event dates represent the same interval. */ public static Boolean eventsAreSameInterval(String eventDate, String secondEventDate) { boolean result = false; try { Interval interval = null; Interval secondInterval = null; interval = DateUtils.extractDateInterval(eventDate); secondInterval = DateUtils.extractDateInterval(secondEventDate); logger.debug(interval.toString()); logger.debug(secondInterval.toString()); result = interval.equals(secondInterval); } catch (IllegalFieldValueException ex) { // field format error, can't parse as date, log at debug level. logger.debug(ex.getMessage()); } catch (Exception e) { logger.error(e.getMessage()); } return result; }