Revision 45516
Added by Michele Artini over 7 years ago
modules/dnet-common-utils/trunk/src/main/java/eu/dnetlib/clients/locators/ServiceRunningInstance.java | ||
---|---|---|
1 |
package eu.dnetlib.clients.locators; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
/** |
|
7 |
* This bean packages the minimum information for describing a service running instance. |
|
8 |
*/ |
|
9 |
public class ServiceRunningInstance { |
|
10 |
|
|
11 |
private String serviceId; |
|
12 |
private String url; |
|
13 |
private int usedDiskSpace = 0; |
|
14 |
private int handledDatastructures = 0; |
|
15 |
private Map<String, String> serviceProperties = new HashMap<String, String>(); |
|
16 |
|
|
17 |
public ServiceRunningInstance() {} |
|
18 |
|
|
19 |
public ServiceRunningInstance(final String serviceId, final String url) { |
|
20 |
this.serviceId = serviceId; |
|
21 |
this.url = url; |
|
22 |
} |
|
23 |
|
|
24 |
public ServiceRunningInstance(final String serviceId, final String url, final int usedDiskSpace, |
|
25 |
final int handledDatastructures, final Map<String, String> serviceProperties) { |
|
26 |
this.serviceId = serviceId; |
|
27 |
this.url = url; |
|
28 |
this.usedDiskSpace = usedDiskSpace; |
|
29 |
this.handledDatastructures = handledDatastructures; |
|
30 |
this.serviceProperties = serviceProperties; |
|
31 |
} |
|
32 |
|
|
33 |
public String getServiceId() { |
|
34 |
return serviceId; |
|
35 |
} |
|
36 |
|
|
37 |
public void setServiceId(final String serviceId) { |
|
38 |
this.serviceId = serviceId; |
|
39 |
} |
|
40 |
|
|
41 |
public String getUrl() { |
|
42 |
return url; |
|
43 |
} |
|
44 |
|
|
45 |
public void setUrl(final String url) { |
|
46 |
this.url = url; |
|
47 |
} |
|
48 |
|
|
49 |
public Map<String, String> getServiceProperties() { |
|
50 |
return serviceProperties; |
|
51 |
} |
|
52 |
|
|
53 |
public void setServiceProperties(final Map<String, String> serviceProperties) { |
|
54 |
this.serviceProperties = serviceProperties; |
|
55 |
} |
|
56 |
|
|
57 |
public int getUsedDiskSpace() { |
|
58 |
return usedDiskSpace; |
|
59 |
} |
|
60 |
|
|
61 |
public void setUsedDiskSpace(final int usedDiskSpace) { |
|
62 |
this.usedDiskSpace = usedDiskSpace; |
|
63 |
} |
|
64 |
|
|
65 |
public int getHandledDatastructures() { |
|
66 |
return handledDatastructures; |
|
67 |
} |
|
68 |
|
|
69 |
public void setHandledDatastructures(final int handledDatastructures) { |
|
70 |
this.handledDatastructures = handledDatastructures; |
|
71 |
} |
|
72 |
|
|
73 |
} |
modules/dnet-common-utils/trunk/src/main/java/eu/dnetlib/clients/locators/ServiceClientLocator.java | ||
---|---|---|
3 | 3 |
import java.util.Comparator; |
4 | 4 |
|
5 | 5 |
import eu.dnetlib.clients.BaseServiceClient; |
6 |
import eu.dnetlib.services.ServiceRunningInstance; |
|
6 | 7 |
|
7 | 8 |
public interface ServiceClientLocator { |
8 | 9 |
|
modules/dnet-common-utils/trunk/src/main/java/eu/dnetlib/clients/locators/DefaultServiceClientLocator.java | ||
---|---|---|
27 | 27 |
import eu.dnetlib.enabling.annotations.DnetServiceType; |
28 | 28 |
import eu.dnetlib.exceptions.DnetGenericRuntimeException; |
29 | 29 |
import eu.dnetlib.exceptions.ISLookUpException; |
30 |
import eu.dnetlib.services.ServiceRunningInstance; |
|
30 | 31 |
|
31 | 32 |
public class DefaultServiceClientLocator implements ServiceClientLocator, BeanFactoryAware { |
32 | 33 |
|
modules/dnet-common-utils/trunk/src/main/java/eu/dnetlib/clients/locators/comparators/HandledDatastructuresComparator.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.Comparator; |
4 | 4 |
|
5 |
import eu.dnetlib.clients.locators.ServiceRunningInstance;
|
|
5 |
import eu.dnetlib.services.ServiceRunningInstance;
|
|
6 | 6 |
|
7 | 7 |
public class HandledDatastructuresComparator implements Comparator<ServiceRunningInstance> { |
8 | 8 |
|
modules/dnet-common-utils/trunk/src/main/java/eu/dnetlib/clients/locators/comparators/DiskSpaceComparator.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.Comparator; |
4 | 4 |
|
5 |
import eu.dnetlib.clients.locators.ServiceRunningInstance;
|
|
5 |
import eu.dnetlib.services.ServiceRunningInstance;
|
|
6 | 6 |
|
7 | 7 |
public class DiskSpaceComparator implements Comparator<ServiceRunningInstance> { |
8 | 8 |
|
modules/dnet-common-utils/trunk/src/main/java/eu/dnetlib/clients/BaseServiceClient.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import javax.annotation.PostConstruct; |
4 | 4 |
|
5 |
import eu.dnetlib.clients.locators.ServiceRunningInstance; |
|
6 | 5 |
import eu.dnetlib.enabling.annotations.DnetService; |
7 | 6 |
import eu.dnetlib.enabling.annotations.DnetServiceType; |
8 | 7 |
import eu.dnetlib.exceptions.DnetGenericException; |
8 |
import eu.dnetlib.services.ServiceRunningInstance; |
|
9 | 9 |
|
10 | 10 |
public abstract class BaseServiceClient { |
11 | 11 |
|
modules/dnet-common-utils/trunk/src/main/java/eu/dnetlib/services/ServiceRunningInstance.java | ||
---|---|---|
1 |
package eu.dnetlib.services; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
/** |
|
7 |
* This bean packages the minimum information for describing a service running instance. |
|
8 |
*/ |
|
9 |
public class ServiceRunningInstance { |
|
10 |
|
|
11 |
private String serviceId; |
|
12 |
private String url; |
|
13 |
private int usedDiskSpace = 0; |
|
14 |
private int handledDatastructures = 0; |
|
15 |
private Map<String, String> serviceProperties = new HashMap<String, String>(); |
|
16 |
|
|
17 |
public ServiceRunningInstance() {} |
|
18 |
|
|
19 |
public ServiceRunningInstance(final String serviceId, final String url) { |
|
20 |
this.serviceId = serviceId; |
|
21 |
this.url = url; |
|
22 |
} |
|
23 |
|
|
24 |
public ServiceRunningInstance(final String serviceId, final String url, final int usedDiskSpace, |
|
25 |
final int handledDatastructures, final Map<String, String> serviceProperties) { |
|
26 |
this.serviceId = serviceId; |
|
27 |
this.url = url; |
|
28 |
this.usedDiskSpace = usedDiskSpace; |
|
29 |
this.handledDatastructures = handledDatastructures; |
|
30 |
this.serviceProperties = serviceProperties; |
|
31 |
} |
|
32 |
|
|
33 |
public String getServiceId() { |
|
34 |
return serviceId; |
|
35 |
} |
|
36 |
|
|
37 |
public void setServiceId(final String serviceId) { |
|
38 |
this.serviceId = serviceId; |
|
39 |
} |
|
40 |
|
|
41 |
public String getUrl() { |
|
42 |
return url; |
|
43 |
} |
|
44 |
|
|
45 |
public void setUrl(final String url) { |
|
46 |
this.url = url; |
|
47 |
} |
|
48 |
|
|
49 |
public Map<String, String> getServiceProperties() { |
|
50 |
return serviceProperties; |
|
51 |
} |
|
52 |
|
|
53 |
public void setServiceProperties(final Map<String, String> serviceProperties) { |
|
54 |
this.serviceProperties = serviceProperties; |
|
55 |
} |
|
56 |
|
|
57 |
public int getUsedDiskSpace() { |
|
58 |
return usedDiskSpace; |
|
59 |
} |
|
60 |
|
|
61 |
public void setUsedDiskSpace(final int usedDiskSpace) { |
|
62 |
this.usedDiskSpace = usedDiskSpace; |
|
63 |
} |
|
64 |
|
|
65 |
public int getHandledDatastructures() { |
|
66 |
return handledDatastructures; |
|
67 |
} |
|
68 |
|
|
69 |
public void setHandledDatastructures(final int handledDatastructures) { |
|
70 |
this.handledDatastructures = handledDatastructures; |
|
71 |
} |
|
72 |
|
|
73 |
} |
modules/dnet-common-utils/trunk/src/main/java/eu/dnetlib/services/BaseService.java | ||
---|---|---|
4 | 4 |
import java.util.Map; |
5 | 5 |
|
6 | 6 |
import javax.annotation.PostConstruct; |
7 |
import javax.servlet.http.HttpServletRequest; |
|
7 | 8 |
|
9 |
import org.apache.commons.lang3.StringUtils; |
|
8 | 10 |
import org.apache.commons.logging.Log; |
9 | 11 |
import org.apache.commons.logging.LogFactory; |
10 | 12 |
import org.springframework.context.Lifecycle; |
13 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
11 | 14 |
|
12 | 15 |
import eu.dnetlib.enabling.annotations.DnetService; |
13 | 16 |
import eu.dnetlib.enabling.annotations.DnetServiceType; |
... | ... | |
56 | 59 |
log.info("Stopping service " + this); |
57 | 60 |
} |
58 | 61 |
|
62 |
@RequestMapping("identify") |
|
63 |
public ServiceRunningInstance identify(final HttpServletRequest req) { |
|
64 |
return new ServiceRunningInstance(getProfileId(), StringUtils.substringBeforeLast(req.getRequestURI(), "/identify")); |
|
65 |
} |
|
66 |
|
|
59 | 67 |
public String getProfileId() { |
60 | 68 |
return profileId; |
61 | 69 |
} |
Also available in: Unified diff