code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static Message buildSyncHistory(Zxid lastZxid) {
ZabMessage.Zxid zxid = toProtoZxid(lastZxid);
ZabMessage.SyncHistory sync =
ZabMessage.SyncHistory.newBuilder().setLastZxid(zxid).build();
return Message.newBuilder().setType(MessageType.SYNC_HISTORY)
.setSyncHistor... | java |
public static Message buildSyncHistoryReply(int timeout) {
ZabMessage.SyncHistoryReply reply =
ZabMessage.SyncHistoryReply.newBuilder().setSyncTimeout(timeout).build();
return Message.newBuilder().setType(MessageType.SYNC_HISTORY_REPLY)
.setSyncHistoryReply(reply).build();
... | java |
public static Message buildElectionInfo(String vote, Zxid lastZxid,
long ackEpoch,
long round,
boolean electing) {
ZabMessage.Zxid zxid = toProtoZxid(lastZxid);
ZabMessage.ElectionInfo e... | java |
public static Message buildSnapshotDone(String filePath) {
ZabMessage.SnapshotDone done =
ZabMessage.SnapshotDone.newBuilder().setFilePath(filePath).build();
return Message.newBuilder().setType(MessageType.SNAPSHOT_DONE)
.setSnapshotDone(done).build();
} | java |
void deliverPendingFlushes(Zxid zxid) {
if (!flushQueue.isEmpty()) {
while(flushQueue.peek() != null) {
PendingFlush flush = flushQueue.peek();
if (flush.getWaitZxid().compareTo(zxid) <= 0) {
Tuple tp = pendings.pendingFlushes.remove(0);
if (tp == null) {
throw ... | java |
@Override
public void join(String peer) throws Exception {
try {
// Initializes the persistent variables.
List<String> peers = new ArrayList<String>();
peers.add(this.serverId);
ClusterConfiguration cnf =
new ClusterConfiguration(new Zxid(0, 0), peers, this.serverId);
persist... | java |
void waitProposedEpochFromQuorum()
throws InterruptedException, TimeoutException, IOException {
ClusterConfiguration currentConfig = persistence.getLastSeenConfig();
long acknowledgedEpoch = persistence.getAckEpoch();
// Waits PROPOED_EPOCH from a quorum of peers in current configuraion.
while (th... | java |
void proposeNewEpoch()
throws IOException {
long maxEpoch = persistence.getProposedEpoch();
int maxSyncTimeoutMs = getSyncTimeoutMs();
for (PeerHandler ph : this.quorumMap.values()) {
if (ph.getLastProposedEpoch() > maxEpoch) {
maxEpoch = ph.getLastProposedEpoch();
}
if (ph.g... | java |
void broadcast(Iterator<String> peers, Message message) {
transport.broadcast(peers, message);
} | java |
void waitEpochAckFromQuorum()
throws InterruptedException, TimeoutException {
int ackCount = 0;
// Waits the Ack from all other peers in the quorum set.
while (ackCount < this.quorumMap.size()) {
MessageTuple tuple = filter.getExpectedMessage(MessageType.ACK_EPOCH,
... | java |
String selectSyncHistoryOwner()
throws IOException {
// L.1.2 Select the history of a follwer f to be the initial history
// of the new epoch. Follwer f is such that for every f' in the quorum,
// f'.a < f.a or (f'.a == f.a && f'.zxid <= f.zxid).
long ackEpoch = persistence.getAckEpoch();
Zxid... | java |
void synchronizeFromFollower(String peerId)
throws IOException, TimeoutException, InterruptedException {
LOG.debug("Begins synchronizing from follower {}.", peerId);
Zxid lastZxid = persistence.getLatestZxid();
Message pullTxn = MessageBuilder.buildPullTxnReq(lastZxid);
LOG.debug("Last zxid of {} ... | java |
void waitNewLeaderAckFromQuorum()
throws TimeoutException, InterruptedException, IOException {
LOG.debug("Waiting for synchronization to followers complete.");
int completeCount = 0;
Zxid lastZxid = persistence.getLatestZxid();
while (completeCount < this.quorumMap.size()) {
// Here we shoul... | java |
void beginSynchronizing() throws IOException {
// Synchronization is performed in other threads.
Zxid lastZxid = persistence.getLatestZxid();
ClusterConfiguration clusterConfig = persistence.getLastSeenConfig();
long proposedEpoch = persistence.getProposedEpoch();
for (PeerHandler ph : this.quorumMa... | java |
void broadcasting()
throws TimeoutException, InterruptedException, IOException,
ExecutionException {
// Initialization.
broadcastingInit();
try {
while (this.quorumMap.size() >= clusterConfig.getQuorumSize()) {
MessageTuple tuple = filter.getMessage(config.getTimeoutMs());
... | java |
private Zxid getNextProposedZxid() {
if (lastProposedZxid.getEpoch() != establishedEpoch) {
lastProposedZxid = new Zxid(establishedEpoch, -1);
}
lastProposedZxid = new Zxid(establishedEpoch,
lastProposedZxid.getXid() + 1);
return lastProposedZxid;
} | java |
private static boolean isCompilationDisabledCondition(Expression condition) {
Object conditionValue = condition.accept(new ConditionalCompilationConditionEvaluator(), null);
return Boolean.FALSE.equals(conditionValue);
} | java |
private static void includeColumnRecursive(List<OrcProto.Type> types,
boolean[] result,
int typeId) {
result[typeId] = true;
OrcProto.Type type = types.get(typeId);
int children = type.getSubtypesCount();
for(int i... | java |
private static boolean[] findIncludedColumns(List<OrcProto.Type> types,
Configuration conf) {
String includedStr =
conf.get(ColumnProjectionUtils.READ_COLUMN_IDS_CONF_STR);
if (includedStr == null || includedStr.trim().length() == 0) {
return null;
... | java |
@Override
public void shutdown() throws InterruptedException {
try {
channel.close();
for(Map.Entry<String, Sender> entry: senders.entrySet()) {
entry.getValue().shutdown();
}
senders.clear();
for(Map.Entry<String, ChannelHandlerContext> entry:
receivers.entrySet()... | java |
private List<Map.Entry<StreamName, BufferedStream>> cleanUpStreams() throws IOException {
List<Map.Entry<StreamName, BufferedStream>> streamList =
new ArrayList<Map.Entry<StreamName, BufferedStream>>(streams.size());
Map<StreamName, Integer> indexMap = new HashMap<StreamName, Integer>(streams.size());
... | java |
@Override
public Object next(Object previous) throws IOException {
DoubleWritable result = null;
if (valuePresent) {
result = createWritable(previous, readDouble());
}
return result;
} | java |
public void fill(byte value)
{
int offset = 0;
int length = size;
long longValue = Longs.fromBytes(value, value, value, value, value, value, value, value);
while (length >= SizeOf.SIZE_OF_LONG) {
unsafe.putLong(base, address + offset, longValue);
offset += Siz... | java |
public byte[] getBytes(int index, int length)
{
byte[] bytes = new byte[length];
getBytes(index, bytes, 0, length);
return bytes;
} | java |
public Slice slice(int index, int length)
{
if ((index == 0) && (length == length())) {
return this;
}
checkIndexLength(index, length);
if (length == 0) {
return Slices.EMPTY_SLICE;
}
return new Slice(base, address + index, length, reference);
... | java |
@SuppressWarnings("ObjectEquality")
public int compareTo(int offset, int length, Slice that, int otherOffset, int otherLength)
{
return compareTo(offset, length, that.base, otherOffset, otherLength);
} | java |
synchronized void addWriter(final Path path,
final long requestedAllocation,
final Callback callback,
final long initialAllocation) throws IOException {
WriterInfo oldVal = writerList.get(path);
// this should always be nu... | java |
synchronized void removeWriter(Path path) throws IOException {
WriterInfo val = writerList.get(path);
if (val != null) {
LOG.info("Unregeristering writer for path " + path.toString());
writerList.remove(path);
totalAllocation -= val.allocation;
updateScale(false);
}
} | java |
private synchronized void notifyWriters() throws IOException {
LOG.debug("Notifying writers after " + rowsAddedSinceCheck);
for(WriterInfo writer: writerList.values()) {
if (lowMemoryMode) {
// If we're in low memory mode and a writer
// 1) flushes twice in a row, mark it as needy
... | java |
protected void grow(int index) {
if ((index * literalSize) + (literalSize - 1) >= data.length()) {
int newSize = Math.max((index * literalSize) + defaultSize, 2 * data.length());
Slice newSlice = Slices.allocate(newSize);
newSlice.setBytes(0, data);
setData(newSlice);
}
} | java |
public static void read(FSDataInputStream file, long fileOffset, byte[] array, int arrayOffset,
int length) throws IOException {
file.seek(fileOffset);
file.readFully(array, arrayOffset, length);
} | java |
public static List<Method> findOverriddenMethods(MethodDeclaration md) {
final List<Method> methods = new ArrayList<Method>();
collectOverriddenMethods(md, methods);
return methods.isEmpty() ? Collections.<Method>emptyList() : Collections.unmodifiableList(methods);
} | java |
private static boolean collectOverriddenMethods(MethodDeclaration md,
/* Nullable */ List<Method> overriddenMethods) {
final MethodSymbolData sdata = md.getSymbolData();
if (sdata == null || isStatic(sdata.getMethod()) || isPrivate(sdata.getMethod())) {
return false;
} e... | java |
private short readShort() throws IOException {
latestRead =
(short)SerializationUtils.readIntegerType(input, WriterImpl.SHORT_BYTE_SIZE,
true, input.useVInts());
return latestRead;
} | java |
public void broadcast(Iterator<String> peers, Message message) {
while (peers.hasNext()) {
send(peers.next(), message);
}
} | java |
private void addPreliminaryThis(Scope scope, Symbol symbol, TypeDeclaration type) {
Symbol<TypeDeclaration> thisSymbol =
new Symbol<TypeDeclaration>("this", symbol.getType(), type, ReferenceType.VARIABLE);
thisSymbol.setInnerScope(scope);
scope.addSymbol(thisSymbol);
} | java |
protected MessageTuple getMessage(int timeoutMs)
throws InterruptedException, TimeoutException {
MessageTuple tuple = messageQueue.poll(timeoutMs,
TimeUnit.MILLISECONDS);
if (tuple == null) {
throw new TimeoutException("Timeout while waiting for the message... | java |
protected MessageTuple getExpectedMessage(MessageType type,
String source,
int timeoutMs)
throws TimeoutException, InterruptedException {
int startTime = (int) (System.nanoTime() / 1000000);
// Waits until the expected... | java |
private int getSizeOfIntArrays() {
return (offsets.length + hashcodes.length + nexts.length + counts.length +
indexStrides.length) * 4;
} | java |
@Override
public void clear() {
// Subtract the amount of memory being used for the dictionary
memoryEstimate.decrementDictionaryMemory(byteArray.size());
byteArray.clear();
// Add the new size
memoryEstimate.incrementDictionaryMemory(byteArray.size());
htDictionary.clear();
// Make sure t... | java |
private void maybeIndexResource(String relPath, URL delegate) {
if (!index.containsKey(relPath)) {
index.put(relPath, delegate);
if (relPath.endsWith(File.separator)) {
maybeIndexResource(relPath.substring(0, relPath.length() - File.separator.length()), delegate);
... | java |
public static void writeLongToFile(long value, File file) throws IOException {
// Create a temp file in the same directory as the file parameter.
File temp = File.createTempFile(file.getName(), null,
file.getAbsoluteFile().getParentFile());
try (FileOutputStream fos = new... | java |
public static void writePropertiesToFile(Properties prop, File file)
throws IOException {
// Create a temp file in the same directory as the file parameter.
File temp = File.createTempFile(file.getName(), null,
file.getAbsoluteFile().getParentFile());
try (FileOutpu... | java |
public static void atomicMove(File source, File dest) throws IOException {
Files.move(source.toPath(), dest.toPath(), ATOMIC_MOVE, REPLACE_EXISTING);
} | java |
public void send(ByteBuffer request, Object ctx)
throws InvalidPhase, TooManyPendingRequests {
this.mainThread.send(request, ctx);
} | java |
public void flush(ByteBuffer request, Object ctx)
throws InvalidPhase, TooManyPendingRequests {
this.mainThread.flush(request, ctx);
} | java |
public void remove(String peerId, Object ctx)
throws InvalidPhase, TooManyPendingRequests {
this.mainThread.remove(peerId, ctx);
} | java |
protected long countNonNulls(long rows) throws IOException {
if (present != null) {
long result = 0;
for(long c=0; c < rows; ++c) {
if (present.next() == 1) {
result += 1;
}
}
return result;
} else {
return rows;
}
} | java |
public boolean nextIsNull(long currentRow) throws IOException {
if (present != null) {
seekToPresentRow(currentRow);
valuePresent = present.next() == 1;
if (valuePresent) {
// Adjust numNonNulls so we know how many non-null values we'll need to skip if skip is
// called
num... | java |
protected void seekToPresentRow(long currentRow) throws IOException {
if (currentRow != previousPresentRow + 1) {
long rowInStripe = currentRow - rowBaseInStripe - 1;
int rowIndexEntry = computeRowIndexEntry(currentRow);
if (rowIndexEntry != computeRowIndexEntry(previousPresentRow) ||
cu... | java |
public Object get(long currentRow, Object previous) throws IOException {
seekToRow(currentRow);
return next(previous);
} | java |
protected void seek(int rowIndexEntry, boolean backwards) throws IOException {
if (backwards || rowIndexEntry != computeRowIndexEntry(previousRow)) {
// initialize the previousPositionProvider
previousRowIndexEntry = rowIndexEntry;
// if the present stream exists and we are seeking backwards or to... | java |
protected boolean seekToRow(long currentRow) throws IOException {
boolean seeked = false;
// If this holds it means we checked if the row is null, and it was not,
// and when we skipRows we don't want to skip this row.
if (currentRow != previousPresentRow) {
nextIsNull(currentRow);
}
if ... | java |
public int loadIndeces(List<RowIndexEntry> rowIndexEntries, int startIndex) {
if (present != null) {
return present.loadIndeces(rowIndexEntries, startIndex);
} else {
return startIndex;
}
} | java |
public int loadIndeces(List<RowIndexEntry> rowIndexEntries, int startIndex) {
int updatedStartIndex = input.loadIndeces(rowIndexEntries, startIndex);
int numIndeces = rowIndexEntries.size();
indeces = new int[numIndeces + 1];
int i = 0;
for (RowIndexEntry rowIndexEntry : rowIndexEntries) {
in... | java |
public int add(byte[] value, int valueOffset, int valueLength) {
grow(length + valueLength);
data.setBytes(length, value, valueOffset, valueLength);
int result = length;
length += valueLength;
return result;
} | java |
public void readAll(InputStream in) throws IOException {
int read = 0;
do {
grow(length);
read = data.setBytes(length, in, data.length() - length);
if (read > 0) {
length += read;
}
} while (in.available() > 0);
} | java |
public void read(InputStream in, int lengthToRead) throws IOException {
int read = 0;
do {
grow(length);
read = data.setBytes(length, in, Math.min(lengthToRead, data.length() - length));
length += read;
lengthToRead -= read;
} while (lengthToRead > 0);
} | java |
public int compare(byte[] other, int otherOffset, int otherLength, int ourOffset, int ourLength) {
return 0 - data.compareTo(ourOffset, ourLength, other, otherOffset, otherLength);
} | java |
public void setText(Text result, int offset, int length) {
result.clear();
result.set(data.getBytes(), offset, length);
} | java |
public void write(OutputStream out, int offset,
int length) throws IOException {
data.getBytes(offset, out, length);
} | java |
long getAckEpoch() throws IOException {
try {
long ackEpoch = FileUtils.readLongFromFile(this.fAckEpoch);
return ackEpoch;
} catch (FileNotFoundException e) {
LOG.debug("File not exist, initialize acknowledged epoch to -1");
return -1;
} catch (IOException e) {
LOG.error("IOExc... | java |
long getProposedEpoch() throws IOException {
try {
long pEpoch = FileUtils.readLongFromFile(this.fProposedEpoch);
return pEpoch;
} catch (FileNotFoundException e) {
LOG.debug("File not exist, initialize acknowledged epoch to -1");
return -1;
} catch (IOException e) {
LOG.error(... | java |
ClusterConfiguration getLastSeenConfig() throws IOException {
File file = getLatestFileWithPrefix(this.rootDir, "cluster_config");
if (file == null) {
return null;
}
try {
Properties prop = FileUtils.readPropertiesFromFile(file);
return ClusterConfiguration.fromProperties(prop);
} ... | java |
ClusterConfiguration getLastConfigWithin(Zxid zxid) throws IOException {
String pattern = "cluster_config\\.\\d+_-?\\d+";
String zxidFileName = "cluster_config." + zxid.toSimpleString();
String lastFileName = null;
for (File file : this.rootDir.listFiles()) {
if (!file.isDirectory() && file.getNa... | java |
void setLastSeenConfig(ClusterConfiguration conf) throws IOException {
String version = conf.getVersion().toSimpleString();
File file = new File(rootDir, String.format("cluster_config.%s", version));
FileUtils.writePropertiesToFile(conf.toProperties(), file);
// Since the new config file gets created, w... | java |
File setSnapshotFile(File tempFile, Zxid zxid) throws IOException {
File snapshot =
new File(dataDir, String.format("snapshot.%s", zxid.toSimpleString()));
LOG.debug("Atomically move snapshot file to {}", snapshot);
FileUtils.atomicMove(tempFile, snapshot);
// Since the new snapshot file gets crea... | java |
Zxid getSnapshotZxid() {
File snapshot = getSnapshotFile();
if (snapshot == null) {
return Zxid.ZXID_NOT_EXIST;
}
String fileName = snapshot.getName();
String strZxid = fileName.substring(fileName.indexOf('.') + 1);
return Zxid.fromSimpleString(strZxid);
} | java |
void endStateTransfer() throws IOException {
File nextDir = getNextDataDir();
FileUtils.atomicMove(this.dataDir, nextDir);
// Update current data directory.
this.dataDir = nextDir;
// Restores transaction log.
this.log = createLog(dataDir);
fsyncDirectory();
this.isTransferring = false;
... | java |
File getNextDataDir() {
File latest = getLatestDataDir();
long newID;
if (latest == null) {
newID = 0;
} else {
newID = Long.parseLong(latest.getName().substring(4)) + 1;
}
String suffix = String.format("%015d", newID);
return new File(this.rootDir, "data" + suffix);
} | java |
void cleanupClusterConfigFiles() throws IOException {
Zxid latestZxid = getLatestZxid();
List<File> files = getFilesWithPrefix(this.rootDir, "cluster_config");
if (files.isEmpty()) {
LOG.error("There's no cluster_config files in log directory.");
throw new RuntimeException("There's no cluster_co... | java |
public SymbolType withName(String name) {
return clone(marker, name, arrayCount, typeVariable, null, null);
} | java |
public static SymbolType typeVariableOf(final String typeVariable, final Class<Object> clazz) {
return new SymbolType(clazz, typeVariable);
} | java |
public static SymbolType typeVariableOf(final String typeVariable, List<SymbolType> upperBounds) {
return new SymbolType(upperBounds, typeVariable);
} | java |
private static SymbolType typeVariableOf(String typeVariable, final String name, final int arrayCount,
final List<SymbolType> upperBounds, final List<SymbolType> lowerBounds) {
return new SymbolType(name, arrayCount, upperBounds, lowerBounds, typeVariable);
} | java |
public static SymbolType typeVariableOf(TypeVariable<?> typeVariable) throws InvalidTypeException {
return valueOf(typeVariable, null).cloneAsTypeVariable(typeVariable.getName());
} | java |
public static SymbolType valueOf(Type type, SymbolType arg, Map<String, SymbolType> updatedTypeMapping,
Map<String, SymbolType> typeMapping) throws InvalidTypeException {
if (typeMapping == null) {
typeMapping = Collections.emptyMap();
}
SymbolType returnType = null;
... | java |
@Override
public float nextFloat(boolean readStream) throws IOException, ValueNotPresentException {
if (!readStream) {
return latestRead;
}
if (!valuePresent) {
throw new ValueNotPresentException("Cannot materialize float..");
}
return readFloat();
} | java |
public static List<? extends Class<?> > intersectRawTypes(List<Class<?> > classes1, List<Class<?>> classes2) {
// most typical case
if (classes1.size() == 1 && classes2.size() == 1) {
return intersectRawTypes(classes1.get(0), classes2.get(0));
} else {
return list(removeS... | java |
public static List<? extends Class<?>> intersectRawTypes(Class<?> clazz1,
Class<?> clazz2) {
if (clazz2 == null) {
clazz2 = Object.class;
}
if (clazz1 == null) {
clazz1 = Object.class;
}
if (clazz1.isPrimitive()) {
clazz1 = Types.getWrapperClass(clazz1.getName());
}
... | java |
@Override
public void join(String peer) throws Exception {
LOG.debug("Follower joins in.");
try {
LOG.debug("Query leader from {}", peer);
Message query = MessageBuilder.buildQueryLeader();
MessageTuple tuple = null;
while (true) {
// The joiner might gets started before the cl... | java |
void sendProposedEpoch() throws IOException {
Message message = MessageBuilder
.buildProposedEpoch(persistence.getProposedEpoch(),
persistence.getAckEpoch(),
persistence.getLastSeenConfig(),
... | java |
void waitForNewEpoch()
throws InterruptedException, TimeoutException, IOException {
MessageTuple tuple = filter.getExpectedMessage(MessageType.NEW_EPOCH,
this.electedLeader,
config.getTimeoutMs());
Messag... | java |
void waitForNewLeaderMessage()
throws TimeoutException, InterruptedException, IOException {
LOG.debug("Waiting for New Leader message from {}.", this.electedLeader);
MessageTuple tuple = filter.getExpectedMessage(MessageType.NEW_LEADER,
this.electedLeader... | java |
void waitForCommitMessage()
throws TimeoutException, InterruptedException, IOException {
LOG.debug("Waiting for commit message from {}", this.electedLeader);
MessageTuple tuple = filter.getExpectedMessage(MessageType.COMMIT,
this.electedLeader,
... | java |
private void joinSynchronization()
throws IOException, TimeoutException, InterruptedException {
Message sync = MessageBuilder.buildSyncHistory(persistence.getLatestZxid());
sendMessage(this.electedLeader, sync);
MessageTuple tuple =
filter.getExpectedMessage(MessageType.SYNC_HISTORY_REPLY, elect... | java |
public static Reader createReader(FileSystem fs, Path path, Configuration conf )
throws IOException {
return new ReaderImpl(fs, path, conf);
} | java |
public static Writer createWriter(FileSystem fs,
Path path,
Configuration conf,
ObjectInspector inspector,
long stripeSize,
CompressionKind ... | java |
private int compareKinds(Kind kind1, Kind kind2) {
if (kind1 == Kind.LENGTH && kind2 == Kind.DATA) {
return -1;
}
if (kind1 == Kind.DATA && kind2 == Kind.LENGTH) {
return 1;
}
return kind1.compareTo(kind2);
} | java |
protected void sendMessage(String dest, Message message) {
if (LOG.isTraceEnabled()) {
LOG.trace("Sends message {} to {}.",
TextFormat.shortDebugString(message),
dest);
}
this.transport.send(dest, message);
} | java |
void waitForSyncEnd(String peerId)
throws TimeoutException, IOException, InterruptedException {
MessageTuple tuple = filter.getExpectedMessage(MessageType.SYNC_END,
peerId,
getSyncTimeoutMs());
ClusterCon... | java |
void restoreFromSnapshot() throws IOException {
Zxid snapshotZxid = persistence.getSnapshotZxid();
LOG.debug("The last applied zxid in snapshot is {}", snapshotZxid);
if (snapshotZxid != Zxid.ZXID_NOT_EXIST &&
lastDeliveredZxid == Zxid.ZXID_NOT_EXIST) {
// Restores from snapshot only if the la... | java |
void deliverUndeliveredTxns() throws IOException {
LOG.debug("Delivering all the undelivered txns after {}",
lastDeliveredZxid);
Zxid startZxid =
new Zxid(lastDeliveredZxid.getEpoch(), lastDeliveredZxid.getXid() + 1);
Log log = persistence.getLog();
try (Log.LogIterator iter = log.ge... | java |
protected void clearMessageQueue() {
MessageTuple tuple = null;
while ((tuple = messageQueue.poll()) != null) {
Message msg = tuple.getMessage();
if (msg.getType() == MessageType.DISCONNECTED) {
this.transport.clear(msg.getDisconnected().getServerId());
} else if (msg.getType() == Mess... | java |
protected int incSyncTimeout() {
int syncTimeoutMs = getSyncTimeoutMs();
participantState.setSyncTimeoutMs(syncTimeoutMs * 2);
LOG.debug("Increase the sync timeout to {}", getSyncTimeoutMs());
return syncTimeoutMs;
} | java |
protected void adjustSyncTimeout(int timeoutMs) {
int timeoutSec = (timeoutMs + 999) / 1000;
// Finds out the smallest timeout which is powers of 2 and larger than
// timeoutMs.
for (int i = 0; i < 32; ++i) {
if ((1 << i) >= timeoutSec) {
LOG.debug("Adjust timeout to {} sec", 1 << i);
... | java |
void initFromDir() {
for (File file : this.logDir.listFiles()) {
if (!file.isDirectory() &&
file.getName().matches("transaction\\.\\d+_\\d+")) {
// Appends the file with valid name to log file list.
this.logFiles.add(file);
}
}
if (!this.logFiles.isEmpty()) {
// S... | java |
int getFileIdx(Zxid zxid) {
if (logFiles.isEmpty() ||
zxid.compareTo(getZxidFromFileName(logFiles.get(0))) < 0) {
// If there's no log files or the zxid is smaller than the smallest zxid
// of the rolling log, returns -1.
return -1;
}
int idx = 0;
while (idx < logFiles.size() -... | java |
Zxid getZxidFromFileName(File file) {
String fileName = file.getName();
String strZxid = fileName.substring(fileName.indexOf('.') + 1);
return Zxid.fromSimpleString(strZxid);
} | java |
SimpleLog getLastLog() throws IOException {
if (logFiles.isEmpty()) {
return null;
}
return new SimpleLog(logFiles.get(logFiles.size() - 1));
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.