Skip to content

Commit

Permalink
Merge branch 'master' into rxsocks
Browse files Browse the repository at this point in the history
  • Loading branch information
RockyLOMO committed Dec 7, 2024
2 parents 0937842 + f210754 commit be2d828
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
14 changes: 6 additions & 8 deletions rxlib/src/main/java/org/rx/io/KeyValueStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.rx.core.Disposable;
import org.rx.core.Linq;
import org.rx.core.Reflects;
import org.rx.core.StringBuilder;
import org.rx.core.Strings;
import org.rx.exception.ExceptionLevel;
import org.rx.exception.InvalidException;
Expand Down Expand Up @@ -156,9 +157,6 @@ public KeyValueStore(@NonNull KeyValueStoreConfig config, @NonNull Serializer se
pos = endPos.v;
}
});
if (wal.extra == null) {
wal.extra = new AtomicInteger();
}

if (config.getApiPort() > 0) {
startApiServer(config.getApiPort());
Expand Down Expand Up @@ -257,11 +255,11 @@ private Entry<TK, TV> unsafeRead(long logPosition, TK k, $<Long> position) {
val = serializer.deserialize(wal, true);

if (k != null && !k.equals(val.key)) {
AtomicInteger counter = (AtomicInteger) wal.extra;
int total = counter == null ? -1 : counter.incrementAndGet();
log.warn("LogPosError hash collision {} total={}", k, total);
Files.writeLines("./hc_err.log", Linq.from(String.format("%s %s hc=%s total=%s", DateTime.now(), logName
, k, total)), StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.APPEND);
String msg = new StringBuilder()
.appendMessageFormat("{} {} KeyValueStore hash collision {}",
DateTime.now().toDateTimeString(), logName, k).toString();
Files.writeLines("./rx_err.log", Linq.from(msg),
StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.APPEND);
return null;
}
return val;
Expand Down
4 changes: 1 addition & 3 deletions rxlib/src/main/java/org/rx/io/WALFileStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
private CompositeMmap writer;
private final LinkedTransferQueue<IOStream> readers = new LinkedTransferQueue<>();
private final Serializer serializer;
final MetaHeader meta;
private final MetaHeader meta;
@Setter
long flushDelayMillis = 1000;
private transient InputStream _reader;
Expand Down Expand Up @@ -173,8 +173,6 @@ public long getLength() {
return lock.readInvoke(file::getLength);
}

Object extra;

public long getSize() {
return lock.readInvoke(() -> meta.size);
}
Expand Down

0 comments on commit be2d828

Please sign in to comment.