Projects >> AxonFramework >>6849ba3a9a008e1c74cab6c7dc87c22c1621f1b8

Chunk
Conflicting content
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
<<<<<<< HEAD
import java.util.*;
import java.util.concurrent.*;
=======
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
>>>>>>> 3219ecb40a9c68e3adcfee44ebf3ad50e9f83b28
import java.util.concurrent.atomic.AtomicReference;

/**
Solution content
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicReference;

/**
File
JGroupsConnector.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
     * clusterName and serializer configuration in order to successfully set up a distributed
     * cluster.
     *
<<<<<<< HEAD
     * @param channel            The channel (configured, but not connected) used to discover and connect with the
     *                           other members
     * @param clusterName        The name of the cluster to connect to
     * @param localSegment       The command bus on which messages with this member as destination are dispatched on
     * @param serializer         The serialized used to serialize messages before sending them to other members.
     * @param hashChangeListener The listener to notify when the consistent hash is changed
     */
    public JGroupsConnector(JChannel channel, String clusterName, CommandBus localSegment, Serializer serializer,
                            HashChangeListener hashChangeListener) {
=======
     * @param channel      The channel (configured, but not connected) used to discover and connect with the other
     *                     members
     * @param clusterName  The name of the cluster to connect to
     * @param localSegment The command bus on which messages with this member as destination are dispatched on
     * @param serializer   The serialized used to serialize messages before sending them to other members.
     */
    public JGroupsConnector(JChannel channel, String clusterName, CommandBus localSegment, Serializer serializer, HashChangeListener hashChangeListener) {
>>>>>>> 3219ecb40a9c68e3adcfee44ebf3ad50e9f83b28
        this.channel = channel;
        this.clusterName = clusterName;
        this.localSegment = localSegment;
Solution content
     * clusterName and serializer configuration in order to successfully set up a distributed
     * cluster.
     *
     * @param channel            The channel (configured, but not connected) used to discover and connect with the
     *                           other members
     * @param clusterName        The name of the cluster to connect to
     * @param localSegment       The command bus on which messages with this member as destination are dispatched on
     * @param serializer         The serialized used to serialize messages before sending them to other members.
     * @param hashChangeListener The listener to notify when the consistent hash is changed
     */
    public JGroupsConnector(JChannel channel, String clusterName, CommandBus localSegment, Serializer serializer,
                            HashChangeListener hashChangeListener) {
        this.channel = channel;
        this.clusterName = clusterName;
        this.localSegment = localSegment;
File
JGroupsConnector.java
Developer's decision
Version 1
Kind of conflict
Comment
Method signature
Chunk
Conflicting content
    private ApplicationContext applicationContext;
    private List interceptors;
    private long joinTimeout = -1;
<<<<<<< HEAD
    private boolean registerMBean = false;
=======
>>>>>>> 3219ecb40a9c68e3adcfee44ebf3ad50e9f83b28
    private HashChangeListener hashChangeListener;

    @Override
Solution content
    private ApplicationContext applicationContext;
    private List interceptors;
    private long joinTimeout = -1;
    private boolean registerMBean = false;
    private HashChangeListener hashChangeListener;

    @Override
File
JGroupsConnectorFactoryBean.java
Developer's decision
Version 1
Kind of conflict
Attribute
Chunk
Conflicting content
    }

    /**
<<<<<<< HEAD
     * Registers the JChannel monitoring bean after the channel has connected. Defaults to false.
     *
     * @param registerMBean
     */
    public void setRegisterMBean(boolean registerMBean) {
        this.registerMBean = registerMBean;
    }

    /**
=======
>>>>>>> 3219ecb40a9c68e3adcfee44ebf3ad50e9f83b28
     * Register a {@link HashChangeListener} with the {@link JGroupsConnector}. The listener
     * will be notified when the consistent hash changes due to members joining or leaving the
     * JGroup.
Solution content
    }

    /**
     * Register a {@link HashChangeListener} with the {@link JGroupsConnector}. The listener
     * will be notified when the consistent hash changes due to members joining or leaving the
     * JGroup.
     *
     * @param hashChangeListener
     */
    public void setHashChangeListener(HashChangeListener hashChangeListener) {
        this.hashChangeListener = hashChangeListener;
    }

    /**
     * Registers the JChannel monitoring bean after the channel has connected. Defaults to false.
     *
     * @param registerMBean
     */
    public void setRegisterMBean(boolean registerMBean) {
        this.registerMBean = registerMBean;
    }

    /**
     * Register a {@link HashChangeListener} with the {@link JGroupsConnector}. The listener
     * will be notified when the consistent hash changes due to members joining or leaving the
     * JGroup.
File
JGroupsConnectorFactoryBean.java
Developer's decision
Manual
Kind of conflict
Comment
Method declaration
Chunk
Conflicting content
        mockChannel = mock(JChannel.class);
        mockConnector = mock(JGroupsConnector.class);
        mockListener = mock(HashChangeListener.class);
<<<<<<< HEAD
=======

>>>>>>> 3219ecb40a9c68e3adcfee44ebf3ad50e9f83b28
        when(mockApplicationContext.getBean(Serializer.class)).thenReturn(new XStreamSerializer());
        whenNew(JChannel.class).withParameterTypes(String.class).withArguments(isA(String.class))
                .thenReturn(mockChannel);
Solution content
        mockChannel = mock(JChannel.class);
        mockConnector = mock(JGroupsConnector.class);
        mockListener = mock(HashChangeListener.class);
        when(mockApplicationContext.getBean(Serializer.class)).thenReturn(new XStreamSerializer());
        whenNew(JChannel.class).withParameterTypes(String.class).withArguments(isA(String.class))
                .thenReturn(mockChannel);
File
JGroupsConnectorFactoryBeanTest.java
Developer's decision
Version 1
Kind of conflict
Blank
Chunk
Conflicting content
        whenNew(JChannel.class).withParameterTypes(String.class).withArguments(isA(String.class))
                .thenReturn(mockChannel);
        whenNew(JGroupsConnector.class)
<<<<<<< HEAD
                .withArguments(isA(JChannel.class),
                               isA(String.class),
                               isA(CommandBus.class),
                               isA(Serializer.class),
                               anyObject() /*HashChangeListener or null */)
=======
                .withArguments(isA(JChannel.class), isA(String.class), isA(CommandBus.class), isA(Serializer.class), anyObject())
>>>>>>> 3219ecb40a9c68e3adcfee44ebf3ad50e9f83b28
                .thenReturn(mockConnector);

        testSubject = new JGroupsConnectorFactoryBean();
Solution content
        whenNew(JChannel.class).withParameterTypes(String.class).withArguments(isA(String.class))
                .thenReturn(mockChannel);
        whenNew(JGroupsConnector.class)
                .withArguments(isA(JChannel.class),
                               isA(String.class),
                               isA(CommandBus.class),
                               isA(Serializer.class),
                               anyObject() /*HashChangeListener or null */)
                .thenReturn(mockConnector);

        testSubject = new JGroupsConnectorFactoryBean();
File
JGroupsConnectorFactoryBeanTest.java
Developer's decision
Version 1
Kind of conflict
Comment
Method invocation
Chunk
Conflicting content
        verifyNew(JChannel.class).withArguments("custom.xml");
        verifyNew(JGroupsConnector.class).withArguments(eq(mockChannel), eq("ClusterName"),
<<<<<<< HEAD
                                                        same(localSegment), same(serializer), same(mockListener));
=======
                same(localSegment), same(serializer), same(mockListener));
>>>>>>> 3219ecb40a9c68e3adcfee44ebf3ad50e9f83b28
        verify(mockApplicationContext, never()).getBean(Serializer.class);
        verify(mockChannel).setName("localname");
        verify(mockConnector).connect(200);
Solution content
        verifyNew(JChannel.class).withArguments("custom.xml");
        verifyNew(JGroupsConnector.class).withArguments(eq(mockChannel), eq("ClusterName"),
                                                        same(localSegment), same(serializer), same(mockListener));
        verify(mockApplicationContext, never()).getBean(Serializer.class);
        verify(mockChannel).setName("localname");
        verify(mockConnector).connect(200);
File
JGroupsConnectorFactoryBeanTest.java
Developer's decision
Version 1
Kind of conflict
Attribute
Method invocation
Variable
Chunk
Conflicting content
        verify(mockCommandBus2, times(66)).dispatch(any(CommandMessage.class), isA(CommandCallback.class));
    }

<<<<<<< HEAD
    @Test(timeout = 300000)
    public void testHashChangeNotification() throws Exception {
        connector1.connect(10);
        connector2.connect(10);

        // wait for both connectors to have the same view
        waitForConnectorSync();

        // connector 1 joined
        ConsistentHash notify1 = hashChangeListener.notifications.poll(5, TimeUnit.SECONDS);

        // connector 2 joined
        ConsistentHash notify2 = hashChangeListener.notifications.poll(5, TimeUnit.SECONDS);
        // Self and other node have joined
        assertEquals(connector1.getConsistentHash(), notify2);

        channel2.close();

        // Other node has left
        ConsistentHash notify3 = hashChangeListener.notifications.poll(5, TimeUnit.SECONDS);
        assertEquals(connector1.getConsistentHash(), notify3);
    }


=======
>>>>>>> 3219ecb40a9c68e3adcfee44ebf3ad50e9f83b28
    private static void closeSilently(JChannel channel) {
        try {
            channel.close();
Solution content
        verify(mockCommandBus2, times(66)).dispatch(any(CommandMessage.class), isA(CommandCallback.class));
    }

    @Test(timeout = 300000)
    public void testHashChangeNotification() throws Exception {
        connector1.connect(10);
        connector2.connect(10);

        // wait for both connectors to have the same view
        waitForConnectorSync();

        // connector 1 joined
        ConsistentHash notify1 = hashChangeListener.notifications.poll(5, TimeUnit.SECONDS);

        // connector 2 joined
        ConsistentHash notify2 = hashChangeListener.notifications.poll(5, TimeUnit.SECONDS);
        // Self and other node have joined
        assertEquals(connector1.getConsistentHash(), notify2);

        channel2.close();

        // Other node has left
        ConsistentHash notify3 = hashChangeListener.notifications.poll(5, TimeUnit.SECONDS);
        assertEquals(connector1.getConsistentHash(), notify3);
    }


    private static void closeSilently(JChannel channel) {
        try {
            channel.close();
File
JGroupsConnectorTest.java
Developer's decision
Version 1
Kind of conflict
Annotation
Method declaration