本文整理汇总了Java中org.apache.flink.configuration.ConfigConstants.DEFAULT_CHARSET属性的典型用法代码示例。如果您正苦于以下问题:Java ConfigConstants.DEFAULT_CHARSET属性的具体用法?Java ConfigConstants.DEFAULT_CHARSET怎么用?Java ConfigConstants.DEFAULT_CHARSET使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.flink.configuration.ConfigConstants
的用法示例。
在下文中一共展示了ConfigConstants.DEFAULT_CHARSET属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOffsetFromZooKeeper
public static Long getOffsetFromZooKeeper(CuratorFramework curatorClient, String groupId, String topic, int partition) throws Exception {
ZKGroupTopicDirs topicDirs = new ZKGroupTopicDirs(groupId, topic);
String path = topicDirs.consumerOffsetDir() + "/" + partition;
curatorClient.newNamespaceAwareEnsurePath(path).ensure(curatorClient.getZookeeperClient());
byte[] data = curatorClient.getData().forPath(path);
if (data == null) {
return null;
} else {
String asString = new String(data, ConfigConstants.DEFAULT_CHARSET);
if (asString.length() == 0) {
return null;
} else {
try {
return Long.valueOf(asString);
}
catch (NumberFormatException e) {
LOG.error(
"The offset in ZooKeeper for group '{}', topic '{}', partition {} is a malformed string: {}",
groupId, topic, partition, asString);
return null;
}
}
}
}
示例2: readRecord
@Override
public Record readRecord(Record target, byte[] record, int offset, int numBytes) {
if(this.cnt == 10) {
throw new RuntimeException("Excpected Test Exception.");
}
this.cnt++;
String line = new String(record, offset, numBytes, ConfigConstants.DEFAULT_CHARSET);
try {
this.key.setValue(Integer.parseInt(line.substring(0,line.indexOf("_"))));
this.value.setValue(Integer.parseInt(line.substring(line.indexOf("_")+1,line.length())));
}
catch(RuntimeException re) {
return null;
}
target.setField(0, this.key);
target.setField(1, this.value);
return target;
}
示例3: run
@Override
public void run() {
while (running) {
try {
byte[] buffer = new byte[1024];
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet);
String line = new String(packet.getData(), 0, packet.getLength(), ConfigConstants.DEFAULT_CHARSET);
lines.put(line, obj);
synchronized (lines) {
lines.notifyAll();
}
} catch (IOException ex) {
// ignore the exceptions
}
}
}
示例4: parseField
@Override
public int parseField(byte[] bytes, int startPos, int limit, byte[] delimiter, FloatValue reusable) {
final int endPos = nextStringEndPos(bytes, startPos, limit, delimiter);
if (endPos < 0) {
return -1;
}
if (endPos > startPos &&
(Character.isWhitespace(bytes[startPos]) || Character.isWhitespace(bytes[endPos - 1]))) {
setErrorState(ParseErrorState.NUMERIC_VALUE_ILLEGAL_CHARACTER);
return -1;
}
String str = new String(bytes, startPos, endPos - startPos, ConfigConstants.DEFAULT_CHARSET);
try {
float value = Float.parseFloat(str);
reusable.setValue(value);
this.result = reusable;
return (endPos == limit) ? limit : endPos + delimiter.length;
}
catch (NumberFormatException e) {
setErrorState(ParseErrorState.NUMERIC_VALUE_FORMAT_ERROR);
return -1;
}
}
示例5: parseField
@Override
public int parseField(byte[] bytes, int startPos, int limit, byte[] delimiter, Time reusable) {
final int endPos = nextStringEndPos(bytes, startPos, limit, delimiter);
if (endPos < 0) {
return -1;
}
String str = new String(bytes, startPos, endPos - startPos, ConfigConstants.DEFAULT_CHARSET);
try {
this.result = Time.valueOf(str);
return (endPos == limit) ? limit : endPos + delimiter.length;
} catch (IllegalArgumentException e) {
setErrorState(ParseErrorState.NUMERIC_VALUE_FORMAT_ERROR);
return -1;
}
}
示例6: parseField
@Override
public int parseField(byte[] bytes, int startPos, int limit, byte[] delimiter, Float reusable) {
final int endPos = nextStringEndPos(bytes, startPos, limit, delimiter);
if (endPos < 0) {
return -1;
}
if (endPos > startPos &&
(Character.isWhitespace(bytes[startPos]) || Character.isWhitespace(bytes[endPos - 1]))) {
setErrorState(ParseErrorState.NUMERIC_VALUE_ILLEGAL_CHARACTER);
return -1;
}
String str = new String(bytes, startPos, endPos - startPos, ConfigConstants.DEFAULT_CHARSET);
try {
this.result = Float.parseFloat(str);
return (endPos == limit) ? limit : endPos + delimiter.length;
} catch (NumberFormatException e) {
setErrorState(ParseErrorState.NUMERIC_VALUE_FORMAT_ERROR);
return -1;
}
}
示例7: parseField
@Override
public int parseField(byte[] bytes, int startPos, int limit, byte[] delimiter, DoubleValue reusable) {
final int endPos = nextStringEndPos(bytes, startPos, limit, delimiter);
if (endPos < 0) {
return -1;
}
if (endPos > startPos &&
(Character.isWhitespace(bytes[startPos]) || Character.isWhitespace(bytes[(endPos - 1)]))) {
setErrorState(ParseErrorState.NUMERIC_VALUE_ILLEGAL_CHARACTER);
return -1;
}
String str = new String(bytes, startPos, endPos - startPos, ConfigConstants.DEFAULT_CHARSET);
try {
double value = Double.parseDouble(str);
reusable.setValue(value);
this.result = reusable;
return (endPos == limit) ? limit : endPos + delimiter.length;
}
catch (NumberFormatException e) {
setErrorState(ParseErrorState.NUMERIC_VALUE_FORMAT_ERROR);
return -1;
}
}
示例8: deserialize
@Override
public Object deserialize(byte[] bytes) {
if (bytes == null) {
return null;
}
else {
return new String(bytes, ConfigConstants.DEFAULT_CHARSET);
}
}
示例9: deserialize
@Override
public String deserialize(byte[] message) throws IOException {
try {
// wait a bit to not cause too much cpu load
Thread.sleep(1);
} catch (InterruptedException e) {
e.printStackTrace();
}
return new String(message, ConfigConstants.DEFAULT_CHARSET);
}
示例10: testString
@Test
public void testString() {
final byte[] data = new byte[this.r.nextInt(15)];
this.r.nextBytes(data);
final String flinkTuple = new String(data, ConfigConstants.DEFAULT_CHARSET);
final StormTuple<String> tuple = new StormTuple<String>(flinkTuple, null, -1, null, null,
null);
Assert.assertEquals(flinkTuple, tuple.getString(0));
}
示例11: deserializeMessage
@Override
public TestMessage deserializeMessage(ByteBuf buf) {
int length = buf.readInt();
String message = "";
if (length > 0) {
byte[] name = new byte[length];
buf.readBytes(name);
message = new String(name, ConfigConstants.DEFAULT_CHARSET);
}
return new TestMessage(message);
}
示例12: testVeryLargeDefaultValue
@Test
public void testVeryLargeDefaultValue() throws Exception {
// ensure that we correctly read very large data when deserializing the default value
TypeSerializer<String> serializer = new KryoSerializer<>(String.class, new ExecutionConfig());
byte[] data = new byte[200000];
for (int i = 0; i < 200000; i++) {
data[i] = 65;
}
data[199000] = '\0';
String defaultValue = new String(data, ConfigConstants.DEFAULT_CHARSET);
ValueStateDescriptor<String> descr =
new ValueStateDescriptor<String>("testName", serializer, defaultValue);
assertEquals("testName", descr.getName());
assertEquals(defaultValue, descr.getDefaultValue());
assertNotNull(descr.getSerializer());
assertEquals(serializer, descr.getSerializer());
ValueStateDescriptor<String> copy = CommonTestUtils.createCopySerializable(descr);
assertEquals("testName", copy.getName());
assertEquals(defaultValue, copy.getDefaultValue());
assertNotNull(copy.getSerializer());
assertEquals(serializer, copy.getSerializer());
}
示例13: StreamPrinter
public StreamPrinter(InputStream stream, AtomicReference<String> output) {
this.reader = new BufferedReader(new InputStreamReader(stream, ConfigConstants.DEFAULT_CHARSET));
this.output = output;
}
示例14: readRecord
@Override
public String readRecord(String reuse, byte[] bytes, int offset, int numBytes) {
return new String(bytes, offset, numBytes, ConfigConstants.DEFAULT_CHARSET);
}
示例15: map
@Override
public String map(byte[] value) throws Exception {
//discard type byte and size
return new String(value, 5, value.length - 5, ConfigConstants.DEFAULT_CHARSET);
}