use of org.apache.oozie.dependency.hcat.HCatMessageHandler in project oozie by apache.
the class TestHAPartitionDependencyManagerService method addMissingDependencyAndRegister.
protected void addMissingDependencyAndRegister(HCatURI hcatURI, String actionId, PartitionDependencyManagerService pdms) {
pdms.addMissingDependency(hcatURI, actionId);
HCatAccessorService hcatService = Services.get().get(HCatAccessorService.class);
if (!hcatService.isRegisteredForNotification(hcatURI)) {
hcatService.registerForNotification(hcatURI, hcatURI.getDb() + "." + hcatURI.getTable(), new HCatMessageHandler(hcatURI.getServer()));
}
}
use of org.apache.oozie.dependency.hcat.HCatMessageHandler in project oozie by apache.
the class TestJMSAccessorService method testUnRegisterTopic.
@Test
public void testUnRegisterTopic() {
try {
HCatAccessorService hcatService = services.get(HCatAccessorService.class);
JMSAccessorService jmsService = services.get(JMSAccessorService.class);
String server = "hcat.server.com:5080";
String topic = "hcatalog.mydb.mytable";
JMSConnectionInfo connInfo = hcatService.getJMSConnectionInfo(new URI("hcat://hcat.server.com:8020"));
jmsService.registerForNotification(connInfo, topic, new HCatMessageHandler(server));
MessageReceiver receiver1 = jmsService.getMessageReceiver(connInfo, topic);
assertNotNull(receiver1);
jmsService.unregisterFromNotification(connInfo, topic);
receiver1 = jmsService.getMessageReceiver(connInfo, topic);
assertEquals(null, receiver1);
} catch (Exception e) {
e.printStackTrace();
fail("Exception encountered : " + e);
}
}
use of org.apache.oozie.dependency.hcat.HCatMessageHandler in project oozie by apache.
the class TestJMSAccessorService method testRegisterSingleConsumerPerTopic.
@Test
public void testRegisterSingleConsumerPerTopic() {
try {
HCatAccessorService hcatService = services.get(HCatAccessorService.class);
JMSAccessorService jmsService = services.get(JMSAccessorService.class);
String server = "hcat.server.com:5080";
String topic = "hcat.mydb.mytable";
JMSConnectionInfo connInfo = hcatService.getJMSConnectionInfo(new URI("hcat://hcat.server.com:8020"));
jmsService.registerForNotification(connInfo, topic, new HCatMessageHandler(server));
MessageReceiver receiver1 = jmsService.getMessageReceiver(connInfo, topic);
jmsService.registerForNotification(connInfo, topic, new HCatMessageHandler(server));
MessageReceiver receiver2 = jmsService.getMessageReceiver(connInfo, topic);
assertEquals(receiver1, receiver2);
} catch (Exception e) {
e.printStackTrace();
fail("Exception encountered : " + e);
}
}
use of org.apache.oozie.dependency.hcat.HCatMessageHandler in project oozie by apache.
the class TestJMSAccessorService method testConnectionRetryExceptionListener.
@Test
public void testConnectionRetryExceptionListener() throws Exception {
services.destroy();
services = super.setupServicesForHCatalog();
int randomPort = 30000 + random.nextInt(10000);
String brokerURL = "tcp://localhost:" + randomPort;
String jndiPropertiesString = "java.naming.factory.initial#" + ActiveMQConnFactory + ";" + "java.naming.provider.url#" + brokerURL + ";" + "connectionFactoryNames#" + "ConnectionFactory";
Configuration servicesConf = services.getConf();
servicesConf.set(JMSAccessorService.CONF_RETRY_INITIAL_DELAY, "1");
servicesConf.set(JMSAccessorService.CONF_RETRY_MAX_ATTEMPTS, "3");
servicesConf.set(HCatAccessorService.JMS_CONNECTIONS_PROPERTIES, "default=" + jndiPropertiesString);
services.init();
HCatAccessorService hcatService = Services.get().get(HCatAccessorService.class);
JMSAccessorService jmsService = Services.get().get(JMSAccessorService.class);
String publisherAuthority = "hcat.server.com:5080";
String topic = "topic.topic1";
// Start the broker
BrokerService broker = new BrokerService();
broker.addConnector(brokerURL);
broker.setDataDirectory(getTestCaseDir());
broker.start();
JMSConnectionInfo connInfo = hcatService.getJMSConnectionInfo(new URI("hcat://hcat.server.com:8020"));
jmsService.registerForNotification(connInfo, topic, new HCatMessageHandler(publisherAuthority));
assertTrue(jmsService.isListeningToTopic(connInfo, topic));
assertFalse(jmsService.isConnectionInRetryList(connInfo));
assertFalse(jmsService.isTopicInRetryList(connInfo, topic));
ConnectionContext connCtxt = jmsService.createConnectionContext(connInfo);
broker.stop();
try {
connCtxt.createSession(Session.AUTO_ACKNOWLEDGE);
fail("Exception expected");
} catch (Exception e) {
Thread.sleep(100);
assertFalse(jmsService.isListeningToTopic(connInfo, topic));
assertTrue(jmsService.isConnectionInRetryList(connInfo));
assertTrue(jmsService.isTopicInRetryList(connInfo, topic));
}
broker = new BrokerService();
broker.addConnector(brokerURL);
broker.setDataDirectory(getTestCaseDir());
broker.start();
Thread.sleep(1000);
assertTrue(jmsService.isListeningToTopic(connInfo, topic));
assertFalse(jmsService.isConnectionInRetryList(connInfo));
assertFalse(jmsService.isTopicInRetryList(connInfo, topic));
broker.stop();
jmsService.destroy();
}
use of org.apache.oozie.dependency.hcat.HCatMessageHandler in project oozie by apache.
the class TestJMSAccessorService method testConnectionRetryMaxAttempt.
@Test
public void testConnectionRetryMaxAttempt() throws Exception {
services.destroy();
services = super.setupServicesForHCatalog();
String jndiPropertiesString = "java.naming.factory.initial#" + ActiveMQConnFactory + ";" + "java.naming.provider.url#" + "tcp://localhost:12345;connectionFactoryNames#ConnectionFactory";
Configuration servicesConf = services.getConf();
servicesConf.set(JMSAccessorService.CONF_RETRY_INITIAL_DELAY, "1");
servicesConf.set(JMSAccessorService.CONF_RETRY_MAX_ATTEMPTS, "1");
servicesConf.set(HCatAccessorService.JMS_CONNECTIONS_PROPERTIES, "default=" + jndiPropertiesString);
services.init();
HCatAccessorService hcatService = Services.get().get(HCatAccessorService.class);
JMSAccessorService jmsService = Services.get().get(JMSAccessorService.class);
String publisherAuthority = "hcat.server.com:5080";
String topic = "topic.topic1";
JMSConnectionInfo connInfo = hcatService.getJMSConnectionInfo(new URI("hcat://hcat.server.com:8020"));
jmsService.registerForNotification(connInfo, topic, new HCatMessageHandler(publisherAuthority));
assertTrue(jmsService.isConnectionInRetryList(connInfo));
assertTrue(jmsService.isTopicInRetryList(connInfo, topic));
assertFalse(jmsService.isListeningToTopic(connInfo, topic));
Thread.sleep(1100);
// Should not retry again as max attempt is 1
assertTrue(jmsService.isConnectionInRetryList(connInfo));
assertTrue(jmsService.isTopicInRetryList(connInfo, topic));
assertFalse(jmsService.isListeningToTopic(connInfo, topic));
assertEquals(1, jmsService.getNumConnectionAttempts(connInfo));
assertFalse(jmsService.retryConnection(connInfo));
jmsService.destroy();
}
Aggregations