summaryrefslogtreecommitdiffstats
path: root/sandbox/axis2-1.4/demos/workpool-distributed/src/main/java/workpool/WorkpoolService.java
blob: d84ae549d854a6223ca476b76d1b8482bea08d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.    
 */
package workpool;

import org.apache.tuscany.sca.core.context.CallableReferenceImpl;
import org.apache.tuscany.sca.databinding.annotation.DataBinding;
import org.apache.tuscany.sca.databinding.job.Job;
import org.osoa.sca.annotations.OneWay;
import org.osoa.sca.annotations.Remotable;
import org.osoa.sca.ServiceReference;

@DataBinding("org.apache.tuscany.sca.databinding.job.Job")
@Remotable
public interface WorkpoolService {

    /* this the functional part */
    void submit(Job i);

    /* the time between two subsequent worker invocations */
    double getServiceTime();

    /* the number of ResultJob received */
    long getJobComputed();

    /* the time elapsed between the stream has initiated and now */
    long getElapsedTime();

    /* the size of the internal queue : it's not accurate */
    int estimatedQueueSize();

    /* the average time between two consuecutive submit */
    double getArrivalTime();

    void start();

    void stop();

    /*
     * this is the part needed by management. May be in future i'll refactor it
     * order to hide this part.
     */
    @OneWay
    void handleResult(Job j, boolean reuse, String string,
            CallableReferenceImpl<WorkerService> worker, boolean newJob);

    void addTrigger(CallableReferenceImpl<Trigger> reference);

    void removeTrigger();

    void registerManager(
            CallableReferenceImpl<WorkpoolManager> createSelfReference);

    /*
     * This could placed in another interface definition - think about it These
     * methods evict, and evictAll are needed when a worker finish to exist and
     * it needs to be evicted by the WorkpoolManager. In the system I have two
     * caches: 1) a domain cache, which holds the components URI 2) a
     * workerReference cache (implemented by a ConcurrentHashMap), which holds a
     * proxy to each worker. Every proxy gets built from the worker callable
     * reference. I'm thinking for placing the workerReferenceCache in a local
     * interface. Assuming that WorkpoolService and WorkpoolManager are in the
     * same JVM.
     */
    void evict(String workerURI);

    void evictAll();

    /*
     * these two are no longer needed. I leave it because if i'll have time to
     * do dynamic wiring the first one is needed. void PostWorkerName(String
     * referenceName);
     */
    void PostWorkerReference(CallableReferenceImpl<WorkerService> worker);

}