Java Code Examples for org.apache.flink.util.StringUtils#byteToHexString()

The following examples show how to use org.apache.flink.util.StringUtils#byteToHexString() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Flink-CEPplus   File: BlobKey.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public String toString() {
	final String typeString;
	switch (this.type) {
		case TRANSIENT_BLOB:
			typeString = "t-";
			break;
		case PERMANENT_BLOB:
			typeString = "p-";
			break;
		default:
			// this actually never happens!
			throw new IllegalStateException("Invalid BLOB type");
	}
	return typeString + StringUtils.byteToHexString(this.key) + "-" + random.toString();
}
 
Example 2
Source Project: Flink-CEPplus   File: BufferSpiller.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new buffer spiller, spilling to one of the I/O manager's temp directories.
 *
 * @param ioManager The I/O manager for access to the temp directories.
 * @param pageSize The page size used to re-create spilled buffers.
 * @throws IOException Thrown if the temp files for spilling cannot be initialized.
 */
public BufferSpiller(IOManager ioManager, int pageSize) throws IOException {
	this.pageSize = pageSize;

	this.readBuffer = ByteBuffer.allocateDirect(READ_BUFFER_SIZE);
	this.readBuffer.order(ByteOrder.LITTLE_ENDIAN);

	this.headBuffer = ByteBuffer.allocateDirect(16);
	this.headBuffer.order(ByteOrder.LITTLE_ENDIAN);

	File[] tempDirs = ioManager.getSpillingDirectories();
	this.tempDir = tempDirs[DIRECTORY_INDEX.getAndIncrement() % tempDirs.length];

	byte[] rndBytes = new byte[32];
	ThreadLocalRandom.current().nextBytes(rndBytes);
	this.spillFilePrefix = StringUtils.byteToHexString(rndBytes) + '.';

	// prepare for first contents
	createSpillingChannel();
}
 
Example 3
Source Project: flink   File: BlobKey.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public String toString() {
	final String typeString;
	switch (this.type) {
		case TRANSIENT_BLOB:
			typeString = "t-";
			break;
		case PERMANENT_BLOB:
			typeString = "p-";
			break;
		default:
			// this actually never happens!
			throw new IllegalStateException("Invalid BLOB type");
	}
	return typeString + StringUtils.byteToHexString(this.key) + "-" + random.toString();
}
 
Example 4
Source Project: flink   File: BufferSpiller.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link BufferSpiller}, spilling to one of the I/O manager's temp directories.
 *
 * @param ioManager The I/O manager for access to the temp directories.
 * @param pageSize The page size used to re-create spilled buffers.
 * @param maxBufferedBytes The maximum bytes to be buffered before the checkpoint aborts.
 * @param taskName The task name for logging.
 * @throws IOException Thrown if the temp files for spilling cannot be initialized.
 */
public BufferSpiller(IOManager ioManager, int pageSize, long maxBufferedBytes, String taskName) throws IOException {
	super(maxBufferedBytes, taskName);
	this.pageSize = pageSize;

	this.readBuffer = ByteBuffer.allocateDirect(READ_BUFFER_SIZE);
	this.readBuffer.order(ByteOrder.LITTLE_ENDIAN);

	this.headBuffer = ByteBuffer.allocateDirect(16);
	this.headBuffer.order(ByteOrder.LITTLE_ENDIAN);

	File[] tempDirs = ioManager.getSpillingDirectories();
	this.tempDir = tempDirs[DIRECTORY_INDEX.getAndIncrement() % tempDirs.length];

	byte[] rndBytes = new byte[32];
	ThreadLocalRandom.current().nextBytes(rndBytes);
	this.spillFilePrefix = StringUtils.byteToHexString(rndBytes) + '.';

	// prepare for first contents
	createSpillingChannel();
}
 
Example 5
Source Project: flink   File: BlobKey.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public String toString() {
	final String typeString;
	switch (this.type) {
		case TRANSIENT_BLOB:
			typeString = "t-";
			break;
		case PERMANENT_BLOB:
			typeString = "p-";
			break;
		default:
			// this actually never happens!
			throw new IllegalStateException("Invalid BLOB type");
	}
	return typeString + StringUtils.byteToHexString(this.key) + "-" + random.toString();
}
 
Example 6
@Override
public String toString() {
	return encodedReference == null ? "(default)"
			: StringUtils.byteToHexString(encodedReference, 0, encodedReference.length);
}
 
Example 7
private static String randomString(Random random) {
	final byte[] bytes = new byte[20];
	random.nextBytes(bytes);
	return StringUtils.byteToHexString(bytes);
}
 
Example 8
Source Project: Flink-CEPplus   File: FileIOChannel.java    License: Apache License 2.0 4 votes vote down vote up
private static String randomString(Random random) {
	byte[] bytes = new byte[RANDOM_BYTES_LENGTH];
	random.nextBytes(bytes);
	return StringUtils.byteToHexString(bytes);
}
 
Example 9
@Override
public String toString() {
	return encodedReference == null ? "(default)"
			: StringUtils.byteToHexString(encodedReference, 0, encodedReference.length);
}
 
Example 10
private static String randomString(Random random) {
	final byte[] bytes = new byte[20];
	random.nextBytes(bytes);
	return StringUtils.byteToHexString(bytes);
}
 
Example 11
Source Project: flink   File: FileIOChannel.java    License: Apache License 2.0 4 votes vote down vote up
private static String randomString(Random random) {
	byte[] bytes = new byte[RANDOM_BYTES_LENGTH];
	random.nextBytes(bytes);
	return StringUtils.byteToHexString(bytes);
}
 
Example 12
@Override
public String toString() {
	return encodedReference == null ? "(default)"
			: StringUtils.byteToHexString(encodedReference, 0, encodedReference.length);
}
 
Example 13
Source Project: flink   File: SpanningWrapper.java    License: Apache License 2.0 4 votes vote down vote up
private static String randomString(Random random) {
	final byte[] bytes = new byte[20];
	random.nextBytes(bytes);
	return StringUtils.byteToHexString(bytes);
}
 
Example 14
Source Project: flink   File: FileIOChannel.java    License: Apache License 2.0 4 votes vote down vote up
private static String randomString(Random random) {
	byte[] bytes = new byte[RANDOM_BYTES_LENGTH];
	random.nextBytes(bytes);
	return StringUtils.byteToHexString(bytes);
}