use of org.apache.airavata.sharing.registry.models.SharingRegistryException in project airavata by apache.
the class JPAUtils method initializeDB.
public static void initializeDB() throws SharingRegistryException {
jdbcDriver = readServerProperties(SHARING_REG_JDBC_DRIVER);
jdbcURl = readServerProperties(SHARING_REG_JDBC_URL);
jdbcUser = readServerProperties(SHARING_REG_JDBC_USER);
jdbcPassword = readServerProperties(SHARING_REG_JDBC_PWD);
jdbcURl = jdbcURl + "?" + "user=" + jdbcUser + "&" + "password=" + jdbcPassword;
if (getDBType(jdbcURl).equals("derby") && isDerbyStartEnabled()) {
startDerbyInServerMode();
}
db = new JdbcStorage(10, 50, jdbcURl, jdbcDriver, true);
Connection conn = null;
try {
conn = db.connect();
if (!DatabaseCreator.isDatabaseStructureCreated(CONFIGURATION, conn)) {
DatabaseCreator.createRegistryDatabase("database_scripts/sharing-registry", conn);
logger.info("New Database created for Sharing Catalog !!! ");
} else {
logger.info("Database already created for Sharing Catalog !!!");
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new RuntimeException("Database failure", e);
} finally {
db.closeConnection(conn);
try {
if (conn != null) {
if (!conn.getAutoCommit()) {
conn.commit();
}
conn.close();
}
} catch (SQLException e) {
logger.error("Error while closing database connection...", e.getMessage(), e);
}
}
}
use of org.apache.airavata.sharing.registry.models.SharingRegistryException in project airavata by apache.
the class SharingRegistryServer method start.
@Override
public void start() throws Exception {
try {
setStatus(IServer.ServerStatus.STARTING);
final int serverPort = Integer.parseInt(ServerSettings.getSetting(SHARING_REG_SERVER_PORT));
final String serverHost = ServerSettings.getSetting(SHARING_REG_SERVER_HOST);
SharingRegistryService.Processor processor = new SharingRegistryService.Processor(new SharingRegistryServerHandler());
TServerTransport serverTransport;
if (serverHost == null) {
serverTransport = new TServerSocket(serverPort);
} else {
InetSocketAddress inetSocketAddress = new InetSocketAddress(serverHost, serverPort);
serverTransport = new TServerSocket(inetSocketAddress);
}
TThreadPoolServer.Args options = new TThreadPoolServer.Args(serverTransport);
options.minWorkerThreads = 30;
server = new TThreadPoolServer(options.processor(processor));
new Thread() {
public void run() {
server.serve();
setStatus(IServer.ServerStatus.STOPPED);
logger.info("Sharing Registry Server Stopped.");
}
}.start();
new Thread() {
public void run() {
while (!server.isServing()) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
break;
}
}
if (server.isServing()) {
try {
logger.info("Register sharing service with DB Event publishers");
SharingServiceDBEventMessagingFactory.registerSharingServiceWithPublishers(Constants.PUBLISHERS);
logger.info("Start sharing service DB Event subscriber");
SharingServiceDBEventMessagingFactory.getDBEventSubscriber();
} catch (AiravataException | SharingRegistryException e) {
logger.error("Error starting sharing service. Error setting up DB event services.");
server.stop();
}
setStatus(IServer.ServerStatus.STARTED);
logger.info("Starting Sharing Registry Server on Port " + serverPort);
logger.info("Listening to Sharing Registry server clients ....");
}
}
}.start();
} catch (TTransportException e) {
setStatus(IServer.ServerStatus.FAILED);
throw new Exception("Error while starting the Sharing Registry service", e);
}
}
use of org.apache.airavata.sharing.registry.models.SharingRegistryException in project airavata by apache.
the class SharingRegistryServiceClientFactory method createSharingRegistryClient.
public static SharingRegistryService.Client createSharingRegistryClient(String serverHost, int serverPort) throws SharingRegistryException {
try {
TSocket e = new TSocket(serverHost, serverPort);
e.open();
TBinaryProtocol protocol = new TBinaryProtocol(e);
return new SharingRegistryService.Client(protocol);
} catch (TTransportException var4) {
logger.error("failed to create sharing registry client", var4);
throw new SharingRegistryException();
}
}
Aggregations