mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
* #1719 - Refactor TableModState to use nanoTime * Tests only - reduce logging
64 lines
1.5 KiB
Java
64 lines
1.5 KiB
Java
package io.ebeaninternal.server.transaction;
|
|
|
|
import io.ebeaninternal.api.BinaryReadContext;
|
|
import io.ebeaninternal.api.BinaryWritable;
|
|
import io.ebeaninternal.api.BinaryWriteContext;
|
|
|
|
import java.io.DataOutputStream;
|
|
import java.io.IOException;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.Set;
|
|
|
|
public class RemoteTableMod implements BinaryWritable {
|
|
|
|
private final long timestamp;
|
|
|
|
private final Set<String> tables;
|
|
|
|
public RemoteTableMod(Set<String> tables) {
|
|
this.tables = tables;
|
|
this.timestamp = System.currentTimeMillis();
|
|
}
|
|
|
|
private RemoteTableMod(long timestamp, Set<String> tables) {
|
|
this.timestamp = timestamp;
|
|
this.tables = tables;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "TableMod[" + timestamp + "; " + tables + "]";
|
|
}
|
|
|
|
public long getTimestamp() {
|
|
return timestamp;
|
|
}
|
|
|
|
public Set<String> getTables() {
|
|
return tables;
|
|
}
|
|
|
|
public static RemoteTableMod readBinaryMessage(BinaryReadContext dataInput) throws IOException {
|
|
|
|
long timestamp = dataInput.readLong();
|
|
int count = dataInput.readInt();
|
|
|
|
Set<String> tables = new LinkedHashSet<>();
|
|
for (int i = 0; i < count; i++) {
|
|
tables.add(dataInput.readUTF());
|
|
}
|
|
return new RemoteTableMod(timestamp, tables);
|
|
}
|
|
|
|
@Override
|
|
public void writeBinary(BinaryWriteContext out) throws IOException {
|
|
DataOutputStream os = out.start(TYPE_TABLEMOD);
|
|
os.writeLong(timestamp);
|
|
os.writeInt(tables.size());
|
|
for (String table : tables) {
|
|
os.writeUTF(table);
|
|
}
|
|
}
|
|
|
|
}
|