use of com.github.ambry.notification.NotificationSystem in project ambry by linkedin.
the class RestServerTest method startShutdownTestWithReporterFactory.
/**
* Tests {@link RestServer#start()} and {@link RestServer#shutdown()} with a custom {@link JmxReporter} factory.
* @throws Exception
*/
@Test
public void startShutdownTestWithReporterFactory() throws Exception {
Properties properties = new Properties();
VerifiableProperties verifiableProperties = getVProps(properties);
ClusterMap clusterMap = new MockClusterMap();
NotificationSystem notificationSystem = new LoggingNotificationSystem();
ObjectNameFactory spyObjectNameFactory = spy(new DefaultObjectNameFactory());
Function<MetricRegistry, JmxReporter> reporterFactory = reporter -> JmxReporter.forRegistry(reporter).createsObjectNamesWith(spyObjectNameFactory).build();
RestServer server = new RestServer(verifiableProperties, clusterMap, notificationSystem, SSL_FACTORY, Collections.emptyList(), reporterFactory);
server.start();
// check that the custom ObjectNameFactory specified in reporterFactory was used.
verify(spyObjectNameFactory, atLeastOnce()).createName(anyString(), anyString(), anyString());
server.shutdown();
server.awaitShutdown();
}
use of com.github.ambry.notification.NotificationSystem in project ambry by linkedin.
the class RestServerTest method startShutdownTest.
/**
* Tests {@link RestServer#start()} and {@link RestServer#shutdown()}.
* @throws Exception
*/
@Test
public void startShutdownTest() throws Exception {
Properties properties = new Properties();
VerifiableProperties verifiableProperties = getVProps(properties);
ClusterMap clusterMap = new MockClusterMap();
NotificationSystem notificationSystem = new LoggingNotificationSystem();
RestServer server = new RestServer(verifiableProperties, clusterMap, notificationSystem, SSL_FACTORY);
server.start();
server.shutdown();
server.awaitShutdown();
}
use of com.github.ambry.notification.NotificationSystem in project ambry by linkedin.
the class VcrRecoveryTest method setup.
/**
* Create a cluster with a vcr node and a recovery (ambry data) node.
* @throws Exception on {@link Exception}
*/
@Before
public void setup() throws Exception {
String vcrMountPath = ClusterMapSnapshotConstants.CLOUD_REPLICA_MOUNT + "/1";
recoveryProperties = new Properties();
recoveryProperties.setProperty("replication.metadata.request.version", "2");
// create vcr node
List<Port> vcrPortList = new ArrayList<>(2);
Port vcrClusterMapPort = new Port(12310, PortType.PLAINTEXT);
Port vcrSslPort = new Port(12410, PortType.SSL);
vcrPortList.add(vcrClusterMapPort);
vcrPortList.add(vcrSslPort);
MockDataNodeId vcrNode = new MockDataNodeId("localhost", vcrPortList, Collections.singletonList(vcrMountPath), dcName);
// create recovery node
recoveryNodePort = new Port(12311, PortType.PLAINTEXT);
ArrayList<Port> recoveryPortList = new ArrayList<>(2);
recoveryPortList.add(recoveryNodePort);
recoveryNode = MockClusterMap.createDataNode(recoveryPortList, dcName, 1);
// create cluster for recovery
recoveryCluster = MockCluster.createOneNodeRecoveryCluster(vcrNode, recoveryNode, dcName);
partitionId = recoveryCluster.getClusterMap().getWritablePartitionIds(null).get(0);
// Start ZK Server and Helix Controller.
if (!zkInfo.isZkServerStarted()) {
zkInfo.startZkServer();
}
helixControllerManager = VcrTestUtil.populateZkInfoAndStartController(zkConnectString, vcrClusterName, recoveryCluster.getClusterMap());
Properties vcrProperties = VcrTestUtil.createVcrProperties(vcrNode.getDatacenterName(), vcrClusterName, zkConnectString, 12310, 12410, 12510, null);
vcrProperties.putAll(recoveryProperties);
NotificationSystem notificationSystem = new MockNotificationSystem(recoveryCluster.getClusterMap());
// Create blobs and data for upload to vcr.
int blobCount = 10;
blobIds = ServerTestUtil.createBlobIds(blobCount, recoveryCluster.getClusterMap(), accountId, containerId, partitionId);
// Create cloud destination and start vcr server.
latchBasedInMemoryCloudDestination = new LatchBasedInMemoryCloudDestination(blobIds, recoveryCluster.getClusterMap());
CloudDestinationFactory cloudDestinationFactory = new LatchBasedInMemoryCloudDestinationFactory(latchBasedInMemoryCloudDestination);
vcrServer = VcrTestUtil.createVcrServer(new VerifiableProperties(vcrProperties), recoveryCluster.getClusterAgentsFactory(), notificationSystem, cloudDestinationFactory);
vcrServer.startup();
// start ambry server with data node
recoveryCluster.initializeServers(notificationSystem, vcrNode, recoveryProperties);
recoveryCluster.startServers();
}
Aggregations