KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > virtualdatabase > protocol > BackendStatus


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
6  * Copyright (C) 2006 Continuent, Inc.
7  * Contact: sequoia@continuent.org
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  * Initial developer(s): Emmanuel Cecchet.
22  * Contributor(s): ______________________.
23  */

24
25 package org.continuent.sequoia.controller.virtualdatabase.protocol;
26
27 import java.io.Serializable JavaDoc;
28 import java.util.List JavaDoc;
29
30 import org.continuent.hedera.common.Member;
31 import org.continuent.sequoia.common.jmx.management.BackendInfo;
32 import org.continuent.sequoia.controller.backend.DatabaseBackend;
33 import org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager;
34 import org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase;
35
36 /**
37  * Send the status of local backends to remote controllers.
38  *
39  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
40  * @version 1.0
41  */

42 public class BackendStatus extends DistributedVirtualDatabaseMessage
43 {
44   private static final long serialVersionUID = -537987250588460222L;
45
46   private List JavaDoc /* <BackendInfo> */backendList;
47   private long controllerId;
48
49   /**
50    * Build a new BackendStatus object
51    *
52    * @param backends a List&lt;BackendInfo&gt;
53    * @param controllerId the sending controller identifier
54    * @see org.continuent.sequoia.common.jmx.management.BackendInfo
55    */

56   public BackendStatus(List JavaDoc/* <BackendInfo> */backends, long controllerId)
57   {
58     backendList = backends;
59     this.controllerId = controllerId;
60   }
61
62   /**
63    * Get the list of backends info.
64    *
65    * @return a List&lt;BackendInfo&gt; of the remote controller BackendInfo
66    */

67   public List JavaDoc/* <BackendInfo> */getBackendInfos()
68   {
69     return backendList;
70   }
71
72   /**
73    * Returns the controllerId value.
74    *
75    * @return Returns the controllerId.
76    */

77   public final long getControllerId()
78   {
79     return controllerId;
80   }
81
82   /**
83    * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageSingleThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
84    * org.continuent.hedera.common.Member)
85    */

86   public Object JavaDoc handleMessageSingleThreaded(DistributedVirtualDatabase dvdb,
87       Member sender)
88   {
89     return null;
90   }
91
92   /**
93    * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageMultiThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
94    * org.continuent.hedera.common.Member, java.lang.Object)
95    */

96   public Serializable JavaDoc handleMessageMultiThreaded(
97       DistributedVirtualDatabase dvdb, Member sender,
98       Object JavaDoc handleMessageSingleThreadedResult)
99   {
100     // Update backend list from sender
101
List JavaDoc remoteBackends = BackendInfo.toDatabaseBackends(dvdb, backendList);
102     dvdb.addRemoteControllerId(sender, controllerId);
103     dvdb.addBackendPerController(sender, remoteBackends);
104     return new BackendStatus(
105         DatabaseBackend.toBackendInfos(dvdb.getBackends()),
106         ((DistributedRequestManager) dvdb.getRequestManager())
107             .getControllerId());
108   }
109
110 }
Popular Tags