Search in sources :

Example 26 with DatabaseInfo

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));
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 27 with DatabaseInfo

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;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ArrayList(java.util.ArrayList) GetShardConfTask(com.cubrid.cubridmanager.core.shard.task.GetShardConfTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) ShardNode(com.cubrid.cubridmanager.core.cubrid.service.model.ShardNode) ShardConnection(com.cubrid.cubridmanager.core.shard.model.ShardConnection) GetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask) Shards(com.cubrid.cubridmanager.core.shard.model.Shards) Shard(com.cubrid.cubridmanager.core.shard.model.Shard) Map(java.util.Map)

Example 28 with DatabaseInfo

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;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 29 with DatabaseInfo

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;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)

Example 30 with DatabaseInfo

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();
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Aggregations

DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)188 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)79 ArrayList (java.util.ArrayList)45 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)35 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)31 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)30 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)30 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)25 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)24 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)24 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)23 ITask (com.cubrid.common.core.task.ITask)20 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)18 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)18 Map (java.util.Map)15 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)14 HashMap (java.util.HashMap)14 Composite (org.eclipse.swt.widgets.Composite)14 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)13 GridLayout (org.eclipse.swt.layout.GridLayout)13