use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class JDBCConnectionManagerTest method testShardBroker.
public void testShardBroker() {
assertTrue(JDBCConnectionManager.testShardBroker(databaseInfo, 1));
assertFalse(JDBCConnectionManager.testShardBroker(new DatabaseInfo("", new ServerInfo()), 1));
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class HaShardDemo method getShardNodeIndo92.
protected NodeInfo getShardNodeIndo92(ServerInfo serverInfo) {
ShardNode info = null;
GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(serverInfo);
getBrokerConfParameterTask.execute();
if (!getBrokerConfParameterTask.isSuccess()) {
return null;
}
Shards shards = new Shards();
Map<String, Map<String, String>> confParams = getBrokerConfParameterTask.getConfParameters();
List<Map<String, String>> shardParamsList = new ArrayList<Map<String, String>>();
for (Entry<String, Map<String, String>> entry : confParams.entrySet()) {
String brokerName = entry.getKey();
Map<String, String> params = entry.getValue();
if (StringUtils.equalsIgnoreCase(params.get("SHARD"), "ON")) {
shardParamsList.add(params);
Shard shard = new Shard();
shard.setName(brokerName.toLowerCase(Locale.getDefault()));
shard.setProperties(params);
ShardConnection shardConnection = new ShardConnection();
shard.setShardConnectionFile(shardConnection);
GetShardConfTask<ShardConnection> getShardConnectionConfTask = new GetShardConfTask<ShardConnection>(serverInfo, shardConnection);
getShardConnectionConfTask.execute();
getShardConnectionConfTask.loadDataToModel();
shard.setShardConnectionFile(shardConnection);
shards.addShard(shard);
}
}
if (shardParamsList.size() == 0) {
return null;
}
info = new ShardNode();
for (Map<String, String> params : shardParamsList) {
String shardDbName = params.get("SHARD_DB_NAME");
info.addDatabase(shardDbName);
}
GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
getDatabaseListTask.execute();
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
int shardDbCnt = info.getDatabases().size();
int matchedCnt = 0;
for (DatabaseInfo dbInfo : databaseInfoList) {
for (String dbName : info.getDatabases()) {
if (dbInfo.getDbName().equals(dbName)) {
if (DbRunningType.CS.equals(dbInfo.getRunningType())) {
info.setDbStatus(dbName, "ON");
} else {
info.setDbStatus(dbName, "OFF");
}
matchedCnt++;
if (shardDbCnt <= matchedCnt) {
break;
} else {
continue;
}
}
}
}
info.setShards(shards);
return info;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CMDatabaseNavigatorMenu method getDatabaseLabel.
/**
* return a text of selected database on the query editor
*
* @param database
* @return
*/
public String getDatabaseLabel(CubridDatabase cubridDatabase) {
DatabaseInfo dbInfo = cubridDatabase.getDatabaseInfo();
ServerInfo svrInfo = null;
String text = "";
if (dbInfo != null) {
text = dbInfo.getDbName();
svrInfo = dbInfo.getServerInfo();
}
String userName = cubridDatabase.getUserName();
if (userName != null && userName.trim().length() > 0) {
text = userName + "@" + text;
}
if (svrInfo != null) {
String hostName = svrInfo.getServerName();
text = text + ":" + hostName;
}
return text;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CopyDatabaseDialog method verify.
/**
*
* Verify data
*
* @return <code>true</code> if valid;<code>false</code> otherwise
*/
private boolean verify() {
String tmp = destinationDBNameText.getText();
if (tmp == null || tmp.equals("")) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errInputTargetDb);
return false;
}
tmp = destinationDBLogPathText.getText();
if (tmp == null || tmp.equals("")) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errInputLogDirectory);
return false;
}
/*
* verify overwrite database
*/
List<DatabaseInfo> list = database.getServer().getServerInfo().getLoginedUserInfo().getDatabaseInfoList();
String dbName = destinationDBNameText.getText();
boolean dbExistFlag = false;
for (DatabaseInfo d : list) {
if (dbName.equals(d.getDbName())) {
dbExistFlag = true;
break;
}
}
if (overwriteButton.getSelection()) {
if (dbExistFlag && !CommonUITool.openConfirmBox(parentComp.getShell(), Messages.warnYesNoOverWrite)) {
return false;
}
} else {
if (dbExistFlag) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errDesitinationDbExist);
return false;
}
}
/**
* verify free space
*/
if (dbSize / (1024.0 * 1024.0) > dbSpaceInfo.getFreespace()) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errNotEnoughSpace);
return false;
}
if (dbSize / (1024.0 * 1024.0) * 1.1 > dbSpaceInfo.getFreespace() && !CommonUITool.openConfirmBox(parentComp.getShell(), Messages.warnYesNoCopyDbSpaceOver)) {
return false;
}
return true;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class LoginDatabaseDialog method saveBrokerInfo.
private void saveBrokerInfo() {
DatabaseInfo databaseInfo = database.getDatabaseInfo();
String charset = charsetCombo.getText();
QueryOptions.setCharset(databaseInfo, charset);
String brokerPort = "";
if (database != null) {
String text = brokerPortCombo.getText();
BrokerInfo brokerInfo = null;
if (brokerPortCombo.getData(text) instanceof BrokerInfo) {
brokerInfo = (BrokerInfo) brokerPortCombo.getData(text);
}
if (brokerInfo != null) {
brokerPort = brokerInfo.getPort();
} else {
brokerPort = getBrokerPort();
}
}
if (brokerPort != null) {
QueryOptions.setBrokerPort(databaseInfo, brokerPort);
}
QueryOptions.setBrokerIp(databaseInfo, brokerIpText.getText());
QueryOptions.savePref();
}
Aggregations