use of com.thinkbiganalytics.cluster.ClusterService in project kylo by Teradata.
the class SparkShellClusterListenerTest method onConnected.
/**
* Verify message to cluster on connection.
*/
@Test
public void onConnected() {
// Test process connected
final ClusterService clusterService = Mockito.mock(ClusterService.class);
final SparkShellClusterListener clusterListener = new SparkShellClusterListener(clusterService, Mockito.mock(SparkShellClusterDelegate.class));
clusterListener.onConnected(ImmutableList.of("node1", "node2"));
// Verify message
final ArgumentCaptor<SparkShellProcessSyncMessage> messageCaptor = ArgumentCaptor.forClass(SparkShellProcessSyncMessage.class);
Mockito.verify(clusterService).sendMessageToOthers(Mockito.eq(SparkShellProcessSyncMessage.TYPE), messageCaptor.capture());
Assert.assertNull(messageCaptor.getValue().getProcesses());
}
use of com.thinkbiganalytics.cluster.ClusterService in project kylo by Teradata.
the class SparkShellClusterListenerTest method processStopped.
/**
* Verify message to cluster on process stopped.
*/
@Test
public void processStopped() {
// Mock cluster service
final ClusterService clusterService = Mockito.mock(ClusterService.class);
Mockito.when(clusterService.isClustered()).thenReturn(true);
// Test process stopped
final SparkShellClusterListener clusterListener = new SparkShellClusterListener(clusterService, Mockito.mock(SparkShellClusterDelegate.class));
final SparkLauncherSparkShellProcess process = Mockito.mock(SparkLauncherSparkShellProcess.class);
Mockito.when(process.getClientId()).thenReturn(CLIENT_ID);
clusterListener.processStopped(process);
// Verify message
final ArgumentCaptor<SparkShellProcessChangedMessage> messageCaptor = ArgumentCaptor.forClass(SparkShellProcessChangedMessage.class);
Mockito.verify(clusterService).sendMessageToOthers(Mockito.eq(SparkShellProcessChangedMessage.TYPE), messageCaptor.capture());
Assert.assertEquals(CLIENT_ID, messageCaptor.getValue().getClientId());
Assert.assertNull(messageCaptor.getValue().getProcess());
}
use of com.thinkbiganalytics.cluster.ClusterService in project kylo by Teradata.
the class SparkShellClusterListenerTest method processStarted.
/**
* Verify message to cluster on process started.
*/
@Test
public void processStarted() {
// Mock cluster service
final ClusterService clusterService = Mockito.mock(ClusterService.class);
Mockito.when(clusterService.isClustered()).thenReturn(true);
// Test process started
final SparkShellClusterListener clusterListener = new SparkShellClusterListener(clusterService, Mockito.mock(SparkShellClusterDelegate.class));
final SparkLauncherSparkShellProcess process = Mockito.mock(SparkLauncherSparkShellProcess.class);
Mockito.when(process.getClientId()).thenReturn(CLIENT_ID);
clusterListener.processStarted(process);
// Verify message
final ArgumentCaptor<SparkShellProcessChangedMessage> messageCaptor = ArgumentCaptor.forClass(SparkShellProcessChangedMessage.class);
Mockito.verify(clusterService).sendMessageToOthers(Mockito.eq(SparkShellProcessChangedMessage.TYPE), messageCaptor.capture());
Assert.assertEquals(CLIENT_ID, messageCaptor.getValue().getClientId());
Assert.assertEquals(process, messageCaptor.getValue().getProcess());
}
use of com.thinkbiganalytics.cluster.ClusterService in project kylo by Teradata.
the class SparkShellClusterListenerTest method processReady.
/**
* Verify message to cluster on process ready.
*/
@Test
public void processReady() {
// Mock cluster service
final ClusterService clusterService = Mockito.mock(ClusterService.class);
Mockito.when(clusterService.isClustered()).thenReturn(true);
// Test process ready
final SparkShellClusterListener clusterListener = new SparkShellClusterListener(clusterService, Mockito.mock(SparkShellClusterDelegate.class));
final SparkLauncherSparkShellProcess process = Mockito.mock(SparkLauncherSparkShellProcess.class);
Mockito.when(process.getClientId()).thenReturn(CLIENT_ID);
clusterListener.processReady(process);
// Verify message
final ArgumentCaptor<SparkShellProcessChangedMessage> messageCaptor = ArgumentCaptor.forClass(SparkShellProcessChangedMessage.class);
Mockito.verify(clusterService).sendMessageToOthers(Mockito.eq(SparkShellProcessChangedMessage.TYPE), messageCaptor.capture());
Assert.assertEquals(CLIENT_ID, messageCaptor.getValue().getClientId());
Assert.assertEquals(process, messageCaptor.getValue().getProcess());
}
Aggregations