use of com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo in project cubrid-manager by CUBRID.
the class BrokerDashboardViewPart method performUpdate.
/**
* Perform update UI when data change event happen
*
* @param dataChangedEvent the instance of DataChangedEvent
*/
public void performUpdate(DataChangedEvent dataChangedEvent) {
if (composite == null || composite.isDisposed()) {
return;
}
if (dataChangedEvent != null) {
String brokerName = brokerNode.getBrokerName();
BrokerInfos brokerInfos = dataChangedEvent.getBrokerInfosMap().get(brokerName);
BrokerStatusInfos brokerStatusInfos = dataChangedEvent.getBrokerStatusInfosMap().get(brokerName);
BrokerDiagData brokerDiagData = dataChangedEvent.getBrokerDiagDataMap().get(brokerName);
List<String> basicTableLst = new ArrayList<String>();
if (brokerInfos == null) {
for (int i = 0; i < 10; i++) {
basicTableLst.add("");
}
} else {
BrokerInfoList brokerInfoList = brokerInfos.getBorkerInfoList();
if (brokerInfoList.getBrokerInfoList().isEmpty()) {
for (int i = 0; i < 10; i++) {
basicTableLst.add("");
}
}
for (BrokerInfo bi : brokerInfoList.getBrokerInfoList()) {
if (brokerName.equals(bi.getName())) {
basicTableLst.add(bi.getPid());
basicTableLst.add(bi.getPort());
basicTableLst.add(bi.getJq());
basicTableLst.add(bi.getAuto());
basicTableLst.add(bi.getSqll());
basicTableLst.add(bi.getLong_tran_time());
basicTableLst.add(bi.getLong_query_time());
basicTableLst.add(bi.getSes());
basicTableLst.add(bi.getKeep_conn());
basicTableLst.add(bi.getAccess_mode());
}
}
}
if (brokerDiagData == null) {
for (int i = 0; i < 3; i++) {
basicTableLst.add("");
}
} else {
basicTableLst.add(brokerDiagData.getCas_mon_active());
basicTableLst.add(brokerDiagData.getCas_mon_session());
basicTableLst.add(brokerDiagData.getCas_mon_tran());
}
//test
List<List<String>> basicColumnLst = new ArrayList<List<String>>();
basicColumnLst.add(basicTableLst);
basicTableViewer.setInput(basicColumnLst);
basicTableViewer.refresh();
List<ApplyServerInfo> asinfoLst = null;
List<JobInfo> jobinfoLst = null;
if (brokerStatusInfos == null) {
asinfoLst = new ArrayList<ApplyServerInfo>();
jobinfoLst = new ArrayList<JobInfo>();
} else {
asinfoLst = brokerStatusInfos.getAsinfo();
jobinfoLst = brokerStatusInfos.getJobinfo();
if (asinfoLst == null) {
asinfoLst = new ArrayList<ApplyServerInfo>();
}
if (jobinfoLst == null) {
jobinfoLst = new ArrayList<JobInfo>();
}
}
asTableViewer.setInput(asinfoLst);
asTableViewer.refresh();
jqTableViewer.setInput(jobinfoLst);
jqTableViewer.refresh();
}
}
use of com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo in project cubrid-manager by CUBRID.
the class BrokerStatusView method createAsTable.
/**
* Create app server table
*
* @param comp the parent composite
*
*/
private void createAsTable(Composite comp) {
Composite asComposite = new Composite(comp, SWT.NONE);
GridData gdAs = new GridData(SWT.FILL, SWT.FILL, true, true);
asComposite.setLayoutData(gdAs);
asComposite.setLayout(new GridLayout());
asTableViewer = new TableViewer(asComposite, SWT.FULL_SELECTION | SWT.NO_SCROLL | SWT.V_SCROLL | SWT.BORDER);
Table asTable = asTableViewer.getTable();
asTable.setHeaderVisible(true);
asTable.setLinesVisible(true);
asTable.setLayoutData(gdAs);
TableLayout asLayout = new TableLayout();
setAsLayout(asLayout);
asTable.setLayout(asLayout);
TableColumn tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsId);
tblColumn.setToolTipText(Messages.tblAsId);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsProcess);
tblColumn.setToolTipText(Messages.tblAsProcess);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsQps);
tblColumn.setToolTipText(Messages.tblAsQps);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsLqs);
tblColumn.setToolTipText(Messages.tblAsLqs);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsPort);
tblColumn.setToolTipText(Messages.tblAsPort);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsSize);
tblColumn.setToolTipText(Messages.tblAsSize);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsStatus);
tblColumn.setToolTipText(Messages.tblAsStatus);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsDb);
tblColumn.setToolTipText(Messages.tblAsDb);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsHost);
tblColumn.setToolTipText(Messages.tblAsHost);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsLastAccess);
tblColumn.setToolTipText(Messages.tblAsLastAccess);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsLct);
tblColumn.setToolTipText(Messages.tblAsLct);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsClientIp);
tblColumn.setToolTipText(Messages.tblAsClientIp);
tblColumn = new TableColumn(asTable, SWT.CENTER);
tblColumn.setText(Messages.tblAsCur);
tblColumn.setToolTipText(Messages.tblAsCur);
asTableViewer.setContentProvider(new ApplyServerContentProvider());
asTableViewer.setLabelProvider(new ApplyServerLabelProvider());
asTableViewer.setInput(asinfoLst);
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
IStructuredSelection selection = (IStructuredSelection) asTableViewer.getSelection();
ApplyServerInfo as = (ApplyServerInfo) (selection.toArray()[0]);
RestartAction restartAcion = new RestartAction(as.getAs_id());
manager.add(restartAcion);
}
});
Menu contextMenu = menuManager.createContextMenu(asTableViewer.getControl());
asTableViewer.getControl().setMenu(contextMenu);
}
use of com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo in project cubrid-manager by CUBRID.
the class BrokerNode method getAccessedHostDbMap.
/*public Set<String> getDbSet(){
Set<String> dbSet = new HashSet<String>();
for(BrokerStatusInfos bStatusInfos : brokerStatusMap.values()){
List<ApplyServerInfo> asInfoList = bStatusInfos.getAsinfo();
if(asInfoList == null){
continue;
}
for(ApplyServerInfo asInfo : asInfoList){
String dbHost = asInfo.getAs_dbhost();
String dbName = asInfo.getAs_dbname();
if(!StringUtil.isEmpty(dbName) && !isLocalHost(dbHost)){
dbSet.add(dbName);
}
}
}
return dbSet;
}*/
public Map<List<String>, Set<String>> getAccessedHostDbMap() {
List<DbLocationInfo> dbLocationInfoList = getDbLocationInfoList();
if (brokerStatusMap == null || brokerStatusMap.isEmpty() || dbLocationInfoList == null || dbLocationInfoList.isEmpty()) {
return null;
}
Map<List<String>, Set<String>> accessedHostDbMap = new HashMap<List<String>, Set<String>>();
for (BrokerStatusInfos bStatusInfos : brokerStatusMap.values()) {
List<ApplyServerInfo> asInfoList = bStatusInfos.getAsinfo();
if (asInfoList == null) {
continue;
}
for (ApplyServerInfo asInfo : asInfoList) {
String dbHost = asInfo.getAs_dbhost();
String dbName = asInfo.getAs_dbname();
if (StringUtil.isEmpty(dbName) || StringUtil.isEmpty(dbHost)) {
continue;
}
List<String> hostList = null;
if (CMServiceAnalysisUtil.isLocalHost(dbHost)) {
hostList = new ArrayList<String>();
hostList.add(BrokerNode.LOCALHOST);
} else {
for (DbLocationInfo dbLocalInfo : dbLocationInfoList) {
if (dbName.equals(dbLocalInfo.getDbName())) {
if (dbLocalInfo.findHost(dbHost)) {
hostList = dbLocalInfo.getDbHosts();
}
}
}
}
Set<String> dbSet = accessedHostDbMap.get(hostList);
if (dbSet != null) {
dbSet.add(dbName);
} else {
dbSet = new HashSet<String>();
dbSet.add(dbName);
accessedHostDbMap.put(hostList, dbSet);
}
}
}
return accessedHostDbMap;
}
use of com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo in project cubrid-manager by CUBRID.
the class BrokerNode method getAccessedHosts.
public Set<String> getAccessedHosts() {
if (brokerStatusMap == null || brokerStatusMap.isEmpty()) {
return null;
}
Set<String> accessedHosts = new HashSet<String>();
for (BrokerStatusInfos bStatusInfos : brokerStatusMap.values()) {
List<ApplyServerInfo> asInfoList = bStatusInfos.getAsinfo();
if (asInfoList == null) {
continue;
}
for (ApplyServerInfo asInfo : asInfoList) {
String dbHost = asInfo.getAs_dbhost();
if (StringUtil.isEmpty(dbHost) || CMServiceAnalysisUtil.isLocalHost(dbHost)) {
continue;
}
accessedHosts.add(dbHost);
}
}
return accessedHosts;
}
use of com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo in project cubrid-manager by CUBRID.
the class DashboardConnectionManager method refreshBroker2DBConnections.
/**
* Refresh Broker to DB Connections
*
*/
public void refreshBroker2DBConnections() {
List<BrokerNode> allBrokerNode = dashboard.getAllBrokerNode();
for (BrokerNode broker : allBrokerNode) {
//create broker to db connections
BrokerStatusInfos brokerStatusInfos = broker.getBrokerStatusInfos();
List<DatabaseNode> dbList2Connect = new ArrayList<DatabaseNode>();
if (null != brokerStatusInfos && null != brokerStatusInfos.getAsinfo() && !brokerStatusInfos.getAsinfo().isEmpty()) {
List<ApplyServerInfo> asList = brokerStatusInfos.getAsinfo();
for (ApplyServerInfo asi : asList) {
if ("IDLE".equals(asi.getAs_status())) {
continue;
}
HostNode hostNode = dashboard.getHostNodeByName(asi.getAs_dbhost());
if (hostNode == null) {
continue;
}
String asDbname = asi.getAs_dbname();
if (StringUtil.isNotEmpty(asDbname)) {
asDbname = asDbname.replaceAll("@.*", "");
}
DatabaseNode dbNode = hostNode.getDBNodeByName(asDbname);
if (dbNode == null) {
continue;
}
dbList2Connect.add(dbNode);
}
}
//remove old connections
broker.removeConnectionsTargetNotInList(dbList2Connect, DatabaseNode.class);
//create new connections
for (DatabaseNode db2Conn : dbList2Connect) {
if (!broker.targetExists(db2Conn)) {
new BrokerConnection(broker, db2Conn);
}
}
}
List<DatabaseNode> allDatabaseNode = dashboard.getAllDatabaseNode();
for (DatabaseNode dbNode : allDatabaseNode) {
dbNode.removeConnectionsSourceNotInList(allBrokerNode, BrokerNode.class);
}
}
Aggregations