Search in sources :

Example 21 with SimpleDateFormat

use of java.text.SimpleDateFormat in project hadoop by apache.

the class TimedOutTestsListener method buildThreadDiagnosticString.

public static String buildThreadDiagnosticString() {
    StringWriter sw = new StringWriter();
    PrintWriter output = new PrintWriter(sw);
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss,SSS");
    output.println(String.format("Timestamp: %s", dateFormat.format(new Date())));
    output.println();
    output.println(buildThreadDump());
    String deadlocksInfo = buildDeadlockInfo();
    if (deadlocksInfo != null) {
        output.println("====> DEADLOCKS DETECTED <====");
        output.println();
        output.println(deadlocksInfo);
    }
    return sw.toString();
}
Also used : StringWriter(java.io.StringWriter) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) PrintWriter(java.io.PrintWriter)

Example 22 with SimpleDateFormat

use of java.text.SimpleDateFormat in project hadoop by apache.

the class SnapshottableDirectoryStatus method print.

/**
   * Print a list of {@link SnapshottableDirectoryStatus} out to a given stream.
   * @param stats The list of {@link SnapshottableDirectoryStatus}
   * @param out The given stream for printing.
   */
public static void print(SnapshottableDirectoryStatus[] stats, PrintStream out) {
    if (stats == null || stats.length == 0) {
        out.println();
        return;
    }
    int maxRepl = 0, maxLen = 0, maxOwner = 0, maxGroup = 0;
    int maxSnapshotNum = 0, maxSnapshotQuota = 0;
    for (SnapshottableDirectoryStatus status : stats) {
        maxRepl = maxLength(maxRepl, status.dirStatus.getReplication());
        maxLen = maxLength(maxLen, status.dirStatus.getLen());
        maxOwner = maxLength(maxOwner, status.dirStatus.getOwner());
        maxGroup = maxLength(maxGroup, status.dirStatus.getGroup());
        maxSnapshotNum = maxLength(maxSnapshotNum, status.snapshotNumber);
        maxSnapshotQuota = maxLength(maxSnapshotQuota, status.snapshotQuota);
    }
    String lineFormat = // permission string
    "%s%s " + "%" + maxRepl + "s " + (maxOwner > 0 ? "%-" + maxOwner + "s " : "%s") + (maxGroup > 0 ? "%-" + maxGroup + "s " : "%s") + "%" + maxLen + "s " + // mod time
    "%s " + "%" + maxSnapshotNum + "s " + "%" + maxSnapshotQuota + "s " + // path
    "%s";
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    for (SnapshottableDirectoryStatus status : stats) {
        String line = String.format(lineFormat, "d", status.dirStatus.getPermission(), status.dirStatus.getReplication(), status.dirStatus.getOwner(), status.dirStatus.getGroup(), String.valueOf(status.dirStatus.getLen()), dateFormat.format(new Date(status.dirStatus.getModificationTime())), status.snapshotNumber, status.snapshotQuota, status.getFullPath().toString());
        out.println(line);
    }
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 23 with SimpleDateFormat

use of java.text.SimpleDateFormat in project hadoop by apache.

the class InvalidateBlocks method printBlockDeletionTime.

private void printBlockDeletionTime(final Logger log) {
    log.info(DFSConfigKeys.DFS_NAMENODE_STARTUP_DELAY_BLOCK_DELETION_SEC_KEY + " is set to " + DFSUtil.durationToString(pendingPeriodInMs));
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy MMM dd HH:mm:ss");
    Calendar calendar = new GregorianCalendar();
    calendar.add(Calendar.SECOND, (int) (this.pendingPeriodInMs / 1000));
    log.info("The block deletion will start around " + sdf.format(calendar.getTime()));
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) SimpleDateFormat(java.text.SimpleDateFormat)

Example 24 with SimpleDateFormat

use of java.text.SimpleDateFormat in project hadoop by apache.

the class VersionInfoMojo method getBuildTime.

/**
   * Returns a string representing current build time.
   * 
   * @return String representing current build time
   */
private String getBuildTime() {
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    return dateFormat.format(new Date());
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 25 with SimpleDateFormat

use of java.text.SimpleDateFormat in project hadoop by apache.

the class Util method createWriter.

/** Create a writer of a local file. */
public static PrintWriter createWriter(File dir, String prefix) throws IOException {
    checkDirectory(dir);
    SimpleDateFormat dateFormat = new SimpleDateFormat("-yyyyMMdd-HHmmssSSS");
    for (; ; ) {
        final File f = new File(dir, prefix + dateFormat.format(new Date(System.currentTimeMillis())) + ".txt");
        if (!f.exists())
            return new PrintWriter(new OutputStreamWriter(new FileOutputStream(f), Charsets.UTF_8));
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
        }
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) Date(java.util.Date) PrintWriter(java.io.PrintWriter)

Aggregations

SimpleDateFormat (java.text.SimpleDateFormat)2847 Date (java.util.Date)1590 ParseException (java.text.ParseException)463 DateFormat (java.text.DateFormat)425 Calendar (java.util.Calendar)307 Test (org.junit.Test)305 ArrayList (java.util.ArrayList)232 File (java.io.File)230 IOException (java.io.IOException)185 GregorianCalendar (java.util.GregorianCalendar)139 HashMap (java.util.HashMap)121 Locale (java.util.Locale)70 DateField (edu.uci.ics.textdb.api.field.DateField)64 DoubleField (edu.uci.ics.textdb.api.field.DoubleField)64 IField (edu.uci.ics.textdb.api.field.IField)64 IntegerField (edu.uci.ics.textdb.api.field.IntegerField)64 StringField (edu.uci.ics.textdb.api.field.StringField)63 TextField (edu.uci.ics.textdb.api.field.TextField)63 Map (java.util.Map)63 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)61