use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class MigrationInfo method readData.
@Override
public void readData(ObjectDataInput in) throws IOException {
uuid = in.readUTF();
partitionId = in.readInt();
sourceCurrentReplicaIndex = in.readByte();
sourceNewReplicaIndex = in.readByte();
destinationCurrentReplicaIndex = in.readByte();
destinationNewReplicaIndex = in.readByte();
status = MigrationStatus.readFrom(in);
boolean hasSource = in.readBoolean();
if (hasSource) {
source = new Address();
source.readData(in);
sourceUuid = in.readUTF();
}
boolean hasDestination = in.readBoolean();
if (hasDestination) {
destination = new Address();
destination.readData(in);
destinationUuid = in.readUTF();
}
master = new Address();
master.readData(in);
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class PartitionRuntimeState method writeData.
@SuppressWarnings("checkstyle:npathcomplexity")
@Override
public void writeData(ObjectDataOutput out) throws IOException {
out.writeInt(version);
if (addressToIndexes == null) {
out.writeInt(addresses.length);
for (int index = 0; index < addresses.length; index++) {
Address address = addresses[index];
address.writeData(out);
out.writeInt(index);
}
} else {
int memberCount = addressToIndexes.size();
out.writeInt(memberCount);
for (Map.Entry<Address, Integer> entry : addressToIndexes.entrySet()) {
Address address = entry.getKey();
address.writeData(out);
int index = entry.getValue();
out.writeInt(index);
}
}
out.writeInt(minimizedPartitionTable.length);
for (int[] indexes : minimizedPartitionTable) {
for (int ix = 0; ix < MAX_REPLICA_COUNT; ix++) {
out.writeInt(indexes[ix]);
}
}
if (activeMigration != null) {
out.writeBoolean(true);
activeMigration.writeData(out);
} else {
out.writeBoolean(false);
}
if (completedMigrations != null) {
int k = completedMigrations.size();
out.writeInt(k);
for (MigrationInfo migrationInfo : completedMigrations) {
migrationInfo.writeData(out);
}
} else {
out.writeInt(0);
}
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class PartitionRuntimeState method getPartitionTable.
public Address[][] getPartitionTable() {
if (addresses == null) {
addresses = new Address[addressToIndexes.size()];
for (Map.Entry<Address, Integer> entry : addressToIndexes.entrySet()) {
addresses[entry.getValue()] = entry.getKey();
}
}
int length = minimizedPartitionTable.length;
Address[][] result = new Address[length][MAX_REPLICA_COUNT];
for (int partitionId = 0; partitionId < length; partitionId++) {
Address[] replicas = result[partitionId];
int[] addressIndexes = minimizedPartitionTable[partitionId];
for (int replicaIndex = 0; replicaIndex < addressIndexes.length; replicaIndex++) {
int index = addressIndexes[replicaIndex];
if (index != -1) {
Address address = addresses[index];
assert address != null;
replicas[replicaIndex] = address;
}
}
}
return result;
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class PartitionRuntimeState method createAddressToIndexMap.
private Map<Address, Integer> createAddressToIndexMap(InternalPartition[] partitions) {
Map<Address, Integer> map = new HashMap<Address, Integer>();
int addressIndex = 0;
for (InternalPartition partition : partitions) {
for (int i = 0; i < MAX_REPLICA_COUNT; i++) {
Address address = partition.getReplicaAddress(i);
if (address == null) {
continue;
}
if (map.containsKey(address)) {
continue;
}
map.put(address, addressIndex++);
}
}
return map;
}
use of com.hazelcast.nio.Address in project hazelcast by hazelcast.
the class PartitionTableView method writeData.
public static void writeData(PartitionTableView table, ObjectDataOutput out) throws IOException {
Address[][] addresses = table.addresses;
out.writeInt(addresses.length);
for (Address[] a : addresses) {
for (int j = 0; j < MAX_REPLICA_COUNT; j++) {
Address address = a[j];
boolean addressExists = address != null;
out.writeBoolean(addressExists);
if (addressExists) {
address.writeData(out);
}
}
}
out.writeInt(table.version);
}
Aggregations