use of org.talend.repository.nosql.exceptions.NoSQLServerException in project tbd-studio-se by Talend.
the class Neo4jConnectionUtilTest method testLocalConnection.
// TODO: FIXME
@Ignore("failed because workbench has not been created")
public void testLocalConnection() throws Exception {
EMap<String, String> attributes = localConnection.getAttributes();
// $NON-NLS-1$
attributes.put(INeo4jAttributes.REMOTE_SERVER, "false");
attributes.put(INeo4jAttributes.DATABASE_PATH, tmpFolder.getCanonicalPath());
attributes.put(INeo4jAttributes.DB_VERSION, INeo4jConstants.NEO4J_3_2_X);
localConnection.setDbType("NEO4J");
// TUP-15696:"Check Service" for Neo4j does not work after first check.
// so check twice here
ExecutorService threadExecutor = null;
try {
threadExecutor = Executors.newSingleThreadExecutor();
Future future = threadExecutor.submit(new Runnable() {
public void run() {
try {
Neo4jConnectionUtil.checkConnection(localConnection);
assertTrue(Neo4jConnectionUtil.checkConnection(localConnection));
} catch (NoSQLServerException e) {
fail(e.getMessage());
}
}
});
while (true) {
if (future.get() == null) {
break;
}
Thread.sleep(1000);
}
} catch (Exception exception) {
fail(exception.getMessage());
} finally {
if (threadExecutor != null) {
threadExecutor.shutdown();
}
}
}
use of org.talend.repository.nosql.exceptions.NoSQLServerException in project tbd-studio-se by Talend.
the class CassandraMetadataHandler method getKeySpaceNames.
@Override
public List<String> getKeySpaceNames(NoSQLConnection connection) throws NoSQLServerException {
List<String> ksNames = new ArrayList<String>();
initCluster(connection);
try {
List<Object> keySpaces = getKeySpaces(connection);
for (Object keySpace : keySpaces) {
// $NON-NLS-1$
String ksName = (String) NoSQLReflection.invokeMethod(keySpace, "getName");
ksNames.add(ksName);
}
} catch (Exception e) {
throw new NoSQLServerException(e);
}
return ksNames;
}
use of org.talend.repository.nosql.exceptions.NoSQLServerException in project tbd-studio-se by Talend.
the class CassandraMetadataHandler method getColumns.
@Override
public List<Object> getColumns(NoSQLConnection connection, String ksName, String cfName) throws NoSQLServerException {
List<Object> columns = new ArrayList<Object>();
try {
Object keySpace = getKeySpace(connection, ksName);
if (keySpace == null) {
return columns;
}
// $NON-NLS-1$
Collection<Object> tables = (Collection) NoSQLReflection.invokeMethod(keySpace, "getTables");
for (Object table : tables) {
// $NON-NLS-1$
String name = (String) NoSQLReflection.invokeMethod(table, "getName");
if (name != null && cfName.equals(name)) {
// $NON-NLS-1$
columns.addAll((List) NoSQLReflection.invokeMethod(table, "getColumns"));
break;
}
}
} catch (Exception e) {
throw new NoSQLServerException(e);
}
return columns;
}
use of org.talend.repository.nosql.exceptions.NoSQLServerException in project tbd-studio-se by Talend.
the class CassandraMetadataHandler method checkConnection.
@Override
public boolean checkConnection(NoSQLConnection connection) throws NoSQLServerException {
Object session = null;
try {
cluster = null;
initCluster(connection);
ContextType contextType = null;
String ksName = connection.getAttributes().get(ICassandraAttributies.DATABASE);
if (connection.isContextMode()) {
contextType = ConnectionContextHelper.getContextTypeForContextMode(connection);
}
if (contextType != null) {
ksName = ContextParameterUtils.getOriginalValue(contextType, ksName);
}
// if cancel to interrupt check connection, throw exception
if (Thread.currentThread().interrupted()) {
// $NON-NLS-1$
throw new InterruptedException();
}
if (StringUtils.isEmpty(ksName)) {
// $NON-NLS-1$
session = NoSQLReflection.invokeMethod(cluster, "connect");
} else {
// $NON-NLS-1$
session = NoSQLReflection.invokeMethod(cluster, "connect", new Object[] { ksName });
}
return true;
} catch (Exception e) {
if (e instanceof InterruptedException) {
// $NON-NLS-1$
throw new NoSQLServerException(Messages.getString("noSQLConnectionTest.cancelCheckConnection"), e);
} else {
throw new NoSQLServerException(e);
}
} finally {
try {
if (session != null) {
// $NON-NLS-1$
NoSQLReflection.invokeMethod(session, "close");
}
} catch (NoSQLReflectionException e) {
// only for debug
e.printStackTrace();
}
}
}
use of org.talend.repository.nosql.exceptions.NoSQLServerException in project tbd-studio-se by Talend.
the class CassandraMetadataHandler method closeConnections.
@Override
public void closeConnections() throws NoSQLServerException {
try {
if (cluster != null) {
// $NON-NLS-1$
NoSQLReflection.invokeMethod(cluster, "close");
cluster = null;
}
} catch (NoSQLReflectionException e) {
throw new NoSQLServerException(e);
}
}
Aggregations