use of java.text.SimpleDateFormat in project storm by apache.
the class TestSimpleFileNameFormat method testParameters.
@Test
public void testParameters() {
SimpleFileNameFormat format = new SimpleFileNameFormat().withName("$TIME.$HOST.$COMPONENT.$TASK.$NUM.txt").withPath("/mypath").withTimeFormat("yyyy-MM-dd HH:mm:ss");
format.prepare(null, createTopologyContext());
long now = System.currentTimeMillis();
String path = format.getPath();
String name = format.getName(1, now);
Assert.assertEquals("/mypath", path);
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(now);
String host = null;
try {
host = Utils.localHostname();
} catch (UnknownHostException e) {
e.printStackTrace();
}
Assert.assertEquals(time + "." + host + ".Xcom.7.1.txt", name);
}
use of java.text.SimpleDateFormat in project storm by apache.
the class TestSimpleFileNameFormat method testDefaults.
@Test
public void testDefaults() {
SimpleFileNameFormat format = new SimpleFileNameFormat();
format.prepare(null, createTopologyContext());
long now = System.currentTimeMillis();
String path = format.getPath();
String name = format.getName(1, now);
Assert.assertEquals("/storm", path);
String time = new SimpleDateFormat("yyyyMMddHHmmss").format(now);
Assert.assertEquals(time + ".1.txt", name);
}
use of java.text.SimpleDateFormat in project storm by apache.
the class TestSimpleFileNameFormat method testDefaults.
@Test
public void testDefaults() {
SimpleFileNameFormat format = new SimpleFileNameFormat();
format.prepare(null, 3, 5);
long now = System.currentTimeMillis();
String path = format.getPath();
String name = format.getName(1, now);
Assert.assertEquals("/storm", path);
String time = new SimpleDateFormat("yyyyMMddHHmmss").format(now);
Assert.assertEquals(time + ".1.txt", name);
}
use of java.text.SimpleDateFormat in project storm by apache.
the class TestSimpleFileNameFormat method testParameters.
@Test
public void testParameters() {
SimpleFileNameFormat format = new SimpleFileNameFormat().withName("$TIME.$HOST.$PARTITION.$NUM.txt").withPath("/mypath").withTimeFormat("yyyy-MM-dd HH:mm:ss");
format.prepare(null, 3, 5);
long now = System.currentTimeMillis();
String path = format.getPath();
String name = format.getName(1, now);
Assert.assertEquals("/mypath", path);
String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(now);
String host = null;
try {
host = Utils.localHostname();
} catch (UnknownHostException e) {
e.printStackTrace();
}
Assert.assertEquals(time + "." + host + ".3.1.txt", name);
}
use of java.text.SimpleDateFormat in project storm by apache.
the class DelimitedRecordHiveMapper method withTimeAsPartitionField.
public DelimitedRecordHiveMapper withTimeAsPartitionField(String timeFormat) {
this.timeFormat = timeFormat;
parseDate = new SimpleDateFormat(timeFormat);
return this;
}
Aggregations