List of usage examples for org.joda.time DateTimeZone UTC
DateTimeZone UTC
To view the source code for org.joda.time DateTimeZone UTC.
Click Source Link
From source file:br.edu.utfpr.cm.JGitMinerWeb.services.metric.social.TimeMetric.java
public void calculateMetric(AuxAllMetrics pairOfFile, DateTime being, DateTime end) { List<AuxCountTimeMetrics> timeMetricsList = new ArrayList<>(); // if (result.containsKey(pairOfFiles.getAuxPairOfFiles())) { // timeMetricsList = result.get(pairOfFiles.getAuxPairOfFiles()); // } else { // timeMetricsList = new ArrayList<>(); // }/*w ww . j a v a2 s . c om*/ PeriodOfDayCount periodOfDayCount = new PeriodOfDayCount(); DayOfWeekCount dayOfWeekCount = new DayOfWeekCount(); DayOfMonthCount dayOfMonthCount = new DayOfMonthCount(); MonthCount monthCount = new MonthCount(); // if (isBetweenDate(pairOfFiles.getDateFile1(), being, end)) { if (!pairOfFile.getRepoCommits_idList().isEmpty()) { for (EntityRepositoryCommit repoCommit : pairOfFile.getRepoCommits()) { DateTime repoCommitDate = new DateTime(repoCommit.getCommit().getAuthor().getDateCommitUser(), DateTimeZone.UTC); if (isBetweenDate(repoCommitDate, being, end)) { periodOfDayCount.countPeriodOfDay(getPeriodOfDay(repoCommitDate)); dayOfWeekCount.countDayOfWeek(repoCommitDate.getDayOfWeek()); dayOfMonthCount.countDayOfMonth(repoCommitDate.getDayOfMonth()); monthCount.countMonth(repoCommitDate.getMonthOfYear()); } } } // periodOfDayCount.countPeriodOfDay(pairOfFiles.getPedriodOfDayFile1()); // dayOfWeekCount.countDayOfWeek(pairOfFiles.getDayOfWeekFile1()); // dayOfMonthCount.countDayOfMonth(pairOfFiles.getDayOfMonthFile1()); // monthCount.countMonth(pairOfFiles.getMonthOfModFile1()); AuxCountTimeMetrics timeMetrics = new AuxCountTimeMetrics(periodOfDayCount, dayOfWeekCount, dayOfMonthCount, monthCount); timeMetricsList.add(timeMetrics); // } result.put(pairOfFile.getId(), timeMetricsList); }
From source file:ch.icclab.cyclops.client.UdrServiceClient.java
License:Open Source License
/** * Connects to the UDR Service and requests for the CDRs for a user between a time period * * @param from String/*from w ww .j av a 2s . co m*/ * @param to String * @param userId String * @param resourceId String * @return String */ public String getUserUsageData(String userId, String resourceId, Integer from, Integer to) { logger.trace( "BEGIN UserUsage getUserUsageData(String userId, String resourceId, Integer from, Integer to) throws IOException"); logger.trace("DATA UserUsage getUserUsageData...: user=" + userId); Gson gson = new Gson(); LinearRegressionPredict predict = new LinearRegressionPredict(); //parse dates DateTime now = new DateTime(DateTimeZone.UTC); Long time_to = now.plusDays(to).getMillis(); String time_string_from = now.minusDays(from).toString("yyyy-MM-dd'T'HH:mm:ss'Z'"); ArrayList<Double> list_of_points = Time.makeListOfTIme(now, time_to, to); ClientResource resource = new ClientResource(url + "/usage/users/" + userId); resource.getReference().addQueryParameter("from", time_string_from); logger.trace("DATA UserUsage getUserUsageData...: url=" + resource.toString()); resource.get(MediaType.APPLICATION_JSON); Representation output = resource.getResponseEntity(); PredictionResponse result = new PredictionResponse(); try { JSONObject resultArray = new JSONObject(output.getText()); logger.trace("DATA UserUsage getUserUsageData...: output=" + resultArray.toString()); logger.trace("DATA UserUsage getUsageUsageData...: resultArray=" + resultArray); String result_array = resultArray.toString(); if (result_array.contains("OpenStack")) { result_array = result_array.replace("OpenStack", "External"); } UdrServiceResponse usageDataRecords = gson.fromJson(result_array, UdrServiceResponse.class); logger.trace("DATA UserUsage getUserUsageData...: userUsageData=" + usageDataRecords); result = predict.predict(usageDataRecords, resourceId, list_of_points); // Fit "from" and "to" fields result.setFrom(time_string_from); result.setTo(Time.MillsToString(time_to.doubleValue())); logger.trace("DATA UserUsage getUserUsageData...: userUsageData=" + gson.toJson(result)); } catch (JSONException e) { e.printStackTrace(); logger.error("EXCEPTION JSONEXCEPTION UserUsage getUserUsageData..."); } catch (IOException e) { logger.error("EXCEPTION IOEXCEPTION UserUsage getUserUsageData..."); e.printStackTrace(); } return gson.toJson(result); }
From source file:ch.icclab.cyclops.schedule.runner.CloudStackClient.java
License:Open Source License
/** * This method gets called from outside in order to get data from CloudStack and store it into database *//* w w w. java 2 s . c o m*/ private void updateRecords() { logger.debug("Started with updating Usage Records from CloudStack"); // get data from CloudStack Boolean status = cloudStackPuller.pullUsageRecords(); if (status) { // get now Long time = new DateTime(DateTimeZone.UTC).getMillis(); // update time stamp LatestPullORM pull = (LatestPullORM) hibernateClient.getObject(LatestPullORM.class, 1l); if (pull == null) { pull = new LatestPullORM(time); } else { pull.setTimeStamp(time); } hibernateClient.persistObject(pull); } else { logger.error("Couldn't update CloudStack Usage records"); } }
From source file:ch.icclab.cyclops.services.iaas.cloudstack.client.CloudStackClient.java
License:Open Source License
/** * This method gets called from outside in order to get data from CloudStack and store it into database * * @return//w w w . ja v a 2s . c o m */ private void updateRecords() { logger.debug("Started with updating Usage Records from CloudStack"); // mark the date (we have to do it here, not in DB client, as request can be before midnight and saving to DB on the next day) DateTime mark = new DateTime(DateTimeZone.UTC); // get data from CloudStack Boolean status = cloudStackPuller.pullUsageRecords(); if (status) { try { // check for the first time whether we are using extended CloudStack if (settings.extendedCloudStack() || settings.isExtendedCloudStackFlagUnset()) { // try to pull data status = cloudStackPuller.pullCustomUsageRecords(); // update settings to reflect whether we are using extended CloudStack or vanilla one if (settings.isExtendedCloudStackFlagUnset()) { if (status) { settings.setExtendedCloudStack(); // also update meter list selection with extended list CloudStackMeter meter = new CloudStackMeter(); meter.initializeWithList(CloudStackUsageTypes.getExtendedList()); } else { settings.setVanillaCloudStack(); } } } } catch (Exception e) { // if it failed we know that we have to work only with vanilla cloudstack settings.setVanillaCloudStack(); } // everything went fine, save timestamp to database dbClient.saveLog(mark, "pull"); } else { logger.error("Couldn't update CloudStack Usage records"); } }
From source file:ch.icclab.cyclops.services.iaas.cloudstack.client.CloudStackScheduler.java
License:Open Source License
/** * Compute difference between now and closest full hour * * @return time in milliseconds/* w w w.j a v a2 s.com*/ */ private long getSecondsToFullHour() { DateTime now = new DateTime(DateTimeZone.UTC); DateTime hour = now.hourOfDay().roundCeilingCopy(); // return difference in milliseconds return new Duration(now, hour).getMillis(); }
From source file:ch.icclab.cyclops.services.iaas.cloudstack.client.CloudStackScheduler.java
License:Open Source License
/** * Log what have just happened/*from ww w . j a va 2 s. c om*/ * * @param command as typeEvent */ private void logEvent(String command) { DateTime mark = new DateTime(DateTimeZone.UTC); new InfluxDBClient().saveLog(mark, command); logger.trace("CloudStackScheduler logging event: " + command); }
From source file:ch.icclab.cyclops.support.database.influxdb.client.InfluxDBClient.java
License:Open Source License
/** * Will look into database and return the date of last pull, or epoch if there was none * @return DateTime object/* w w w. j av a 2 s .com*/ */ public DateTime getLastPull() { InfluxDB db = getConnection(); // this is epoch DateTime date = new DateTime(0, DateTimeZone.UTC); // prepare select query String select = "SELECT * FROM \"" + cloudStackEvents + "\" WHERE event = 'pull' ORDER BY time DESC LIMIT 1"; try { // fire up the query QueryResult response = db.query(createQuery(select, logsDb)); // parse all results JSONArray resultArray = new JSONArray(response.getResults()); // get first result JSONObject result = (JSONObject) resultArray.get(0); // get series JSONArray series = (JSONArray) result.get("series"); // get first series JSONObject firstSeries = (JSONObject) series.get(0); // get values JSONArray values = (JSONArray) firstSeries.get("values"); // use first value JSONArray firstValue = (JSONArray) values.get(0); // and finally our time String time = firstValue.get(0).toString(); date = Time.getDateForTime(time); } catch (Exception e) { logger.debug("This is the first pull, therefore we will pull data since Epoch"); } return date; }
From source file:ch.icclab.cyclops.util.DateInterval.java
License:Open Source License
public DateInterval() { DateTime from = whenWasLastPull();/*ww w .j a va 2 s . c o m*/ fromDate = from.toString("yyyy-MM-dd'T'HH:mm:ssZ"); toDate = new DateTime(DateTimeZone.UTC).toString("yyyy-MM-dd'T'HH:mm:ssZ"); if (fromDate.contains("+")) fromDate = fromDate.substring(0, fromDate.indexOf("+")); if (toDate.contains("+")) toDate = toDate.substring(0, toDate.indexOf("+")); }
From source file:ch.icclab.cyclops.util.DateInterval.java
License:Open Source License
/** * Will determine when was the last entry point (pull from Ceilometer), or even if there was any * * @return date object of the last commit, or epoch if there was none *///from w w w . j a v a 2 s .c om private DateTime whenWasLastPull() { DateTime last; LatestPullORM pull = (LatestPullORM) HibernateClient.getInstance().getObject(LatestPullORM.class, 1l); if (pull == null) { last = new DateTime(0); } else { last = new DateTime(pull.getTimeStamp()); } logger.trace("Getting the last pull date " + last.toString()); // get date specified by admin String date = Loader.getSettings().getOpenStackSettings().getFirstImport(); if (date != null && !date.isEmpty()) { try { logger.trace("Admin provided us with import date preference " + date); DateTime selection = Time.getDateForTime(date); // if we are first time starting and having Epoch, change it to admin's selection // otherwise skip admin's selection and continue from the last DB entry time if (last.getMillis() == 0) { logger.debug("Setting first import date as configuration file dictates."); last = selection; } } catch (Exception ignored) { // ignoring configuration preference, as admin didn't provide correct format logger.debug("Import date selection for Ceilometer ignored - use yyyy-MM-dd'T'HH:mm:ssZ format"); } } DateTime dateTime = last.toDateTime(DateTimeZone.UTC); return dateTime; }
From source file:ch.oakmountain.tpa.solver.PeriodicalTimeFrame.java
License:Apache License
/** * Constructs an instance set to the local time defined by the specified * instant evaluated using the specified chronology. * <p/>//from w ww .j av a 2 s . com * If the chronology is null, ISO chronology in the default zone is used. * Once the constructor is completed, the zone is no longer used. * * @param instant the milliseconds from 1970-01-01T00:00:00Z * @param chronology the chronology, null means ISOChronology in default zone */ public PeriodicalTimeFrame(long instant, Chronology chronology) { chronology = DateTimeUtils.getChronology(chronology); long localMillis = chronology.getZone().getMillisKeepLocal(DateTimeZone.UTC, instant); iLocalMillis = localMillis; iChronology = chronology.withUTC(); }