001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2002-2004 French National Institute For Research In Computer
004: * Science And Control (INRIA).
005: * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
006: * Copyright (C) 2006 Continuent, Inc.
007: * Contact: sequoia@continuent.org
008: *
009: * Licensed under the Apache License, Version 2.0 (the "License");
010: * you may not use this file except in compliance with the License.
011: * You may obtain a copy of the License at
012: *
013: * http://www.apache.org/licenses/LICENSE-2.0
014: *
015: * Unless required by applicable law or agreed to in writing, software
016: * distributed under the License is distributed on an "AS IS" BASIS,
017: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018: * See the License for the specific language governing permissions and
019: * limitations under the License.
020: *
021: * Initial developer(s): Emmanuel Cecchet.
022: * Contributor(s): ______________________.
023: */package org.continuent.sequoia.controller.virtualdatabase.protocol;
024:
025: import java.io.Serializable;
026: import java.util.List;
027:
028: import org.continuent.hedera.common.Member;
029: import org.continuent.sequoia.common.jmx.management.BackendInfo;
030: import org.continuent.sequoia.controller.backend.DatabaseBackend;
031: import org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager;
032: import org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase;
033:
034: /**
035: * Send the status of local backends to remote controllers.
036: *
037: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
038: * @version 1.0
039: */
040: public class BackendStatus extends DistributedVirtualDatabaseMessage {
041: private static final long serialVersionUID = -537987250588460222L;
042:
043: private List /* <BackendInfo> */backendList;
044: private long controllerId;
045:
046: /**
047: * Build a new BackendStatus object
048: *
049: * @param backends a List<BackendInfo>
050: * @param controllerId the sending controller identifier
051: * @see org.continuent.sequoia.common.jmx.management.BackendInfo
052: */
053: public BackendStatus(List/* <BackendInfo> */backends,
054: long controllerId) {
055: backendList = backends;
056: this .controllerId = controllerId;
057: }
058:
059: /**
060: * Get the list of backends info.
061: *
062: * @return a List<BackendInfo> of the remote controller BackendInfo
063: */
064: public List/* <BackendInfo> */getBackendInfos() {
065: return backendList;
066: }
067:
068: /**
069: * Returns the controllerId value.
070: *
071: * @return Returns the controllerId.
072: */
073: public final long getControllerId() {
074: return controllerId;
075: }
076:
077: /**
078: * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageSingleThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
079: * org.continuent.hedera.common.Member)
080: */
081: public Object handleMessageSingleThreaded(
082: DistributedVirtualDatabase dvdb, Member sender) {
083: return null;
084: }
085:
086: /**
087: * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageMultiThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
088: * org.continuent.hedera.common.Member, java.lang.Object)
089: */
090: public Serializable handleMessageMultiThreaded(
091: DistributedVirtualDatabase dvdb, Member sender,
092: Object handleMessageSingleThreadedResult) {
093: // Update backend list from sender
094: List remoteBackends = BackendInfo
095: .toDatabaseBackends(backendList);
096: dvdb.addRemoteControllerId(sender, controllerId);
097: dvdb.addBackendPerController(sender, remoteBackends);
098: return new BackendStatus(DatabaseBackend.toBackendInfos(dvdb
099: .getBackends()), ((DistributedRequestManager) dvdb
100: .getRequestManager()).getControllerId());
101: }
102:
103: }
|