예제 #1
0
            public override void Receive(Payload payload)
            {
                try
                {
                    object value = outerInstance.Serializer.receive(payload);
                    if (value is MemberIsAvailable)
                    {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final MemberIsAvailable memberIsAvailable = (MemberIsAvailable) value;
                        MemberIsAvailable memberIsAvailable = ( MemberIsAvailable )value;

                        // Update snapshot
                        outerInstance.clusterMembersSnapshot.AvailableMember(memberIsAvailable);

                        outerInstance.log.Info("Snapshot:" + outerInstance.clusterMembersSnapshot.CurrentAvailableMembers);

                        outerInstance.Listeners.notify(listener => listener.memberIsAvailable(memberIsAvailable.Role, memberIsAvailable.InstanceId, memberIsAvailable.RoleUri, memberIsAvailable.StoreId));
                    }
                    else if (value is MemberIsUnavailable)
                    {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final MemberIsUnavailable memberIsUnavailable = (MemberIsUnavailable) value;
                        MemberIsUnavailable memberIsUnavailable = ( MemberIsUnavailable )value;

                        // Update snapshot
                        outerInstance.clusterMembersSnapshot.UnavailableMember(memberIsUnavailable.ClusterUri, memberIsUnavailable.InstanceId, memberIsUnavailable.Role);

                        outerInstance.Listeners.notify(listener => listener.memberIsUnavailable(memberIsUnavailable.Role, memberIsUnavailable.InstanceId));
                    }
                }
                catch (Exception t)
                {
                    outerInstance.log.Error(string.Format("Could not handle cluster member available message: {0} ({1:D})", Base64.Encoder.encodeToString(payload.Buf), payload.Len), t);
                }
            }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeSerializedWhenClusterUriIsNull() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeSerializedWhenClusterUriIsNull()
        {
            // Given
            MemberIsUnavailable message = new MemberIsUnavailable("master", new InstanceId(1), null);

            // When
            sbyte[] serialized = Serialize(message);

            // Then
            assertNotEquals(0, serialized.Length);
        }
예제 #3
0
 public override void MemberIsUnavailable(string role)
 {
     try
     {
         MemberIsUnavailable message = new MemberIsUnavailable(role, _myId, _serverClusterId);
         Payload             payload = Serializer.broadcast(message);
         _atomicBroadcast.broadcast(payload);
     }
     catch (Exception e)
     {
         _log.warn("Could not distribute member unavailability", e);
     }
 }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeDeserializedWhenClusterUriIsNull() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBeDeserializedWhenClusterUriIsNull()
        {
            // Given
            MemberIsUnavailable message = new MemberIsUnavailable("slave", new InstanceId(1), null);

            sbyte[] serialized = Serialize(message);

            // When
            MemberIsUnavailable deserialized = Deserialize(serialized);

            // Then
            assertNotSame(message, deserialized);
            assertEquals("slave", message.Role);
            assertEquals(new InstanceId(1), message.InstanceId);
            assertNull(message.ClusterUri);
        }
예제 #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static byte[] serialize(MemberIsUnavailable message) throws java.io.IOException
        private static sbyte[] Serialize(MemberIsUnavailable message)
        {
            ObjectOutputStream outputStream = null;

            try
            {
                MemoryStream byteArrayOutputStream = new MemoryStream();
                outputStream = (new ObjectStreamFactory()).create(byteArrayOutputStream);
                outputStream.writeObject(message);
                return(byteArrayOutputStream.toByteArray());
            }
            finally
            {
                if (outputStream != null)
                {
                    outputStream.close();
                }
            }
        }