use of org.apache.oozie.jms.JMSConnectionInfo in project oozie by apache.
the class HCatAccessorService method unregisterFromNotification.
public void unregisterFromNotification(String server, String database, String table) {
String key = server + DELIMITER + database + DELIMITER + table;
String topic = registeredTopicsMap.remove(key);
if (topic != null) {
try {
JMSConnectionInfo connInfo = getJMSConnectionInfo(new URI("hcat://" + server));
jmsService.unregisterFromNotification(connInfo, topic);
} catch (URISyntaxException e) {
LOG.warn("Error unregistering from notification for topic [{0}]. Hcat table=[{1}]", topic, key, e);
}
}
}
use of org.apache.oozie.jms.JMSConnectionInfo in project oozie by apache.
the class HCatAccessorService method registerForNotification.
/**
* Register for notifications on a JMS topic for the specified hcatalog table.
*
* @param hcatURI hcatalog partition URI
* @param topic JMS topic to register to
* @param msgHandler Handler which will process the messages received on the topic
*/
public void registerForNotification(HCatURI hcatURI, String topic, HCatMessageHandler msgHandler) {
JMSConnectionInfo connInfo = getJMSConnectionInfo(hcatURI.getURI());
jmsService.registerForNotification(connInfo, topic, msgHandler);
registeredTopicsMap.put(getKeyForRegisteredTopicsMap(hcatURI), topic);
}
use of org.apache.oozie.jms.JMSConnectionInfo in project oozie by apache.
the class V2AdminServlet method getJMSConnectionInfo.
@Override
protected JsonBean getJMSConnectionInfo(HttpServletRequest request, HttpServletResponse response) throws XServletException, IOException {
Configuration conf = Services.get().getConf();
JMSTopicService jmsTopicService = Services.get().get(JMSTopicService.class);
String connectionProperties = conf.get(JMSJobEventListener.JMS_CONNECTION_PROPERTIES);
if (connectionProperties == null) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E1601, "JMS connection property is not defined");
}
JMSConnectionInfoBean jmsBean = new JMSConnectionInfoBean();
JMSConnectionInfo jmsInfo = new JMSConnectionInfo(connectionProperties);
Properties jmsInfoProps = jmsInfo.getJNDIProperties();
jmsInfoProps.remove("java.naming.security.principal");
jmsBean.setJNDIProperties(jmsInfoProps);
if (jmsTopicService != null) {
jmsBean.setTopicPrefix(jmsTopicService.getTopicPrefix());
jmsBean.setTopicPatternProperties(jmsTopicService.getTopicPatternProperties());
} else {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E1601, "JMSTopicService is not initialized. JMS notification" + "may not be enabled");
}
return jmsBean;
}
use of org.apache.oozie.jms.JMSConnectionInfo in project oozie by apache.
the class TestHCatAccessorService method testGetJMSConnectionInfoNoDefault.
@Test
public void testGetJMSConnectionInfoNoDefault() throws Exception {
services.destroy();
services = super.setupServicesForHCatalog();
Configuration conf = services.getConf();
String server2 = "hcat://${1}.${2}.server.com:8020=java.naming.factory.initial#Dummy.Factory;" + "java.naming.provider.url#tcp://broker.${2}:61616";
String server3 = "hcat://xyz.corp.dummy.com=java.naming.factory.initial#Dummy.Factory;" + "java.naming.provider.url#tcp:localhost:61616";
String jmsConnectionURL = server2 + "," + server3;
conf.set(HCatAccessorService.JMS_CONNECTIONS_PROPERTIES, jmsConnectionURL);
services.init();
HCatAccessorService hcatService = services.get(HCatAccessorService.class);
// No default JMS mapping
JMSConnectionInfo connInfo = hcatService.getJMSConnectionInfo(new URI("http://unknown:9999/fs"));
assertNull(connInfo);
connInfo = hcatService.getJMSConnectionInfo(new URI("hcat://server1.colo1.server.com:8020/db/table/pk1=val1;pk2=val2"));
assertEquals("java.naming.factory.initial#Dummy.Factory;java.naming.provider.url#tcp://broker.colo1:61616", connInfo.getJNDIPropertiesString());
connInfo = hcatService.getJMSConnectionInfo(new URI("hcat://xyz.corp.dummy.com/db/table"));
assertEquals("java.naming.factory.initial#Dummy.Factory;java.naming.provider.url#tcp:localhost:61616", connInfo.getJNDIPropertiesString());
}
use of org.apache.oozie.jms.JMSConnectionInfo in project oozie by apache.
the class TestJMSAccessorService method testConnectionContext.
@Test
public void testConnectionContext() throws ServiceException {
try {
services.destroy();
services = super.setupServicesForHCatalog();
Configuration conf = services.getConf();
// set the connection factory name
String jmsURL = "hcat://${1}.${2}.server.com:8020=java.naming.factory.initial#" + "org.apache.activemq.jndi.ActiveMQInitialContextFactory" + ";java.naming.provider.url#vm://localhost?broker.persistent=false;" + "connectionFactoryNames#dynamicFactories/hcat.prod.${1}";
conf.set(HCatAccessorService.JMS_CONNECTIONS_PROPERTIES, jmsURL);
services.init();
HCatAccessorService hcatService = services.get(HCatAccessorService.class);
JMSConnectionInfo connInfo = hcatService.getJMSConnectionInfo(new URI("hcat://hcatserver.blue.server.com:8020"));
assertEquals("java.naming.factory.initial#org.apache.activemq.jndi.ActiveMQInitialContextFactory;java.naming.provider.url#" + "vm://localhost?broker.persistent=false;connectionFactoryNames#dynamicFactories/hcat.prod.hcatserver", connInfo.getJNDIPropertiesString());
ConnectionContext ctx1 = new DefaultConnectionContext();
ctx1.createConnection(connInfo.getJNDIProperties());
BrokerService broker = new BrokerService();
broker.setDataDirectory(getTestCaseDir());
// Without this stop testConnectionRetry fails with
// javax.management.InstanceAlreadyExistsException: org.apache.activemq:BrokerName=localhost,Type=Broker
broker.stop();
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception " + e);
}
}
Aggregations