01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2002-2004 French National Institute For Research In Computer
04: * Science And Control (INRIA).
05: * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
06: * Copyright (C) 2006 Continuent, Inc.
07: * Contact: sequoia@continuent.org
08: *
09: * 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: */package org.continuent.sequoia.controller.virtualdatabase.protocol;
24:
25: import java.io.Serializable;
26: import java.sql.SQLException;
27: import java.util.LinkedList;
28:
29: import org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager;
30: import org.continuent.sequoia.controller.requests.AbstractWriteRequest;
31:
32: /**
33: * This class defines a CacheInvalidate
34: *
35: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
36: * @version 1.0
37: */
38: public class CacheInvalidate extends DistributedRequest {
39: private static final long serialVersionUID = -3697012973169118466L;
40:
41: /**
42: * Creates a new <code>CacheInvalidate</code> object
43: *
44: * @param request Write request that invalidates the cache
45: */
46: public CacheInvalidate(AbstractWriteRequest request) {
47: super (request);
48: }
49:
50: /**
51: * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedRequest#scheduleRequest(org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager)
52: */
53: public final Object scheduleRequest(DistributedRequestManager drm)
54: throws SQLException {
55: LinkedList totalOrderQueue = drm.getVirtualDatabase()
56: .getTotalOrderQueue();
57: synchronized (totalOrderQueue) {
58: totalOrderQueue.addLast(this );
59: }
60: return this ;
61: }
62:
63: /**
64: * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedRequest#executeScheduledRequest(org.continuent.sequoia.controller.requestmanager.distributed.DistributedRequestManager)
65: */
66: public final Serializable executeScheduledRequest(
67: DistributedRequestManager drm) throws SQLException {
68: // Notify cache if any
69: if (drm.getResultCache() != null) { // Update cache
70: drm.getResultCache().writeNotify(
71: (AbstractWriteRequest) request);
72: }
73: return null;
74: }
75:
76: }
|