All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.server.hotrod.tx.table.ClientAddress Maven / Gradle / Ivy

package org.infinispan.server.hotrod.tx.table;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;

import org.infinispan.commons.marshall.AdvancedExternalizer;
import org.infinispan.remoting.transport.Address;
import org.infinispan.server.core.ExternalizerIds;

/**
 * A {@link Address} implementation for a client transaction.
 * 

* The {@code localAddress} is the address of the node in which the transaction was replayed. * * @author Pedro Ruivo * @since 9.2 */ public class ClientAddress implements Address { public static final AdvancedExternalizer EXTERNALIZER = new Externalizer(); private final Address localAddress; public ClientAddress(Address localAddress) { this.localAddress = localAddress; } @Override public int compareTo(Address o) { if (o instanceof ClientAddress) { return localAddress == null ? (((ClientAddress) o).localAddress == null ? 0 : -1) : localAddress.compareTo(((ClientAddress) o).localAddress); } return -1; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ClientAddress that = (ClientAddress) o; return Objects.equals(localAddress, that.localAddress); } @Override public int hashCode() { return localAddress == null ? 0 : localAddress.hashCode(); } @Override public String toString() { return "ClientAddress{" + "localAddress=" + localAddress + '}'; } Address getLocalAddress() { return localAddress; } private static class Externalizer implements AdvancedExternalizer { @Override public Set> getTypeClasses() { return Collections.singleton(ClientAddress.class); } @Override public Integer getId() { return ExternalizerIds.CLIENT_ADDRESS; } @Override public void writeObject(ObjectOutput output, ClientAddress object) throws IOException { output.writeObject(object.localAddress); } @Override public ClientAddress readObject(ObjectInput input) throws IOException, ClassNotFoundException { return new ClientAddress((Address) input.readObject()); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy