Refine search
private void cleanExecutionLogs() { ExecutorManager.logger.info("Cleaning old logs from execution_logs"); final long cutoff = System.currentTimeMillis() - this.executionLogsRetentionMs; ExecutorManager.logger.info("Cleaning old log files before " + new DateTime(cutoff).toString()); cleanOldExecutionLogs(System.currentTimeMillis() - this.executionLogsRetentionMs); } }
public LLCSegmentName(String tableName, int partitionId, int sequenceNumber, long msSinceEpoch) { if (!isValidComponentName(tableName)) { throw new RuntimeException("Invalid table name " + tableName); } _tableName = tableName; _partitionId = partitionId; _sequenceNumber = sequenceNumber; // ISO8601 date: 20160120T1234Z DateTime dateTime = new DateTime(msSinceEpoch, DateTimeZone.UTC); _creationTime = dateTime.toString("yyyyMMdd'T'HHmm'Z'"); _segmentName = tableName + SEPARATOR + partitionId + SEPARATOR + sequenceNumber + SEPARATOR + _creationTime; }
@Override public void configureOutputJobProperties(TableDesc tableDesc, Map<String, String> jobProperties) { jobProperties.put(Constants.DRUID_DATA_SOURCE, tableDesc.getTableName()); jobProperties.put(DruidConstants.DRUID_SEGMENT_VERSION, new DateTime().toString()); jobProperties.put(DruidConstants.DRUID_JOB_WORKING_DIRECTORY, getStagingWorkingDir().toString()); // DruidOutputFormat will write segments in an intermediate directory jobProperties.put(DruidConstants.DRUID_SEGMENT_INTERMEDIATE_DIRECTORY, getIntermediateSegmentDir().toString()); }
public TimeRange create(final Map<String, Object> timerangeConfig) throws InvalidRangeParametersException { final String rangeType = Strings.isNullOrEmpty((String)timerangeConfig.get("type")) ? (String)timerangeConfig.get("range_type") : (String)timerangeConfig.get("type"); if (Strings.isNullOrEmpty(rangeType)) { throw new InvalidRangeParametersException("range type not set"); } switch (rangeType) { case "relative": return RelativeRange.create(Integer.parseInt(String.valueOf(timerangeConfig.get("range")))); case "keyword": return KeywordRange.create((String) timerangeConfig.get("keyword")); case "absolute": final String from = new DateTime(timerangeConfig.get("from"), DateTimeZone.UTC).toString(); final String to = new DateTime(timerangeConfig.get("to"), DateTimeZone.UTC).toString(); return AbsoluteRange.create(from, to); default: throw new InvalidRangeParametersException("range_type not recognized"); } } }
@Override public List<Trigger> getUpdatedTriggers(final long lastUpdateTime) throws TriggerLoaderException { logger.info("Loading triggers changed since " + new DateTime(lastUpdateTime).toString()); final ResultSetHandler<List<Trigger>> handler = new TriggerResultHandler(); try { final List<Trigger> triggers = this.dbOperator .query(GET_UPDATED_TRIGGERS, handler, lastUpdateTime); logger.info("Loaded " + triggers.size() + " triggers."); return triggers; } catch (final SQLException ex) { throw new TriggerLoaderException("Loading triggers from db failed.", ex); } }
public static void convertDataPropertiesToJson(List<ValuedDataObject> dataObjects, ObjectNode propertiesNode) { ObjectNode dataPropertiesNode = objectMapper.createObjectNode(); ArrayNode itemsNode = objectMapper.createArrayNode(); for (ValuedDataObject dObj : dataObjects) { ObjectNode propertyItemNode = objectMapper.createObjectNode(); propertyItemNode.put(PROPERTY_DATA_ID, dObj.getId()); propertyItemNode.put(PROPERTY_DATA_NAME, dObj.getName()); String itemSubjectRefQName = dObj.getItemSubjectRef().getStructureRef(); // remove namespace prefix String dataType = itemSubjectRefQName.substring(itemSubjectRefQName.indexOf(':') + 1); propertyItemNode.put(PROPERTY_DATA_TYPE, dataType); Object dObjValue = dObj.getValue(); String value = new String(); if (null == dObjValue) { propertyItemNode.put(PROPERTY_DATA_VALUE, ""); } else { if ("datetime".equals(dataType)) { value = new DateTime(dObjValue).toString("yyyy-MM-dd'T'hh:mm:ss"); } else { value = new String(dObjValue.toString()); } propertyItemNode.put(PROPERTY_DATA_VALUE, value.toString()); } itemsNode.add(propertyItemNode); } dataPropertiesNode.set(EDITOR_PROPERTIES_GENERAL_ITEMS, itemsNode); propertiesNode.set("dataproperties", dataPropertiesNode); }
DateTime dateTime = new DateTime(((java.sql.Time) val).getTime()); if (dateTime.getMillisOfSecond() != 0) { res = dateTime.toString("HH:mm:ss.SSS"); } else { res = dateTime.toString("HH:mm:ss"); DateTime dateTime = new DateTime(((java.sql.Timestamp) val).getTime()); if (dateTime.getMillisOfSecond() != 0) { res = dateTime.toString("yyyy-MM-dd'T'HH:mm:ss.SSS+08:00"); } else { res = dateTime.toString("yyyy-MM-dd'T'HH:mm:ss+08:00"); res = dateTime.toString("yyyy-MM-dd"); } else { if (dateTime.getMillisOfSecond() != 0) { res = dateTime.toString("yyyy-MM-dd'T'HH:mm:ss.SSS+08:00"); } else { res = dateTime.toString("yyyy-MM-dd'T'HH:mm:ss+08:00"); if (dateTime.getHourOfDay() == 0 && dateTime.getMinuteOfHour() == 0 && dateTime.getSecondOfMinute() == 0 && dateTime.getMillisOfSecond() == 0) { res = dateTime.toString("yyyy-MM-dd"); } else if (dateTime.getMillisOfSecond() != 0) { res = dateTime.toString("yyyy-MM-dd'T'HH:mm:ss.SSS+08:00"); } else { res = dateTime.toString("yyyy-MM-dd'T'HH:mm:ss+08:00"); res = dateTime.toString("yyyy-MM-dd'T'HH:mm:ss.SSS+08:00"); } else {
/** * Determine if the {@link Table} or {@link Partition} should be validated by checking if its create time * lies between maxLookBackTime and skipRecentThanTime window. */ private boolean shouldValidate(Partition partition) { for (String pathToken : this.ignoreDataPathIdentifierList) { if (partition.getDataLocation().toString().toLowerCase().contains(pathToken.toLowerCase())) { log.info("Skipping partition " + partition.getCompleteName() + " containing invalid token " + pathToken .toLowerCase()); return false; } } try { long createTime = getPartitionCreateTime(partition.getName()); boolean withinTimeWindow = new DateTime(createTime).isAfter(this.maxLookBackTime) && new DateTime(createTime) .isBefore(this.skipRecentThanTime); if (!withinTimeWindow) { log.info("Skipping partition " + partition.getCompleteName() + " as create time " + new DateTime(createTime) .toString() + " is not within validation time window "); } else { log.info("Validating partition " + partition.getCompleteName()); return withinTimeWindow; } } catch (ParseException e) { Throwables.propagate(e); } return false; }
LocalTime localTime = new LocalTime(); LocalDate localDate = new LocalDate(); DateTime dateTime = new DateTime(); LocalDateTime localDateTime = new LocalDateTime(); DateTimeZone dateTimeZone = DateTimeZone.getDefault(); System.out.println("LocalTime : " + localTime.toString()); System.out.println("localDate : " + localDate.toString()); System.out.println("dateTime : " + dateTime.toString()); System.out.println("localDateTime : " + localDateTime.toString()); System.out.println("DateTimeZone : " + dateTimeZone.toString());
@Test public void testCommonDateTimePattern() { DateTime dt1 = DateTimes.nowUtc(); DateTime dt2 = new DateTime(System.currentTimeMillis(), DateTimes.inferTzFromString("IST")); DateTime dt3 = new DateTime(System.currentTimeMillis(), DateTimeZone.forOffsetHoursMinutes(1, 30)); for (DateTime dt : new DateTime[] {dt1, dt2, dt3}) { Assert.assertTrue(DateTimes.COMMON_DATE_TIME_PATTERN.matcher(dt.toString()).matches()); } } }
public static Props addCommonFlowProperties(final Props parentProps, final ExecutableFlowBase flow) { final Props props = new Props(parentProps); props.put(CommonJobProperties.FLOW_ID, flow.getFlowId()); props.put(CommonJobProperties.EXEC_ID, flow.getExecutionId()); props.put(CommonJobProperties.PROJECT_ID, flow.getProjectId()); props.put(CommonJobProperties.PROJECT_NAME, flow.getProjectName()); props.put(CommonJobProperties.PROJECT_VERSION, flow.getVersion()); props.put(CommonJobProperties.FLOW_UUID, UUID.randomUUID().toString()); props.put(CommonJobProperties.PROJECT_LAST_CHANGED_BY, flow.getLastModifiedByUser()); props.put(CommonJobProperties.PROJECT_LAST_CHANGED_DATE, flow.getLastModifiedTimestamp()); props.put(CommonJobProperties.SUBMIT_USER, flow.getExecutableFlow().getSubmitUser()); final DateTime loadTime = new DateTime(); props.put(CommonJobProperties.FLOW_START_TIMESTAMP, loadTime.toString()); props.put(CommonJobProperties.FLOW_START_YEAR, loadTime.toString("yyyy")); props.put(CommonJobProperties.FLOW_START_MONTH, loadTime.toString("MM")); props.put(CommonJobProperties.FLOW_START_DAY, loadTime.toString("dd")); props.put(CommonJobProperties.FLOW_START_HOUR, loadTime.toString("HH")); props.put(CommonJobProperties.FLOW_START_MINUTE, loadTime.toString("mm")); props.put(CommonJobProperties.FLOW_START_SECOND, loadTime.toString("ss")); props.put(CommonJobProperties.FLOW_START_MILLISSECOND, loadTime.toString("SSS")); props.put(CommonJobProperties.FLOW_START_TIMEZONE, loadTime.toString("ZZZZ")); return props; }
@Test(groups = "fast", description="Test Account event serialization") public void testAccountCreationEvent() throws Exception { final DefaultAccountData data = new DefaultAccountData("dsfdsf", "bobo", 3, "bobo@yahoo.com", 12, "USD", null, false, UUID.randomUUID(), new DateTime().toString(), "UTC", "US", "21 avenue", "", "Gling", "San Franciso", "CA", "94110", "USA", "4126789887", "notes", false); final DefaultAccountCreationEvent e = new DefaultAccountCreationEvent(data, UUID.randomUUID(), 1L, 2L, null); final String json = mapper.writeValueAsString(e); final DefaultAccountCreationEvent obj = mapper.readValue(json, DefaultAccountCreationEvent.class); Assert.assertTrue(obj.equals(e)); } }
new DateTime(record.get("LastModifiedDate")).toString(format)); Assert.assertEquals(jsonRecord.get("date_type").getAsString(), new DateTime(record.get("date_type")).toString(format)); new DateTime(record.get("time_type")).toString(format)); Assert.assertEquals(jsonRecord.get("bytes_type").getAsString().getBytes(), ((ByteBuffer) record.get("bytes_type")).array());