Browse Source

added dnet-core-services, which embeds old cnr-notifications-common, cnr-blackboard-common, cnr-resultset-service

master
Claudio Atzori 3 years ago
parent
commit
c121531bdc
  1. 4
      dnet-core-components/src/test/java/eu/dnetlib/miscutils/iterators/xml/IterableXmlParserTest.java
  2. 22
      dnet-core-services/pom.xml
  3. 61
      dnet-core-services/src/main/java/eu/dnetlib/enabling/hcm/HostingContextManagerServiceImpl.java
  4. 17
      dnet-core-services/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriber.java
  5. 117
      dnet-core-services/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriberImpl.java
  6. 57
      dnet-core-services/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriptionListFactory.java
  7. 19
      dnet-core-services/src/main/java/eu/dnetlib/enabling/hnm/HostingNodeManagerServiceImpl.java
  8. 155
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/AbstractObservableResultset.java
  9. 38
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/AbstractResultSetFactory.java
  10. 46
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/CachingResultSetFactory.java
  11. 61
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/CachingResultSetListener.java
  12. 60
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/CountingResultSet.java
  13. 26
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/CountingResultSetFactory.java
  14. 23
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/EPRPoolingLocalOpenResultSetFactoryImpl.java
  15. 27
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/EPRPoolingLocalResultSetFactoryImpl.java
  16. 105
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/FetchList.java
  17. 116
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/IterableResultSet.java
  18. 67
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/IterableResultSetFactory.java
  19. 68
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/JaxbResultsetListenerWrapper.java
  20. 23
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/LocalOpenResultSetFactoryImpl.java
  21. 38
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/LocalResultSetFactoryImpl.java
  22. 98
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/LocalResultSetImpl.java
  23. 151
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/MappedResultSet.java
  24. 53
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/MappedResultSetFactory.java
  25. 57
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ParallelMappedResultSet.java
  26. 49
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ParallelMappedResultSetFactory.java
  27. 71
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ResultSet.java
  28. 16
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ResultSetAware.java
  29. 137
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ResultSetEPRPool.java
  30. 19
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ResultSetFactory.java
  31. 15
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ResultSetListener.java
  32. 19
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ResultSetPropertyDao.java
  33. 23
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ResultSetPropertyDaoImpl.java
  34. 75
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ResultSetRegistry.java
  35. 123
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ResultSetRegistryImpl.java
  36. 259
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ResultSetServiceImpl.java
  37. 7
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/SizedIterable.java
  38. 32
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/StreamingResultSetFactory.java
  39. 132
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/StreamingResultSetListener.java
  40. 34
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/TypedResultSetListener.java
  41. 75
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/XSLTMappedResultSetFactory.java
  42. 29
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/observer/DelegationObserver.java
  43. 18
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/observer/Observable.java
  44. 23
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/observer/ResultSetObserver.java
  45. 44
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/push/AbstractPushResultSetFactoryImpl.java
  46. 179
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/push/CacheTransientResultSetDaoImpl.java
  47. 22
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/push/PushResultSet.java
  48. 21
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/push/PushResultSetFactory.java
  49. 156
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/push/ResultSetDescriptor.java
  50. 7
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/push/ResultSetDescriptorFactory.java
  51. 45
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/push/TransientPushResultSetDao.java
  52. 34
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/push/TransientPushResultSetFactory.java
  53. 99
      dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/push/TransientPushResultSetImpl.java
  54. 61
      dnet-core-services/src/main/resources/eu/dnetlib/enabling/hcm/applicationContext-hcm.xml
  55. 45
      dnet-core-services/src/main/resources/eu/dnetlib/enabling/hnm/applicationContext-hnm.xml
  56. 10
      dnet-core-services/src/main/resources/eu/dnetlib/enabling/resultset/applicationContext-resultset.properties
  57. 138
      dnet-core-services/src/main/resources/eu/dnetlib/enabling/resultset/applicationContext-resultset.xml
  58. 75
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/FetchListTest.java
  59. 150
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/IterableResultSetTest.java
  60. 174
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/LocalResultSetImplTest.java
  61. 140
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/MappedResultSetTest.java
  62. 184
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/ResultSetRegistryImplTest.java
  63. 101
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/ResultSetServiceImplTest.java
  64. 62
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/StreamingResultSetListenerTest.java
  65. 139
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/XSLTMappedResultSetFactoryTest.java
  66. 223
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/push/AbstractTransientPushResultSetDaoTest.java
  67. 78
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/push/CacheTransientPushResultSetDaoTest.java
  68. 36
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/push/ResultSetDescriptorFactoryTest.java
  69. 44
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/push/ResultSetDescriptorTest.java
  70. 166
      dnet-core-services/src/test/java/eu/dnetlib/enabling/resultset/push/TransientPushResultSetImplTest.java
  71. 14
      dnet-core-services/src/test/resources/eu/dnetlib/enabling/resultset/push/ResultSetDescriptorFactoryTest-context.xml
  72. 6
      dnet-core-services/src/test/resources/eu/dnetlib/enabling/resultset/test.xsl
  73. 25
      pom.xml

4
dnet-core-components/src/test/java/eu/dnetlib/miscutils/iterators/xml/IterableXmlParserTest.java

@ -16,10 +16,14 @@ import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
@Ignore
// TODO investigate why it takes so long to run
// Time elapsed: 303.806 sec - in eu.dnetlib.miscutils.iterators.xml.IterableXmlParserTest
public class IterableXmlParserTest {
private Resource xmlZip = new ClassPathResource("eu/dnetlib/miscutils/iterators/xml/opendoar.zip");

22
dnet-core-services/pom.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet-core</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>dnet-core-services</artifactId>
<groupId>eu.dnetlib</groupId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>eu.dnetlib</groupId>
<artifactId>dnet-core-components</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

61
dnet-core-services/src/main/java/eu/dnetlib/enabling/hcm/HostingContextManagerServiceImpl.java

@ -0,0 +1,61 @@
package eu.dnetlib.enabling.hcm;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Required;
import eu.dnetlib.enabling.hcm.rmi.HostingContextManagerService;
import eu.dnetlib.enabling.tools.AbstractBaseService;
import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
/**
* CNR HostingContextManagerService implementation. Will conflict with NKUA! yes this is ok.
*
* @author marko
*
*/
public class HostingContextManagerServiceImpl extends AbstractBaseService implements HostingContextManagerService {
/**
* logger.
*/
private static final Log log = LogFactory.getLog(HostingContextManagerServiceImpl.class); // NOPMD by marko on 11/24/08 5:02 PM
/**
* notification handler.
*/
private NotificationHandler notificationHandler; // NOPMD
@Override
public void notify(String subscrId, String topic, String isId, String message) {
if (log.isDebugEnabled()) {
log.debug("---- service got notification ----");
log.debug("subscrId: " + subscrId);
log.debug("topic " + topic);
log.debug("isId " + isId);
log.debug("msg: " + message);
log.debug("____ now processing the notification ____");
}
getNotificationHandler().notified(subscrId, topic, isId, message);
}
/**
* {@inheritDoc}
*
* @see eu.dnetlib.enabling.tools.AbstractBaseService#start()
*/
@Override
public void start() {
log.info("staring hosting context manager");
}
public NotificationHandler getNotificationHandler() {
return notificationHandler;
}
@Required
public void setNotificationHandler(NotificationHandler notificationHandler) {
this.notificationHandler = notificationHandler;
}
}

17
dnet-core-services/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriber.java

@ -0,0 +1,17 @@
package eu.dnetlib.enabling.hcm.sn;
import eu.dnetlib.enabling.is.sn.rmi.ISSNException;
/**
* This component takes care of subscribing the MSRO service to interesting events.
*
* @author marko
*
*/
public interface HCMSubscriber {
/**
* performs the subscription.
* @throws ISSNException could happen
*/
void subscribeAll() throws ISSNException;
}

117
dnet-core-services/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriberImpl.java

@ -0,0 +1,117 @@
package eu.dnetlib.enabling.hcm.sn;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.xml.ws.Endpoint;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Required;
import eu.dnetlib.enabling.actions.SubscriptionAction;
import eu.dnetlib.enabling.is.sn.rmi.ISSNException;
import eu.dnetlib.enabling.is.sn.rmi.ISSNService;
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
import eu.dnetlib.soap.EndpointReferenceBuilder;
/**
* This component takes care of subscribing the SubscriptionAction(s) to interesting events.
*
* @author claudio
*
*/
public class HCMSubscriberImpl implements HCMSubscriber {
/**
* logger.
*/
private static final Log log = LogFactory.getLog(HCMSubscriberImpl.class);
/**
* notification endpoint (normally the msro service).
*/
private Endpoint endpoint;
/**
* service locator.
*/
private UniqueServiceLocator serviceLocator;
/**
* injected EPR builder.
*/
@Resource(name = "jaxwsEndpointReferenceBuilder")
private EndpointReferenceBuilder<Endpoint> eprBuilder;
/**
* subscription actions.
*/
private List<SubscriptionAction> actions;
@PostConstruct
public void printList() {
log.info(getActions());
}
/**
* {@inheritDoc}
*
* @throws ISSNException
* could happen
* @see eu.dnetlib.enabling.hcm.sn.HCMSubscriber#subscribeAll()
*/
@Override
public void subscribeAll() throws ISSNException {
final W3CEndpointReference endpointReference = eprBuilder
.getEndpointReference(getEndpoint());
if (getActions() != null) {
for (final SubscriptionAction action : getActions()) {
log.info("dynamically subscribing to "
+ action.getTopicExpression());
serviceLocator.getService(ISSNService.class, true).subscribe(endpointReference,
action.getTopicExpression(), 0);
}
}
}
public void setEndpoint(final Endpoint endpoint) {
this.endpoint = endpoint;
}
public Endpoint getEndpoint() {
return endpoint;
}
public void setEprBuilder(
final EndpointReferenceBuilder<Endpoint> eprBuilder) {
this.eprBuilder = eprBuilder;
}
public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
return eprBuilder;
}
public List<SubscriptionAction> getActions() {
return actions;
}
@Required
public void setActions(final List<SubscriptionAction> actions) {
this.actions = actions;
}
public UniqueServiceLocator getServiceLocator() {
return serviceLocator;
}
@Required
public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
this.serviceLocator = serviceLocator;
}
}

57
dnet-core-services/src/main/java/eu/dnetlib/enabling/hcm/sn/HCMSubscriptionListFactory.java

@ -0,0 +1,57 @@
package eu.dnetlib.enabling.hcm.sn;
import java.util.List;
import com.google.common.collect.Lists;
import eu.dnetlib.enabling.actions.SubscriptionAction;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
/**
* This class acts as a simple registry of msro subscription actions.
*
* <p>
* Subscription actions are autodetected using spring autowiring from the current application context and are available for the manager for
* handling subscriptions and delivering notification to particular code interested in those notifications.
* </p>
*
* @author marko
*
*/
@SuppressWarnings("rawtypes")
public class HCMSubscriptionListFactory implements FactoryBean<List<SubscriptionAction>> {
/**
* actions. Spring injects all the declared SubscriptionActions here.
*/
@Autowired(required = false)
private List<SubscriptionAction> actions = Lists.newArrayList();
public List<SubscriptionAction> getActions() {
return actions;
}
public void setActions(final List<SubscriptionAction> actions) {
this.actions = actions;
}
/**
* {@inheritDoc}
*
* @see org.springframework.beans.factory.FactoryBean#getObject()
*/
@Override
public List<SubscriptionAction> getObject() {
return getActions();
}
@Override
public Class<List> getObjectType() {
return List.class;
}
@Override
public boolean isSingleton() {
return false;
}
}

19
dnet-core-services/src/main/java/eu/dnetlib/enabling/hnm/HostingNodeManagerServiceImpl.java

@ -0,0 +1,19 @@
package eu.dnetlib.enabling.hnm;
import eu.dnetlib.enabling.hnm.rmi.HostingNodeManagerService;
import eu.dnetlib.enabling.tools.AbstractBaseService;
/**
* HNMService implementation.
*
* @author michele
*
*/
public class HostingNodeManagerServiceImpl extends AbstractBaseService implements HostingNodeManagerService {
@Override
public String echo(String s) {
return s;
}
}

155
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/AbstractObservableResultset.java

@ -0,0 +1,155 @@
package eu.dnetlib.enabling.resultset;
import java.util.Map;
import java.util.WeakHashMap;
import eu.dnetlib.enabling.resultset.observer.DelegationObserver;
import eu.dnetlib.enabling.resultset.observer.Observable;
/**
* Common stuff for resultset implementations bound to a ResultSetRegistry.
*
* @author marko
*
*/
public abstract class AbstractObservableResultset implements ResultSet, Observable {
/**
* true if the resultset is destroyed.
*/
private boolean destroyed = false;
/**
* true if the resultset is open.
*/
private boolean open;
/**
* delegate the real job to a java.util.Observable object.
*/
private transient final java.util.Observable observable = new DelegationObservable();
/**
* weak map for removing single observers later on.
*/
private transient Map<ResultSetRegistry, DelegationObserver> observers = new WeakHashMap<ResultSetRegistry, DelegationObserver>();
/**
* java.util.Observable requires a "change" in the object to be made for the notifyObservers methods to trigger
* actually the notification. We don't think this should be part of the base Observable/Observer pattern and thus
* hide this fact. If an user of AbstractObservable wants this behavior it should implement her own change tracking
* and avoid calling notifyObservers altogether. The rationale behind this choice is that not all dirty states can
* be expressed using a stateful boolean instance variable like that implemented by java.util.Observable; some users
* may prefer/need a lazy dirty flag instead.
*
* @author marko
*
*/
static class DelegationObservable extends java.util.Observable {
/**
* {@inheritDoc}
*
* @see java.util.Observable#notifyObservers()
*/
@Override
public void notifyObservers() {
setChanged();
super.notifyObservers();
}
/**
* {@inheritDoc}
*
* @see java.util.Observable#notifyObservers(java.lang.Object)
*/
@Override
public void notifyObservers(final Object arg) {
setChanged();
super.notifyObservers(arg);
}
}
/**
* {@inheritDoc}
*
* @see eu.dnetlib.enabling.resultset.ResultSet#destroy()
*/
@Override
public void destroy() {
if (!isDestroyed()) {
setDestroyed(true);
notifyObservers();
deleteObservers();
}
}
public void setDestroyed(final boolean destroyed) {
this.destroyed = destroyed;
}
@Override
public boolean isDestroyed() {
return destroyed;
}
/**
* {@inheritDoc}
*
* @see eu.dnetlib.enabling.resultset.ResultSet#isOpen()
*/
@Override
public boolean isOpen() {
return open;
}
/**
* {@inheritDoc}
*
* @see eu.dnetlib.enabling.resultset.ResultSet#close()
*/
@Override
public void close() {
open = false;
}
public void setOpen(final boolean open) {
this.open = open;
}
@Override
public void addObserver(final ResultSetRegistry observer) {
final DelegationObserver delegate = new DelegationObserver(this, observer);
observers.put(observer, delegate);
observable.addObserver(delegate);
}
protected void notifyObservers() {
observable.notifyObservers();
}
protected void notifyObservers(final Object arg) {
observable.notifyObservers(arg);
}
public int countObservers() {
return observable.countObservers();
}
public void deleteObserver(final java.util.Observer observer) {
observable.deleteObserver(observer);
}
public void deleteObserver(ResultSetRegistry observer) {
DelegationObserver delegate = observers.get(observer);
if(delegate != null) {
observable.deleteObserver(delegate);
}
}
public void deleteObservers() {
observable.deleteObservers();
}
}

38
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/AbstractResultSetFactory.java

@ -0,0 +1,38 @@
package eu.dnetlib.enabling.resultset;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
/**
* Resultset factories bound to a resultset service, from which it takes the resultset registry and the epr builder.
*
* @author marko
*
*/
public abstract class AbstractResultSetFactory implements ResultSetFactory {
/**
* resultset service.
*/
private ResultSetServiceImpl resultSetService;
/**
* Register a resultset instance to the underlying resultset registry and returns
* and EPR to accessible through the resultset service.
*
* @param resultSet resultset instance
* @return epr to the newly created resultset
*/
public W3CEndpointReference registerResultSet(final ResultSet resultSet) {
resultSetService.getResultsetRegistry().addResultSet(resultSet);
return resultSetService.getEprBuilder().getEndpointReference(resultSetService.getEndpoint(), resultSet.getIdentifier());
}
public ResultSetServiceImpl getResultSetService() {
return resultSetService;
}
public void setResultSetService(final ResultSetServiceImpl resultSetService) {
this.resultSetService = resultSetService;
}
}

46
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/CachingResultSetFactory.java

@ -0,0 +1,46 @@
package eu.dnetlib.enabling.resultset;
import javax.annotation.Resource;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.springframework.beans.factory.annotation.Required;
import eu.dnetlib.enabling.tools.ServiceResolver;
public class CachingResultSetFactory {
/**
* underlying resultset factory, which exposes local resultsets to the world.
*/
private ResultSetFactory resultSetFactory;
@Resource
private ServiceResolver serviceResolver;
/**
* @param items
* @param size
* the size of the iterable
* @return
*/
public W3CEndpointReference createCachingResultSet(W3CEndpointReference epr) {
return resultSetFactory.createResultSet(new CachingResultSetListener(epr, serviceResolver));
}
public ResultSetFactory getResultSetFactory() {
return resultSetFactory;
}
@Required
public void setResultSetFactory(ResultSetFactory resultSetFactory) {
this.resultSetFactory = resultSetFactory;
}
public ServiceResolver getServiceResolver() {
return serviceResolver;
}
public void setServiceResolver(ServiceResolver serviceResolver) {
this.serviceResolver = serviceResolver;
}
}

61
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/CachingResultSetListener.java

@ -0,0 +1,61 @@
package eu.dnetlib.enabling.resultset;
import java.util.ArrayList;
import java.util.List;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import eu.dnetlib.enabling.resultset.rmi.ResultSetException;
import eu.dnetlib.enabling.resultset.rmi.ResultSetService;
import eu.dnetlib.enabling.tools.ServiceResolver;
public class CachingResultSetListener implements ResultSetListener {
private static final Log log = LogFactory.getLog(CachingResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
private ResultSetService service;
private String rsId;
private ArrayList<String> storage = new ArrayList<String>();
public CachingResultSetListener(W3CEndpointReference epr, ServiceResolver serviceResolver) {
this.service = serviceResolver.getService(ResultSetService.class, epr);
this.rsId = serviceResolver.getResourceIdentifier(epr);
}
@Override
public List<String> getResult(int fromPosition, int toPosition) {
if (storage.get(fromPosition) != null)
return cached(fromPosition, toPosition);
try {
List<String> data = service.getResult(rsId, fromPosition, toPosition, "waiting");
cache(data, fromPosition, toPosition);
return data;
} catch (ResultSetException e) {
throw new IllegalStateException(e);
}
}
private void cache(List<String> data, int fromPosition, int toPosition) {
for(String value : data)
storage.set(fromPosition++, value);
}
private List<String> cached(int fromPosition, int toPosition) {
log.info("found cached page " + fromPosition + ", " + toPosition);
return storage.subList(fromPosition-1, toPosition);
}
@Override
public int getSize() {
try {
return service.getNumberOfElements(rsId);
} catch (ResultSetException e) {
throw new IllegalStateException(e);
}
}
}

60
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/CountingResultSet.java

@ -0,0 +1,60 @@
package eu.dnetlib.enabling.resultset;
import java.util.List;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import eu.dnetlib.enabling.tools.ServiceResolver;
import eu.dnetlib.miscutils.functional.IdentityFunction;
import eu.dnetlib.miscutils.functional.UnaryFunction;
/**
* A resultset record counter.
*
* @author claudio
*
*/
public class CountingResultSet extends MappedResultSet {
/**
* counter.
*/
private int count;
/**
* @param epr
* @param serviceResolver
*/
public CountingResultSet(final W3CEndpointReference epr, final ServiceResolver serviceResolver) {
this(epr, new IdentityFunction<String>(), serviceResolver);
}
/**
* @param epr
* @param mapper
* @param serviceResolver
*/
public CountingResultSet(final W3CEndpointReference epr, final UnaryFunction<String, String> mapper, final ServiceResolver serviceResolver) {
super(epr, mapper, serviceResolver);
count = 0;
}
/**
* method sets the counter to the higher allowed value of toPosition.
*/
@Override
public List<String> getResult(int fromPosition, int toPosition) {
if (toPosition > count)
count = toPosition;
if (toPosition > super.getSize())
count = super.getSize();
return super.getResult(fromPosition, toPosition);
}
public int getCount() {
return count;
}
}

26
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/CountingResultSetFactory.java

@ -0,0 +1,26 @@
package eu.dnetlib.enabling.resultset;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
/**
* Create a new resultset which takes each record of the input resultset and counts them.
*
* @author claudio
*
*/
public class CountingResultSetFactory extends MappedResultSetFactory {
/**
* Create a new resultset which takes each record of the input resultset and counts them.
*
* @param source
* source resultset epr
* @param mapper
* mapper function
* @return mapped resultset epr
*/
public W3CEndpointReference createCountingResultSet(final W3CEndpointReference source) {
return getResultSetFactory().createResultSet(new CountingResultSet(source, getServiceResolver()));
}
}

23
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/EPRPoolingLocalOpenResultSetFactoryImpl.java

@ -0,0 +1,23 @@
package eu.dnetlib.enabling.resultset;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.springframework.beans.factory.annotation.Required;
public class EPRPoolingLocalOpenResultSetFactoryImpl extends LocalOpenResultSetFactoryImpl {
private ResultSetEPRPool pool;
@Override
public W3CEndpointReference registerResultSet(ResultSet resultSet) {
return pool.registerResultSet(resultSet);
}
public ResultSetEPRPool getPool() {
return pool;
}
@Required
public void setPool(ResultSetEPRPool pool) {
this.pool = pool;
}
}

27
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/EPRPoolingLocalResultSetFactoryImpl.java

@ -0,0 +1,27 @@
package eu.dnetlib.enabling.resultset;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.springframework.beans.factory.annotation.Required;
public class EPRPoolingLocalResultSetFactoryImpl extends LocalResultSetFactoryImpl {
private ResultSetEPRPool pool;
@Override
public W3CEndpointReference registerResultSet(ResultSet resultSet) {
return pool.registerResultSet(resultSet);
}
public ResultSetEPRPool getPool() {
return pool;
}
@Required
public void setPool(ResultSetEPRPool pool) {
this.pool = pool;
}
}

105
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/FetchList.java

@ -0,0 +1,105 @@
package eu.dnetlib.enabling.resultset;
import java.util.Iterator;
import java.util.LinkedList;
/**
* a LinkedList populated by a given iterable, which provides a fetch window of elements
*
* @author claudio
*
* @param <T>
* The FetchList type
*/
public class FetchList<T> extends LinkedList<T> {
/**
*
*/
private static final long serialVersionUID = 7135272008563693321L;
/**
* represents the number of elements ready to be pulled out of the list
*/
private int fetchSize;
/**
* represents the number of elements already consumed by a poll call
*/
private int consumedElements;
/**
* the given itarable used to populate the list
*/
private Iterator<T> iter;
/**
* @param iter
* @param fetchSize
*/
public FetchList(final Iterator<T> iter, final int fetchSize) {
super();
this.consumedElements = 0;
this.fetchSize = fetchSize;
this.iter = iter;
}
/**
* used to fill the list
*/
public synchronized void fill() {
for (int i = 0; i < fetchSize; i++) {
if (!iter.hasNext()) {
break;
}
this.add(iter.next());
}
}
/**
* return the first element and makes the list to be filled in case its size is zero
*/
@Override
public T poll() {
if (this.isEmpty()) {
fill();
}
if (this.size() > 0) {
consumedElements++;
return super.poll();
}
return null;
}
/**
* @return the number of elements already consumed by a "poll"
*/
public int getConsumedElements() {
return consumedElements;
}
/**
* @return the actual number of elements of the list
*/
public int getTotalElements() {
return consumedElements + this.size();
}
/**
* to provide an actual size, fills the list if there are elements to fill it
*/
@Override
public int size() {
if (this.isEmpty() && iter.hasNext()) {
fill();
}
return super.size();
}
@Override
public boolean isEmpty() {
return super.size() == 0;
}
}

116
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/IterableResultSet.java

@ -0,0 +1,116 @@
package eu.dnetlib.enabling.resultset;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* an open ResultSet that can be iterated to get it's data results.
*
* @author claudio
*
*/
public class IterableResultSet implements ResultSetListener, ResultSetAware {
/**
* logger.
*/
private static final Log log = LogFactory.getLog(IterableResultSet.class);
/**
* the container for the data results.
*/
private ResultSet resultSet;
/**
* the list that provides data for this resultSet.
*/
private FetchList<String> fetchList;
private int optionalNumberOfElements;
/**
*
* @param iter
* @param fetchSize
*/
protected IterableResultSet(Iterable<String> iter, int fetchSize) {
fetchList = new FetchList<String>(iter.iterator(), fetchSize);
if (iter instanceof SizedIterable<?>) {
optionalNumberOfElements = ((SizedIterable<?>) iter).getNumberOfElements();
} else {
optionalNumberOfElements = -1;
}
}
/**
* @param fromPosition
* @param toPosition
* @return <T> List
*/
@Override
public List<String> getResult(int fromPosition, int toPosition) {
log.debug(" - getting result from " + fromPosition + " to " + toPosition + ", consumedElements: " + fetchList.getConsumedElements());
if (fromPosition != fetchList.getConsumedElements() + 1)
throw new RuntimeException("Unexpected value for 'fromPosition' parameter");
if (toPosition < fromPosition)
throw new RuntimeException("'fromPosition' must be lower or equal than 'toPosition'");
List<String> result = new ArrayList<String>();
for (int i = fromPosition; i <= toPosition; i++) {
if (fetchList.size() > 0)
result.add(fetchList.poll());
else
break;
}
ensureClosed();
return result;
}
private void ensureClosed() {
if (fetchList.size() == 0 && resultSet.isOpen()) {
log.info(">>>>>>>>>>> closing resultset <<<<<<<<<<<<<");
close();
}
}
public String getRSStatus() {
if (resultSet.isOpen())
return "open";
return "closed";
}
@Override
public int getSize() {
ensureClosed();
if (optionalNumberOfElements == -1)
return fetchList.getTotalElements();
else
return optionalNumberOfElements;
}
/**
* closes the resultset.
*/
protected void close() {
resultSet.close();
}
@Override
public void setResultSet(ResultSet resultSet) {
this.resultSet = resultSet;
}
public ResultSet getResultSet() {
return resultSet;
}
}

67
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/IterableResultSetFactory.java

@ -0,0 +1,67 @@
package eu.dnetlib.enabling.resultset;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.springframework.beans.factory.annotation.Required;
/**
*
* @author claudio
*
*/
public class IterableResultSetFactory {
/**
* {@link ResultSetFactory}
*/
private LocalOpenResultSetFactoryImpl resultSetFactory;
/**
*
*/
private int fetchSize;
/**
*
* @param source
* @return
*/
public W3CEndpointReference createIterableResultSet(final Iterable<String> source) {
return resultSetFactory.createResultSet(new IterableResultSet(source, fetchSize));
}
/**
*
* @return
*/
public LocalOpenResultSetFactoryImpl getResultSetFactory() {
return resultSetFactory;
}
/**
*
* @param resultSetFactory
*/
@Required
public void setResultSetFactory(final LocalOpenResultSetFactoryImpl resultSetFactory) {
this.resultSetFactory = resultSetFactory;
}
/**
*
* @param fetchSize
*/
@Required
public void setFetchSize(int fetchSize) {
this.fetchSize = fetchSize;
}
/**
*
* @return
*/
public int getFetchSize() {
return fetchSize;
}
}

68
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/JaxbResultsetListenerWrapper.java

@ -0,0 +1,68 @@
package eu.dnetlib.enabling.resultset;
import java.util.List;
import javax.xml.bind.JAXBException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.google.common.collect.Lists;
import eu.dnetlib.miscutils.collections.MappedCollection;
import eu.dnetlib.miscutils.functional.UnaryFunction;
import eu.dnetlib.miscutils.jaxb.JaxbFactory;
/**
* Given a jaxb factory for a given type, wraps TypedResultsetListeners to ResultSetListeners, serializing objects
* according to the jaxb factory.
*
* @author marko
*
* @param <T>
*/
public class JaxbResultsetListenerWrapper<T> {
private static final Log log = LogFactory.getLog(JaxbResultsetListenerWrapper.class); // NOPMD by marko on 11/24/08 5:02 PM
private JaxbFactory<T> factory;
/**
* Returns a listener which serializes each item according to the jaxb factory.
*
* @param listener
* listener which returns T
* @return listener which returns strings
*/
public ResultSetListener wrap(final TypedResultSetListener<T> listener) {
return new ResultSetListener() {
@Override
public List<String> getResult(final int fromPosition, final int toPosition) {
return Lists.newArrayList(new MappedCollection<String, T>(listener.getResult(fromPosition, toPosition), new UnaryFunction<String, T>() {
@Override
public String evaluate(final T value) {
try {
return factory.serialize(value);
} catch (final JAXBException e) {
log.warn("cannot serialize", e);
throw new RuntimeException(e);
}
}
}));
}
@Override
public int getSize() {
return listener.getSize();
}
};
}
public JaxbFactory<T> getFactory() {
return factory;
}
public void setFactory(final JaxbFactory<T> factory) {
this.factory = factory;
}
}

23
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/LocalOpenResultSetFactoryImpl.java

@ -0,0 +1,23 @@
package eu.dnetlib.enabling.resultset;
/**
* Creates an "open" (unbounded, unfreezed) local resultset.
*
* @author marko
*
*/
public class LocalOpenResultSetFactoryImpl extends LocalResultSetFactoryImpl {
/**
* {@inheritDoc}
* @see eu.dnetlib.enabling.resultset.LocalResultSetFactoryImpl#createInstance(eu.dnetlib.enabling.resultset.ResultSetListener)
*/
@Override
protected LocalResultSetImpl createInstance(final ResultSetListener provider) {
final LocalResultSetImpl instance = super.createInstance(provider);
instance.setOpen(true);
return instance;
}
}

38
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/LocalResultSetFactoryImpl.java

@ -0,0 +1,38 @@
package eu.dnetlib.enabling.resultset;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
/**
* This factory creates resultset bound to a given resultset registry shared with a resultset service which exposed them
* to the outside world.
*
* It's tightly coupled with a local instance of the ResultSetService.
*
* @see eu.dnetlib.enabling.resultset.ResultSetServiceImpl
*
* @author marko
*
*/
public class LocalResultSetFactoryImpl extends AbstractResultSetFactory {
/**
* {@inheritDoc}
*
* @see eu.dnetlib.enabling.resultset.ResultSetFactory#createResultSet(eu.dnetlib.enabling.resultset.ResultSetListener)
*/
@Override
public W3CEndpointReference createResultSet(final ResultSetListener provider) {
return registerResultSet(createInstance(provider));
}
/**
* create a new local resultset instance. Subclasses may override this to supply additional configuration.
*
* @param provider provider
* @return a new resultset instance.
*/
protected LocalResultSetImpl createInstance(final ResultSetListener provider) {
return new LocalResultSetImpl(provider);
}
}

98
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/LocalResultSetImpl.java

@ -0,0 +1,98 @@
package eu.dnetlib.enabling.resultset;
import java.util.List;
import com.google.common.collect.Lists;
/**
* Resultset backing implementation.
*
* @author marko
*
*/
public class LocalResultSetImpl extends AbstractObservableResultset implements ResultSet {
/**
* rsId.
*/
private String identifier;
/**
* this listener will provide the data to this local resultset by listening to events.
*/
private ResultSetListener listener;
/**
* Construct a new local ResultSet which pulls data from the listener. If the listener implements ResultSetAware, it
* will be injected with this instance.
*
* @param listener
* a resultset listener
*/
public LocalResultSetImpl(final ResultSetListener listener) {
super();
this.listener = listener;
if (listener instanceof ResultSetAware)
((ResultSetAware) listener).setResultSet(this);
}
/**
* {@inheritDoc}
*
* @see eu.dnetlib.enabling.resultset.ResultSet#getNumberOfResults()
*/
@Override
public int getNumberOfResults() {
return listener.getSize();
}
/**
* {@inheritDoc}
*
* @see eu.dnetlib.enabling.resultset.ResultSet#getResults(int, int)
*/
@Override
public List<String> getResults(final int fromPosition, final int toPosition) {
int toPos = toPosition;
int fromPos = fromPosition;
if (!isOpen()) {
final int size = getNumberOfResults();
if (size == 0)
return Lists.newArrayList();
if (fromPos > size)
return Lists.newArrayList();
if (toPos > size)
toPos = size;
}
if (fromPos < 1)
fromPos = 1;
if (toPos < fromPos)
toPos = fromPos;
return listener.getResult(fromPos, toPos);
}
@Override
public String getIdentifier() {
return identifier;
}
@Override
public void setIdentifier(final String identifier) {
this.identifier = identifier;
}
public ResultSetListener getListener() {
return listener;
}
public void setListener(final ResultSetListener listener) {
this.listener = listener;
}
}

151
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/MappedResultSet.java

@ -0,0 +1,151 @@
package eu.dnetlib.enabling.resultset;
import java.util.List;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import org.springframework.beans.factory.annotation.Required;
import eu.dnetlib.enabling.resultset.rmi.ResultSetException;
import eu.dnetlib.enabling.resultset.rmi.ResultSetService;
import eu.dnetlib.enabling.tools.ServiceResolver;
import eu.dnetlib.miscutils.collections.MappedCollection;
import eu.dnetlib.miscutils.functional.UnaryFunction;
/**
* A resultset filter. Applies a transformation for every resultset record.
*
* @author marko
*
*/
public class MappedResultSet implements ResultSetListener, ResultSetAware {
/**
* input resultset.
*/
private ResultSetService resultSetService;
/**
* input resultset id.
*/
private String rsId;
/**
* mapper function.
*/
private UnaryFunction<String, String> mapper;
/**
* service resolver.
*/
private ServiceResolver serviceResolver;
private ResultSet resultSet;
/**
* Create a new mapped resultset.
*
* @param epr
* input resultset epr
* @param mapper
* mapper function
* @param serviceResolver
* service resolver
*/
public MappedResultSet(final W3CEndpointReference epr, final UnaryFunction<String, String> mapper, final ServiceResolver serviceResolver) {
super();
this.resultSetService = serviceResolver.getService(ResultSetService.class, epr);
this.rsId = serviceResolver.getResourceIdentifier(epr);
this.mapper = mapper;
this.serviceResolver = serviceResolver;
}
/**
* {@inheritDoc}
*
* @see eu.dnetlib.enabling.resultset.ResultSetListener#getResult(int, int)
*/
@Override
public List<String> getResult(final int fromPosition, final int toPosition) {
return MappedCollection.listMap(getResultFromSource(fromPosition, toPosition), mapper);
}
protected List<String> getResultFromSource(final int fromPosition, final int toPosition) {
try {
List<String> res = resultSetService.getResult(rsId, fromPosition, toPosition, "waiting");
checkStatus();
return res;
} catch (final ResultSetException e) {
throw new IllegalStateException(e);
}
}
private void checkStatus() throws ResultSetException {
if (getResultSet().isOpen() && resultSetService.getRSStatus(rsId).equals("closed")) {
getResultSet().close();
}
}
/**
* {@inheritDoc}
*
* @see eu.dnetlib.enabling.resultset.ResultSetListener#getSize()
*/
@Override
public int getSize() {
try {
int numberOfElements = resultSetService.getNumberOfElements(rsId);
checkStatus();
return numberOfElements;
} catch (final ResultSetException e) {
throw new IllegalStateException(e);
}
}
public ResultSetService getResultSetService() {
return resultSetService;
}
public void setResultSetService(final ResultSetService resultSetService) {
this.resultSetService = resultSetService;
}
public UnaryFunction<String, String> getMapper() {
return mapper;
}
public void setMapper(final UnaryFunction<String, String> mapper) {
this.mapper = mapper;
}
public ServiceResolver getServiceResolver() {
return serviceResolver;
}
@Required
public void setServiceResolver(final ServiceResolver serviceResolver) {
this.serviceResolver = serviceResolver;
}
@Override
public void setResultSet(ResultSet resultSet) {
this.resultSet = resultSet;
}
public ResultSet getResultSet() {
return resultSet;
}
public String getRsId() {
return rsId;
}
public void setRsId(String rsId) {
this.rsId = rsId;
}
}

53
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/MappedResultSetFactory.java

@ -0,0 +1,53 @@
package eu.dnetlib.enabling.resultset;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import eu.dnetlib.enabling.tools.ServiceResolver;
import eu.dnetlib.miscutils.functional.UnaryFunction;
/**
* Create a new resultset which takes each record of the input resultset and applies the mapping function to it.
*
* @author marko
*
*/
public class MappedResultSetFactory {
/**
* underlying resultset factory, which exposes local resultsets to the world.
*/
private ResultSetFactory resultSetFactory;
/**
* service resolver, transforms eprs to services.
*/
private ServiceResolver serviceResolver;
/**
* Create a new resultset which takes each record of the input resultset and applies the mapping function to it.
*
* @param source source resultset epr
* @param mapper mapper function
* @return mapped resultset epr
*/
public W3CEndpointReference createMappedResultSet(final W3CEndpointReference source, final UnaryFunction<String, String> mapper) {
return resultSetFactory.createResultSet(new MappedResultSet(source, mapper, serviceResolver));
}
public ResultSetFactory getResultSetFactory() {
return resultSetFactory;
}
public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
this.resultSetFactory = resultSetFactory;
}
public ServiceResolver getServiceResolver() {
return serviceResolver;
}
public void setServiceResolver(final ServiceResolver serviceResolver) {
this.serviceResolver = serviceResolver;
}
}

57
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ParallelMappedResultSet.java

@ -0,0 +1,57 @@
package eu.dnetlib.enabling.resultset;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import com.google.common.collect.Lists;
import eu.dnetlib.enabling.tools.ServiceResolver;
import eu.dnetlib.miscutils.collections.MappedCollection;
import eu.dnetlib.miscutils.functional.UnaryFunction;
public class ParallelMappedResultSet extends MappedResultSet {
private ExecutorService executor;
public ParallelMappedResultSet(final W3CEndpointReference source, final UnaryFunction<String, String> mapper, final ServiceResolver serviceResolver,
final ExecutorService executor) {
super(source, mapper, serviceResolver);
this.executor = executor;
}
@Override
public List<String> getResult(int fromPosition, int toPosition) {
// log.info("Parallel page " + (toPosition - fromPosition + 1));
List<Future<String>> results = Lists.newArrayList();
for (final String input : getResultFromSource(fromPosition, toPosition)) {
results.add(executor.submit(new Callable<String>() {
@Override
public String call() throws Exception {
return getMapper().evaluate(input);
}
}));
}
return MappedCollection.listMap(results, new UnaryFunction<String, Future<String>>() {
@Override
public String evaluate(Future<String> arg) {
try {
return arg.get();
} catch (InterruptedException e) {
throw new IllegalStateException(e);
} catch (ExecutionException e) {
throw new IllegalStateException(e);
}
}
});
}
}

49
dnet-core-services/src/main/java/eu/dnetlib/enabling/resultset/ParallelMappedResultSetFactory.java

@ -0,0 +1,49 @@
package eu.dnetlib.enabling.resultset;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import eu.dnetlib.miscutils.functional.UnaryFunction;
public class ParallelMappedResultSetFactory extends MappedResultSetFactory {
private ExecutorService executor;
private static final int QUEUE_SIZE = 40;
private int queueSize = QUEUE_SIZE;
private int cpus = 0;
public ParallelMappedResultSetFactory() {
super();
if (cpus == 0)
cpus = getNumberOfCPUs();
executor = new ThreadPoolExecutor(cpus, cpus, 5, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(queueSize),
new ThreadPoolExecutor.CallerRunsPolicy());
}
@Override
public W3CEndpointReference createMappedResultSet(final W3CEndpointReference source, final UnaryFunction<String, String> mapper) {
return getResultSetFactory().createResultSet(new ParallelMappedResultSet(source, mapper, getServiceResolver(), executor));
}
private int getNumberOfCPUs() {
return Runtime.getRuntime().availableProcessors();
}
public int getCpus() {
return cpus;
}
public void setCpus(int cpus) {
if(cpus > 0)
this.cpus = cpus;
}
}