List of usage examples for org.apache.cassandra.streaming StreamManagerMBean getCurrentStreams
Set<CompositeData> getCurrentStreams();
From source file:io.cassandrareaper.service.StreamManagerTest.java
License:Apache License
@Test public void testGetStreams_2_0_17() throws OpenDataException, IOException, ReaperException, ClassNotFoundException, InterruptedException { // fake the response a 2.0.17 would return when asked for streams CompositeData streamSession = makeCompositeData_2_0_17(); // compare the test payload with an actual payload grabbed from a 2.0.17 ccm node URL url = Resources.getResource("repair-samples/stream-report-2-0-17.txt"); String ref = Resources.toString(url, Charsets.UTF_8); assertEquals(ref.replaceAll("\\s", ""), streamSession.toString().replaceAll("\\s", "")); // init the stream manager JmxProxy proxy = (JmxProxy) mock(Class.forName("io.cassandrareaper.jmx.JmxProxyImpl")); StreamManagerMBean streamingManagerMBean = Mockito.mock(StreamManagerMBean.class); JmxProxyTest.mockGetStreamManagerMBean(proxy, streamingManagerMBean); when(streamingManagerMBean.getCurrentStreams()).thenReturn(ImmutableSet.of(streamSession)); AppContext cxt = new AppContext(); cxt.config = TestRepairConfiguration.defaultConfig(); cxt.jmxConnectionFactory = mock(JmxConnectionFactory.class); when(cxt.jmxConnectionFactory.connect(Mockito.any(Node.class), Mockito.anyInt())).thenReturn(proxy); // do the actual pullStreams() call, which should succeed List<StreamSession> result = StreamManager.create(cxt) .listStreams(Node.builder().withClusterName("test").withHostname("127.0.0.1").build()); verify(streamingManagerMBean, times(1)).getCurrentStreams(); assertEquals(1, result.size());/*from w w w. j av a 2 s . co m*/ }
From source file:io.cassandrareaper.service.StreamManagerTest.java
License:Apache License
@Test public void testGetStreams_2_1_20() throws OpenDataException, IOException, ReaperException, ClassNotFoundException, InterruptedException { // fake the response a 2.1.20 would return when asked for streams CompositeData streamSession = makeCompositeData_2_1_20(); // compare the test payload with an actual payload grabbed from a 2.1.20 ccm node URL url = Resources.getResource("repair-samples/stream-report-2-1-20.txt"); String ref = Resources.toString(url, Charsets.UTF_8); assertEquals(ref.replaceAll("\\s", ""), streamSession.toString().replaceAll("\\s", "")); // init the stream manager JmxProxy proxy = (JmxProxy) mock(Class.forName("io.cassandrareaper.jmx.JmxProxyImpl")); StreamManagerMBean streamingManagerMBean = Mockito.mock(StreamManagerMBean.class); JmxProxyTest.mockGetStreamManagerMBean(proxy, streamingManagerMBean); when(streamingManagerMBean.getCurrentStreams()).thenReturn(ImmutableSet.of(streamSession)); AppContext cxt = new AppContext(); cxt.config = TestRepairConfiguration.defaultConfig(); cxt.jmxConnectionFactory = mock(JmxConnectionFactory.class); when(cxt.jmxConnectionFactory.connect(Mockito.any(Node.class), Mockito.anyInt())).thenReturn(proxy); // do the actual pullStreams() call, which should succeed List<StreamSession> result = StreamManager.create(cxt) .listStreams(Node.builder().withClusterName("test").withHostname("127.0.0.1").build()); verify(streamingManagerMBean, times(1)).getCurrentStreams(); assertEquals(1, result.size());// w ww .j a v a 2 s. co m }
From source file:io.cassandrareaper.service.StreamManagerTest.java
License:Apache License
@Test public void testGetStreams_2_2_12() throws IOException, ReaperException, OpenDataException, ClassNotFoundException, InterruptedException { // fake the response a 2.2.12 would return when asked for streams CompositeData streamSession = makeCompositeData_2_2_12(); // compare the test payload with an actual payload grabbed from a 2.1.20 ccm node URL url = Resources.getResource("repair-samples/stream-report-2-2-12.txt"); String ref = Resources.toString(url, Charsets.UTF_8); assertEquals(ref.replaceAll("\\s", ""), streamSession.toString().replaceAll("\\s", "")); // init the stream manager JmxProxy proxy = (JmxProxy) mock(Class.forName("io.cassandrareaper.jmx.JmxProxyImpl")); StreamManagerMBean streamingManagerMBean = Mockito.mock(StreamManagerMBean.class); JmxProxyTest.mockGetStreamManagerMBean(proxy, streamingManagerMBean); when(streamingManagerMBean.getCurrentStreams()).thenReturn(ImmutableSet.of(streamSession)); AppContext cxt = new AppContext(); cxt.config = TestRepairConfiguration.defaultConfig(); cxt.jmxConnectionFactory = mock(JmxConnectionFactory.class); when(cxt.jmxConnectionFactory.connect(Mockito.any(Node.class), Mockito.anyInt())).thenReturn(proxy); // do the actual pullStreams() call, which should succeed List<StreamSession> result = StreamManager.create(cxt) .listStreams(Node.builder().withClusterName("test").withHostname("127.0.0.1").build()); verify(streamingManagerMBean, times(1)).getCurrentStreams(); assertEquals(1, result.size());/* w w w. j av a 2s . c om*/ }
From source file:io.cassandrareaper.service.StreamManagerTest.java
License:Apache License
@Test public void testGetStreams_3_11_2() throws OpenDataException, IOException, ReaperException, ClassNotFoundException, InterruptedException { // fake the response a 2.2.12 would return when asked for streams CompositeData streamSession = makeCompositeData_3_11_2(); // compare the test payload with an actual payload grabbed from a 2.1.20 ccm node URL url = Resources.getResource("repair-samples/stream-report-3-11-2.txt"); String ref = Resources.toString(url, Charsets.UTF_8); assertEquals(ref.replaceAll("\\s", ""), streamSession.toString().replaceAll("\\s", "")); // init the stream manager JmxProxy proxy = (JmxProxy) mock(Class.forName("io.cassandrareaper.jmx.JmxProxyImpl")); StreamManagerMBean streamingManagerMBean = Mockito.mock(StreamManagerMBean.class); JmxProxyTest.mockGetStreamManagerMBean(proxy, streamingManagerMBean); when(streamingManagerMBean.getCurrentStreams()).thenReturn(ImmutableSet.of(streamSession)); AppContext cxt = new AppContext(); cxt.config = TestRepairConfiguration.defaultConfig(); cxt.jmxConnectionFactory = mock(JmxConnectionFactory.class); when(cxt.jmxConnectionFactory.connect(Mockito.any(Node.class), Mockito.anyInt())).thenReturn(proxy); // do the actual pullStreams() call, which should succeed List<StreamSession> result = StreamManager.create(cxt) .listStreams(Node.builder().withClusterName("test").withHostname("127.0.0.1").build()); verify(streamingManagerMBean, times(1)).getCurrentStreams(); assertEquals(1, result.size());//from w w w. j a va 2 s . c o m }