/** * Return fake, temporary DistributedMember to represent the other vm this vm is connecting to * * @param sock the socket this handshake is operating on * @return temporary id to reprent the other vm */ private InternalDistributedMember getIDForSocket(Socket sock) { return new InternalDistributedMember(sock.getInetAddress(), sock.getPort(), false); }
/** * Notifies registered listeners that a Client member has left * * @param location the address of the server */ public static void notifyServerLeft(final ServerLocation location) { DistributedMember id = new InternalDistributedMember(location); notifyListeners(id, false, EventType.LEFT); }
/** this reads an ID written with writeEssentialData */ public static InternalDistributedMember readEssentialData(DataInput in) throws IOException, ClassNotFoundException { final InternalDistributedMember mbr = new InternalDistributedMember(); mbr._readEssentialData(in); return mbr; }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { this.memberId = new InternalDistributedMember(); InternalDataSerializer.invokeFromData(this.memberId, in); this.prType = in.readInt(); this.isPersistent = in.readBoolean(); this.cacheLoaderWriterByte = in.readByte(); this.serialNumber = in.readInt(); }
/** * Notifies registered listeners that a Client member has connected * * @param location the address of the server */ public static void notifyServerJoined(final ServerLocation location) { DistributedMember id = new InternalDistributedMember(location); notifyListeners(id, false, EventType.JOINED); }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { this.peerMemberId = new InternalDistributedMember(); InternalDataSerializer.invokeFromData(this.peerMemberId, in); this.version = in.readInt(); this.serialNumber = in.readInt(); }
/** * Reads an instance of <code>IpAddress</code> from a <code>DataInput</code>. * * @throws IOException A problem occurs while reading from <code>in</code> */ public static InternalDistributedMember readInternalDistributedMember(DataInput in) throws IOException, ClassNotFoundException { InternalDistributedMember o = new InternalDistributedMember(); InternalDataSerializer.invokeFromData(o, in); return o; }
/** * Notifies registered listeners that a Client member has crashed * * @param location the address of the server */ public static void notifyServerCrashed(final ServerLocation location) { DistributedMember id = new InternalDistributedMember(location); notifyListeners(id, false, EventType.CRASHED); }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); this.bucketId = in.readInt(); this.isRebalance = in.readBoolean(); this.replaceOfflineData = in.readBoolean(); boolean hasMoveSource = in.readBoolean(); if (hasMoveSource) { this.moveSource = new InternalDistributedMember(); InternalDataSerializer.invokeFromData(this.moveSource, in); } this.forceCreation = in.readBoolean(); }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); this.bucketId = in.readInt(); newPrimary = new InternalDistributedMember(); InternalDataSerializer.invokeFromData(newPrimary, in); }
@Override public void fromData(DataInput in) throws IOException, ClassNotFoundException { super.fromData(in); boolean hasPrimary = in.readBoolean(); if (hasPrimary) { primary = new InternalDistributedMember(); InternalDataSerializer.invokeFromData(primary, in); } }
private void setClientProxyMembershipId() { ServerLocation serverLocation = new ServerLocation( ((InetSocketAddress) this.getSocket().getRemoteSocketAddress()).getHostName(), this.getSocketPort()); DistributedMember distributedMember = new InternalDistributedMember(serverLocation); // no handshake for new client protocol. clientProxyMembershipID = new ClientProxyMembershipID(distributedMember); }
@Before public void setup() throws UnknownHostException { region = mock(PartitionedRegion.class); rebalanceOp = mock(PartitionedRegionRebalanceOp.class); completion = mock(Completion.class); resourceObserver = spy(new InternalResourceManager.ResourceObserverAdapter()); InternalResourceManager.setResourceObserver(resourceObserver); doReturn(region).when(rebalanceOp).getLeaderRegion(); operator = new BucketOperatorImpl(rebalanceOp); sourceMember = new InternalDistributedMember(InetAddress.getByName("127.0.0.1"), 1); targetMember = new InternalDistributedMember(InetAddress.getByName("127.0.0.2"), 1); }
@Test public void throwsExceptionWhenBackupRequesterHasLeftDistributedSystem() { InternalDistributedMember oldSender = new InternalDistributedMember("localhost", 5556); assertThatThrownBy(() -> backupService.validateRequestingSender(oldSender)) .isInstanceOf(IllegalStateException.class); }
@Before public void setup() { manager = mock(DistributionManager.class); when(manager.getDistributionManagerId()) .thenReturn(new InternalDistributedMember("localhost", 1)); partitionedRegion = mock(PartitionedRegion.class); advisor = mock(DistributionAdvisor.class); when(partitionedRegion.getDistributionAdvisor()).thenReturn(advisor); when(partitionedRegion.getRegionIdentifier()).thenReturn("testRegion"); }
@Before public final void setUp() throws Exception { originalBitSetWidth = RegionVersionHolder.BIT_SET_WIDTH; member = new InternalDistributedMember(InetAddress.getLocalHost(), 12345); postSetUp(); }
@Test public void memberNoGroup_isOK() { result1 = new CliFunctionResult("member1", CliFunctionResult.StatusState.OK, "result1"); functionResults.add(result1); Set<DistributedMember> membersSet = new HashSet<>(); membersSet.add(new InternalDistributedMember("member1", 0)); doReturn(membersSet).when(command).findMembers(null, new String[] {"member1"}); CommandResultAssert resultAssert = gfsh.executeAndAssertThat(command, "destroy gateway-receiver --member=\"member1\""); resultAssert.statusIsSuccess().tableHasColumnWithValuesContaining("Message", "result1"); }
@Test public void groupNoMember_isOK() { result1 = new CliFunctionResult("member1", CliFunctionResult.StatusState.OK, "result1"); functionResults.add(result1); Set<DistributedMember> membersSet = new HashSet<>(); membersSet.add(new InternalDistributedMember("member1", 0)); doReturn(membersSet).when(command).findMembers(new String[] {"group1"}, null); CommandResultAssert resultAssert = gfsh.executeAndAssertThat(command, "destroy gateway-receiver --group=\"group1\""); resultAssert.statusIsSuccess().tableHasColumnWithValuesContaining("Message", "result1"); } }
@Test public void testRecordVersionDuringRegionInit() { LocalRegion mockRegion = mock(LocalRegion.class); when(mockRegion.isInitialized()).thenReturn(false); final String local = getIPLiteral(); InternalDistributedMember ownerId = new InternalDistributedMember(local, 101); VMVersionTag tag = new VMVersionTag(); tag.setRegionVersion(1L); RegionVersionVector rvv = createRegionVersionVector(ownerId, mockRegion); rvv.recordVersion(ownerId, tag); assertEquals(1, rvv.getVersionForMember(ownerId)); }
@Test public void recordVersionIntoLocalMemberShouldPassfRegionIsNonPersistent() { LocalRegion mockRegion = mock(LocalRegion.class); when(mockRegion.isInitialized()).thenReturn(true); when(mockRegion.getDataPolicy()).thenReturn(DataPolicy.REPLICATE); final String local = getIPLiteral(); InternalDistributedMember ownerId = new InternalDistributedMember(local, 101); RegionVersionVector rvv = createRegionVersionVector(ownerId, mockRegion); VMVersionTag tag = new VMVersionTag(); tag.setRegionVersion(1); tag.setMemberID(ownerId); rvv.recordVersion(ownerId, tag); assertEquals(1, rvv.getLocalExceptions().version); assertEquals(2, rvv.getNextVersion()); }