Search in sources :

Example 31 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class ServiceDashboardEditor method loadServerVolumeData.

/**
	 * Load Server Volume Info
	 */
private void loadServerVolumeData(final ServerInfo serverInfo, final String key) {
    List<String> dbList = serverInfo.getAllDatabaseList();
    if (dbList == null || dbList.size() == 0) {
        return;
    }
    final List<CommonQueryTask<DbSpaceInfoList>> getVolumnTaskList = new ArrayList<CommonQueryTask<DbSpaceInfoList>>();
    for (String dbname : dbList) {
        CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
        task.setDbName(dbname);
        getVolumnTaskList.add(task);
    }
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            Object input = serviceTreeViewer.getInput();
            ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
            setVolumeData(sDashInfo, getVolumnTaskList);
            serviceTreeViewer.refresh(input);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    for (CommonQueryTask<DbSpaceInfoList> task : getVolumnTaskList) {
        taskJobExec.addTask(task);
    }
    executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerVolumeInfo);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) ArrayList(java.util.ArrayList) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 32 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class ServiceDashboardEditor method loadServerHostInfo.

/**
	 * Load Server Host Info
	 */
private void loadServerHostInfo(final ServerInfo serverInfo, final String key) {
    final CommonQueryTask<HostStatData> task = new CommonQueryTask<HostStatData>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new HostStatData());
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            Object input = serviceTreeViewer.getInput();
            ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
            HostStatData hostInfo = task.getResultModel();
            setHostData(sDashInfo, hostInfo);
            serviceTreeViewer.refresh(input);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    taskJobExec.addTask(task);
    executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerHostInfo);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) HostStatData(com.cubrid.cubridmanager.core.monitoring.model.HostStatData)

Example 33 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class CubridBrokerFolderLoader method checkBrokerExist.

/**
	 * 
	 * Check broker whether exist
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor
	 * @return <code>0</code> exist;<code>1</code> has error;<code>2</code>
	 *         canceled;<code>3</code> no exist;
	 */
private int checkBrokerExist(final ICubridNode parent, final IProgressMonitor monitor) {
    ServerInfo serverInfo = parent.getServer().getServerInfo();
    BrokerInfos brokerInfos = new BrokerInfos();
    final CommonQueryTask<BrokerInfos> getBrokersTask = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
    monitorCancel(monitor, new ITask[] { getBrokersTask });
    getBrokersTask.execute();
    final String msg = getBrokersTask.getErrorMsg();
    if (!monitor.isCanceled() && msg != null && msg.trim().length() > 0) {
        parent.removeAllChild();
        openErrorBox(msg);
        setLoaded(true);
        return 1;
    }
    if (monitor.isCanceled()) {
        setLoaded(true);
        return 2;
    }
    CubridBroker broker = (CubridBroker) parent;
    String brokerName = broker.getLabel();
    brokerInfos = getBrokersTask.getResultModel();
    boolean isExist = false;
    List<BrokerInfo> brokerInfoList = (brokerInfos == null || brokerInfos.getBorkerInfoList() == null) ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
    for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
        BrokerInfo brokerInfo = brokerInfoList.get(i);
        if (brokerInfo.getName().equalsIgnoreCase(brokerName)) {
            broker.setRunning(brokerInfo.getState() == null ? false : brokerInfo.getState().equalsIgnoreCase("ON"));
            isExist = true;
        }
    }
    return isExist ? 0 : 3;
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) CubridBroker(com.cubrid.cubridmanager.ui.spi.model.CubridBroker) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 34 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class CubridBrokersFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        ServerInfo serverInfo = parent.getServer().getServerInfo();
        ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
        if (userInfo == null || CasAuthType.AUTH_NONE == userInfo.getCasAuth()) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        BrokerInfos brokerInfos = new BrokerInfos();
        final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            Display display = Display.getDefault();
            display.syncExec(new Runnable() {

                public void run() {
                    CommonUITool.openErrorBox(errorMsg);
                }
            });
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        brokerInfos = task.getResultModel();
        List<ICubridNode> oldNodeList = parent.getChildren();
        parent.removeAllChild();
        List<BrokerInfo> brokerInfoList = (brokerInfos == null || brokerInfos.getBorkerInfoList() == null) ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
        for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
            BrokerInfo brokerInfo = brokerInfoList.get(i);
            String id = parent.getId() + NODE_SEPARATOR + brokerInfo.getName();
            ICubridNode brokerInfoNode = isContained(oldNodeList, id);
            if (brokerInfoNode == null) {
                brokerInfoNode = new CubridBroker(id, brokerInfo.getName(), "icons/navigator/broker.png");
                ((CubridBroker) brokerInfoNode).setStartedIconPath("icons/navigator/broker_started.png");
                brokerInfoNode.setType(CubridNodeType.BROKER);
                brokerInfoNode.setContainer(true);
                brokerInfoNode.setModelObj(brokerInfo);
                brokerInfoNode.setViewId(BrokerStatusView.ID);
                brokerInfoNode.setLoader(new CubridBrokerFolderLoader());
            } else {
                brokerInfoNode.setModelObj(brokerInfo);
                if (brokerInfoNode.getLoader() != null && brokerInfoNode.getLoader().isLoaded()) {
                    brokerInfoNode.getLoader().setLoaded(false);
                    brokerInfoNode.getChildren(monitor);
                }
            }
            parent.addChild(brokerInfoNode);
        }
        serverInfo.setBrokerInfos(brokerInfos);
        // For the Shard Broker Folder
        if (CompatibleUtil.isSupportShard(serverInfo)) {
            Shards shards = new Shards();
            GetShardConfTask<Shards> getShardConfTask = new GetShardConfTask<Shards>(serverInfo, shards);
            getShardConfTask.execute();
            // !"File(?) open error".equals(errorMsg.trim())) {
            if (getShardConfTask.isSuccess()) {
                GetShardStatusTask getShardStatusTask = new GetShardStatusTask(serverInfo, null);
                getShardStatusTask.execute();
                boolean runningShard = getShardStatusTask.isSuccess();
                serverInfo.setShards(shards);
                shards.setRunning(runningShard);
                String shardFolderId = parent.getId() + NODE_SEPARATOR + SHARD_FOLDER_ID;
                ICubridNode shardFolder = parent.getChild(shardFolderId);
                if (shardFolder == null) {
                    shardFolder = new CubridShardFolder(shardFolderId, SHARD_FOLDER_NAME);
                    ICubridNodeLoader loader = new CubridShardsFolderLoader((CubridShardFolder) shardFolder);
                    loader.setLevel(getLevel());
                    shardFolder.setLoader(loader);
                    parent.addChild(shardFolder);
                // shardFolder.getChildren(monitor);
                } else {
                    if (shardFolder.getLoader() != null && shardFolder.getLoader().isLoaded()) {
                        shardFolder.getLoader().setLoaded(false);
                        shardFolder.getChildren(monitor);
                    }
                }
            }
        }
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CubridBroker(com.cubrid.cubridmanager.ui.spi.model.CubridBroker) CubridShardFolder(com.cubrid.cubridmanager.ui.spi.model.CubridShardFolder) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) GetShardConfTask(com.cubrid.cubridmanager.core.shard.task.GetShardConfTask) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) Shards(com.cubrid.cubridmanager.core.shard.model.Shards) GetShardStatusTask(com.cubrid.cubridmanager.core.shard.task.GetShardStatusTask) Display(org.eclipse.swt.widgets.Display)

Example 35 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class CubridAdminLogFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        ServerInfo serverInfo = parent.getServer().getServerInfo();
        AdminLogInfoList logInfoList = new AdminLogInfoList();
        final CommonQueryTask<AdminLogInfoList> task = new CommonQueryTask<AdminLogInfoList>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), logInfoList);
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            openErrorBox(errorMsg);
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        parent.removeAllChild();
        logInfoList = task.getResultModel();
        if (logInfoList != null) {
            List<LogInfo> list = logInfoList.getAdminLogInfoList();
            if (list != null) {
                for (LogInfo logInfo : list) {
                    DefaultCubridNode logInfoNode = new DefaultCubridNode(parent.getId() + NODE_SEPARATOR + logInfo.getName(), logInfo.getName(), "icons/navigator/log_item.png");
                    logInfoNode.setType(CubridNodeType.LOGS_BROKER_ADMIN_LOG);
                    logInfoNode.setContainer(false);
                    logInfoNode.setEditorId(LogEditorPart.ID);
                    logInfoNode.setModelObj(logInfo);
                    parent.addChild(logInfoNode);
                }
            }
        }
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) AdminLogInfoList(com.cubrid.cubridmanager.core.logs.model.AdminLogInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Aggregations

CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)60 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)19 ITask (com.cubrid.common.core.task.ITask)14 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)12 IStatus (org.eclipse.core.runtime.IStatus)12 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)11 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)11 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)11 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)8 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)7 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)7 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)7 ArrayList (java.util.ArrayList)7 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)6 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)6 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)6 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)6 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)6 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)5 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)5