use of org.apache.flink.annotation.VisibleForTesting in project flink by apache.
the class JarFileChecker method checkJar.
@VisibleForTesting
static int checkJar(Path file) throws Exception {
final URI uri = file.toUri();
int numSevereIssues = 0;
try (final FileSystem fileSystem = FileSystems.newFileSystem(new URI("jar:file", uri.getHost(), uri.getPath(), uri.getFragment()), Collections.emptyMap())) {
if (isTestJarAndEmpty(file, fileSystem.getPath("/"))) {
return 0;
}
if (!noticeFileExistsAndIsValid(fileSystem.getPath("META-INF", "NOTICE"), file)) {
numSevereIssues++;
}
if (!licenseFileExistsAndIsValid(fileSystem.getPath("META-INF", "LICENSE"), file)) {
numSevereIssues++;
}
numSevereIssues += getNumLicenseFilesOutsideMetaInfDirectory(file, fileSystem.getPath("/"));
numSevereIssues += getFilesWithIncompatibleLicenses(file, fileSystem.getPath("/"));
}
return numSevereIssues;
}
use of org.apache.flink.annotation.VisibleForTesting in project flink by apache.
the class CollectSinkFunction method serializeAccumulatorResult.
@VisibleForTesting
public static byte[] serializeAccumulatorResult(long offset, String version, long lastCheckpointedOffset, List<byte[]> buffer) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputViewStreamWrapper wrapper = new DataOutputViewStreamWrapper(baos);
wrapper.writeLong(offset);
CollectCoordinationResponse finalResponse = new CollectCoordinationResponse(version, lastCheckpointedOffset, buffer);
finalResponse.serialize(wrapper);
return baos.toByteArray();
}
use of org.apache.flink.annotation.VisibleForTesting in project flink by apache.
the class PseudoRandomValueSelector method getGitCommitId.
@VisibleForTesting
public static Optional<String> getGitCommitId() {
try {
Process process = new ProcessBuilder("git", "rev-parse", "HEAD").start();
try (InputStream input = process.getInputStream()) {
final String commit = IOUtils.toString(input, Charset.defaultCharset()).trim();
if (commit.matches("[a-f0-9]{40}")) {
return Optional.of(commit);
}
LOG.debug("Cannot parse {}", commit);
}
} catch (IOException e) {
LOG.debug("Could not invoke git", e);
}
return Optional.empty();
}
use of org.apache.flink.annotation.VisibleForTesting in project flink by apache.
the class SavepointV0Serializer method serializeOld.
@VisibleForTesting
public void serializeOld(SavepointV0 savepoint, DataOutputStream dos) throws IOException {
dos.writeLong(savepoint.getCheckpointId());
Collection<org.apache.flink.migration.runtime.checkpoint.TaskState> taskStates = savepoint.getOldTaskStates();
dos.writeInt(taskStates.size());
for (org.apache.flink.migration.runtime.checkpoint.TaskState taskState : savepoint.getOldTaskStates()) {
// Vertex ID
dos.writeLong(taskState.getJobVertexID().getLowerPart());
dos.writeLong(taskState.getJobVertexID().getUpperPart());
// Parallelism
int parallelism = taskState.getParallelism();
dos.writeInt(parallelism);
// Sub task states
dos.writeInt(taskState.getNumberCollectedStates());
for (int i = 0; i < parallelism; i++) {
SubtaskState subtaskState = taskState.getState(i);
if (subtaskState != null) {
dos.writeInt(i);
SerializedValue<?> serializedValue = subtaskState.getState();
if (serializedValue == null) {
// null
dos.writeInt(-1);
} else {
byte[] serialized = serializedValue.getByteArray();
dos.writeInt(serialized.length);
dos.write(serialized, 0, serialized.length);
}
dos.writeLong(subtaskState.getStateSize());
dos.writeLong(subtaskState.getDuration());
}
}
// Key group states
dos.writeInt(taskState.getNumberCollectedKvStates());
for (int i = 0; i < parallelism; i++) {
KeyGroupState keyGroupState = taskState.getKvState(i);
if (keyGroupState != null) {
dos.write(i);
SerializedValue<?> serializedValue = keyGroupState.getKeyGroupState();
if (serializedValue == null) {
// null
dos.writeInt(-1);
} else {
byte[] serialized = serializedValue.getByteArray();
dos.writeInt(serialized.length);
dos.write(serialized, 0, serialized.length);
}
dos.writeLong(keyGroupState.getStateSize());
dos.writeLong(keyGroupState.getDuration());
}
}
}
}
use of org.apache.flink.annotation.VisibleForTesting in project flink by apache.
the class RocksDBStateBackend method resetRocksDBLoadedFlag.
@VisibleForTesting
static void resetRocksDBLoadedFlag() throws Exception {
final Field initField = org.rocksdb.NativeLibraryLoader.class.getDeclaredField("initialized");
initField.setAccessible(true);
initField.setBoolean(null, false);
}
Aggregations