use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class ConnectionManager method connectHostInJob.
/**
*
* Connect Host
*
* @param hostNode The HostNode
* @param isConnectChild The boolean
* @param isPing The boolean
*/
public static void connectHostInJob(HostNode hostNode, boolean isConnectChild, boolean isPing) {
if (hostNode.isConnected() || hostNode.isConnecting()) {
return;
}
ServerInfo serverInfo = hostNode.getServerInfo();
if (serverInfo == null) {
serverInfo = new ServerInfo();
serverInfo.setServerName(hostNode.getIp());
serverInfo.setHostAddress(hostNode.getIp());
serverInfo.setHostMonPort(Integer.parseInt(hostNode.getPort()));
serverInfo.setHostJSPort(Integer.parseInt(hostNode.getPort()) + 1);
serverInfo.setUserName(hostNode.getUserName());
serverInfo.setUserPassword(hostNode.getPassword());
serverInfo.setJdbcDriverVersion(ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION);
}
TaskJob job = new TaskJob(Messages.bind(Messages.jobConnectHost, serverInfo.getHostAddress()));
hostNode.setConnecting(true);
ConnectHostJobExecutor executor = new ConnectHostJobExecutor(hostNode, serverInfo, isPing);
job.addTaskJobExecutor(executor);
if (isConnectChild) {
List<DatabaseNode> dbNodeList = hostNode.getDbNodeList();
for (DatabaseNode dbNode : dbNodeList) {
if (dbNode.isConnecting() || dbNode.isConnected()) {
continue;
}
dbNode.setConnecting(true);
ConnectDatabaseNodeJobExecutor dbJobExecutor = new ConnectDatabaseNodeJobExecutor(dbNode, serverInfo);
job.addTaskJobExecutor(dbJobExecutor);
}
}
JobFamily jobFamily = new JobFamily();
jobFamily.setServerName(serverInfo.getServerName());
jobFamily.setDbName(JobFamily.ALL_DB);
job.setJobFamily(jobFamily);
job.setPriority(Job.SHORT);
job.setUser(false);
job.schedule();
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class DataProvider method executeInThread.
/**
*
* Execute task by multi-thread
*
* @throws InterruptedException the exception
*/
public void executeInThread() throws InterruptedException {
//multi thread execution
List<Runnable> runnableList = new ArrayList<Runnable>();
if (isExecuteHostStatTask) {
hostStatTask = new CommonQueryTask<HostStatData>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new HostStatData());
hostStatTask.setTimeout(TIME_OUT_MILL);
runnableList.add(hostStatTask);
}
if (isExecuteBrokerStatTask) {
brokerDiagTask = new CommonQueryTask<BrokerDiagData>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), new BrokerDiagData());
brokerDiagTask.setTimeout(TIME_OUT_MILL);
runnableList.add(brokerDiagTask);
}
List<String> dbList = new ArrayList<String>();
for (DatabaseNode dbNode : uniqueDbNodeList) {
dbList.add(dbNode.getDbName());
}
if (isExecuteHeartbeatTask) {
getHeartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
getHeartbeatNodeInfoTask.setAllDb(false);
getHeartbeatNodeInfoTask.setDbList(dbList);
getHeartbeatNodeInfoTask.setTimeout(TIME_OUT_MILL);
runnableList.add(getHeartbeatNodeInfoTask);
}
if (isExecuteDbModeTask) {
getDbModeTask = new GetDbModeTask(serverInfo);
getDbModeTask.setDbList(dbList);
getDbModeTask.setTimeout(TIME_OUT_MILL);
runnableList.add(getDbModeTask);
}
//execute broker related task
if (!uniqueBrokerNodeList.isEmpty()) {
runnableList.addAll(brokerDataProvider.getExecRunnableList());
}
if (IS_MULTI_THREAD && !runnableList.isEmpty()) {
try {
generator.getThreadPoolManager().execute(runnableList, true);
} catch (ThreadCountOutOfBoundsException e) {
LOGGER.error("", e);
}
join(runnableList, 350);
runnableList.clear();
}
//get database status information
List<HADatabaseStatusInfo> dbStatusInfoList = null;
if (isExecuteDbModeTask) {
dbStatusInfoList = getDbModeTask.getDbModes();
}
//execute database related task
for (int i = 0; i < dbDataProviderList.size(); i++) {
DatabaseNode dbNode = dbDataProviderList.get(i).getDatabaseNode();
HADatabaseStatusInfo dbStatusInfo = HAUtil.getDatabaseStatusInfo(dbStatusInfoList, dbNode.getDbName());
dbDataProviderList.get(i).setDbStatusInfo(dbStatusInfo);
runnableList.addAll(dbDataProviderList.get(i).getExecRunnableList());
}
if (IS_MULTI_THREAD && !runnableList.isEmpty()) {
try {
generator.getThreadPoolManager().execute(runnableList, true);
} catch (ThreadCountOutOfBoundsException e) {
LOGGER.error("", e);
}
join(runnableList, 20);
} else {
execute(runnableList);
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class DataProvider method filterDatabaseDataProvider.
/**
*
* Filter the database provider
*
*/
private void filterDatabaseDataProvider() {
//delete the unused DatabaseDataProvider
List<DatabaseDataProvider> providerList = new ArrayList<DatabaseDataProvider>();
providerList.addAll(dbDataProviderList);
for (DatabaseDataProvider dbDataProvider : providerList) {
DatabaseNode node = dbDataProvider.getDatabaseNode();
boolean isNodeExist = false;
for (DatabaseNode dbNode : uniqueDbNodeList) {
if (node.equals(dbNode)) {
isNodeExist = true;
break;
}
}
if (!isNodeExist) {
dbDataProviderList.remove(dbDataProvider);
}
}
//add the DatabaseDataProvider
for (DatabaseNode dbNode : uniqueDbNodeList) {
boolean isHaveProvider = false;
for (DatabaseDataProvider dbDataProvider : dbDataProviderList) {
DatabaseNode databaseNode = dbDataProvider.getDatabaseNode();
if (dbNode.equals(databaseNode)) {
isHaveProvider = true;
break;
}
}
if (!isHaveProvider) {
IDataProvider dbDataProvider = new DatabaseDataProvider(dbNode);
dbDataProvider.setDataGenerator(generator);
dbDataProviderList.add((DatabaseDataProvider) dbDataProvider);
}
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class DataGenerator method removeDataUpdateListener.
/**
*
* remove a instance of DataUpdateListener to make it can be update
*
* @param listener an instance of DataUpdateListener
*/
public void removeDataUpdateListener(DataUpdateListener listener) {
synchronized (listeners) {
listeners.remove(listener);
if (listeners.isEmpty()) {
setRunflag(false);
HostNode hostNode = null;
if (listener.getModel() instanceof HostNode) {
hostNode = (HostNode) listener.getModel();
} else if (listener.getModel() instanceof DatabaseNode) {
hostNode = ((DatabaseNode) listener.getModel()).getParent();
} else if (listener.getModel() instanceof BrokerNode) {
hostNode = ((BrokerNode) listener.getModel()).getParent();
}
if (hostNode != null) {
hostNode.setConnecting(false);
}
getThreadPoolManager().disposeAll();
DataGeneratorPool pool = DataGeneratorPool.getInstance();
pool.removeDataGenerator(getName());
}
}
}
use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode in project cubrid-manager by CUBRID.
the class BrokerDBListMonitorPart method refreshVisuals.
/**
* Refreshes this EditPart's <i>visuals</i>. This method is called by
* {@link #refresh()}, and may also be called in response to notifications
* from the model.
*/
protected void refreshVisuals() {
BrokerDBListFigure figure = (BrokerDBListFigure) this.getFigure();
BrokerDBListNode dn = (BrokerDBListNode) this.getModel();
figure.setName(dn.getName());
//Remove defined dabatases.
List<String> dbList = new ArrayList<String>();
dbList.addAll(dn.getDbList());
Dashboard dashboard = (Dashboard) getParent().getModel();
for (DatabaseNode dbNode : dashboard.getAllDatabaseNode()) {
String dbName = dbNode.getDbName() + "@" + dbNode.getParent().getIp();
if (dn.getDbList().contains(dbName)) {
dbList.remove(dbName);
}
}
figure.setDBList(dbList);
BrokerNode broker = dn.getBrokerNode();
figure.setHostConnected(broker.getParent().isConnected());
super.refreshVisuals();
}
Aggregations