Skip to content

Commit

Permalink
Merge branch 'master' of ssh://git@git.actoron.com:20000/jadex/jadex.git
Browse files Browse the repository at this point in the history
  • Loading branch information
kj-actoron committed Feb 3, 2021
2 parents 97e396f + 971a7a8 commit b6769ca
Show file tree
Hide file tree
Showing 26 changed files with 914 additions and 482 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,29 @@ public class CalculateService implements ICalculateService
@Timeout(30000)
public IIntermediateFuture<PartDataChunk> calculateArea(AreaData data)
{
IntermediateFuture<PartDataChunk> ret = new IntermediateFuture<>();
IntermediateFuture<PartDataChunk> ret = new IntermediateFuture<PartDataChunk>();
// {
// @Override
// protected boolean doAddResultListener(IResultListener<Collection<PartDataChunk>> listener)
// {
// System.out.println(agent.agent+": doAddResultListener("+this+", "+listener+"), "+Thread.currentThread());
// return super.doAddResultListener(listener);
// }
//
// @Override
// protected void scheduleNotification(IResultListener<Collection<PartDataChunk>> listener, ICommand<IResultListener<Collection<PartDataChunk>>> command)
// {
// System.out.println(agent.agent+":scheduleNotification("+this+", "+listener+", "+command+"), "+Thread.currentThread());
// super.scheduleNotification(listener, command);
// }
//
// @Override
// protected void notifyIntermediateResult(IIntermediateResultListener<PartDataChunk> listener, PartDataChunk result)
// {
// System.out.println(agent.agent+":notifyIntermediateResult("+this+", "+listener+", "+result+"), "+Thread.currentThread());
// super.notifyIntermediateResult(listener, result);
// }
// };

//long start = System.currentTimeMillis();
System.out.println("calc start: "+data.getId()+" "+ag.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import jadex.bridge.service.annotation.Service;
import jadex.bridge.service.annotation.ServiceComponent;
import jadex.bridge.service.component.IRequiredServicesFeature;
import jadex.bridge.service.types.servicepool.ServicePoolHelper;
import jadex.commons.Tuple2;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;
Expand All @@ -27,7 +28,6 @@
import jadex.commons.future.IntermediateEmptyResultListener;
import jadex.commons.future.IntermediateFuture;
import jadex.commons.gui.SGUI;
import jadex.platform.service.servicepool.ServicePoolAgent;

/**
* Generate service implementation.
Expand Down Expand Up @@ -147,8 +147,8 @@ protected IFuture<AreaData> distributeWork(final AreaData data)
int numx = (int)Math.max(Math.round(Math.sqrt((double)pic/task)), 1);
int numy = (int)Math.max(Math.round((double)pic/(task*numx)), 1);

//numx = 2;
//numy = 1;
// numx = 1;
// numy = 1;

// final long time = System.nanoTime();
//System.out.println("Number of tasks: "+numx+", "+numy+", max="+data.getMax()+" tasksize="+data.getTaskSize());
Expand Down Expand Up @@ -187,7 +187,7 @@ protected IFuture<AreaData> distributeWork(final AreaData data)
// Assign tasks to service pool.
final int number = areas.size();

//System.out.println("tasks: "+areas);
System.out.println("tasks: "+areas);

//manager.setMax(data.getParallel());
performTasks(areas, true, data).addResultListener(agent.getFeature(IExecutionFeature.class).createResultListener(
Expand Down Expand Up @@ -547,7 +547,7 @@ protected IFuture<Tuple2<ICalculateService, Integer>> findFreeCalculatorService(
else
{
int fpos = pos;
ServicePoolAgent.getFreeCapacity(agent, (IService)calc).then(cap ->
ServicePoolHelper.getFreeCapacity(agent, (IService)calc).then(cap ->
{
System.out.println("capa: "+calc+" "+cap);
if(cap>0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public boolean isOptimizationAllowed()
public AreaData getDefaultSettings()
{
//return new AreaData(-2, 1, -1.5, 1.5, 100, 100, (short)256, 10, 300, this, null);
return new AreaData(-2, 1, -1.5, 1.5, 100, 100, (short)256, 300, this, null, 20);
// return new AreaData(-2, 1, -1.5, 1.5, 100, 100, (short)256, 300, this, null, 20);
return new AreaData(-2, 1, -1.5, 1.5, 100, 100, (short)256, 300, this, null, 4);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import jadex.bridge.service.component.IRequiredServicesFeature;
import jadex.bridge.service.search.ServiceQuery;
import jadex.bridge.service.types.cms.CreationInfo;
import jadex.bridge.service.types.servicepool.IServicePoolService;
import jadex.commons.DefaultPoolStrategy;
import jadex.commons.future.CounterResultListener;
import jadex.commons.future.DelegationResultListener;
Expand All @@ -42,7 +43,6 @@
import jadex.micro.annotation.Configurations;
import jadex.micro.annotation.ProvidedService;
import jadex.micro.annotation.ProvidedServices;
import jadex.platform.service.servicepool.IServicePoolService;
import jadex.platform.service.servicepool.PoolServiceInfo;
import jadex.platform.service.servicepool.ServicePoolAgent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import jadex.bridge.service.annotation.Service;
import jadex.bridge.service.annotation.ServiceComponent;
import jadex.bridge.service.component.IRequiredServicesFeature;
import jadex.bridge.service.types.servicepool.IServicePoolService;
import jadex.commons.DefaultPoolStrategy;
import jadex.commons.future.DelegationResultListener;
import jadex.commons.future.ExceptionDelegationResultListener;
Expand All @@ -13,7 +14,6 @@
import jadex.commons.future.IIntermediateFuture;
import jadex.commons.future.IResultListener;
import jadex.commons.future.IntermediateFuture;
import jadex.platform.service.servicepool.IServicePoolService;

/**
* Implementation of the service that uses divide and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jadex.bridge.service.annotation.OnInit;
import jadex.bridge.service.annotation.Service;
import jadex.bridge.service.component.IRequiredServicesFeature;
import jadex.bridge.service.types.servicepool.IServicePoolService;
import jadex.commons.DefaultPoolStrategy;
import jadex.commons.future.DelegationResultListener;
import jadex.commons.future.ExceptionDelegationResultListener;
Expand All @@ -26,7 +27,6 @@
import jadex.micro.annotation.ProvidedServices;
import jadex.micro.annotation.RequiredService;
import jadex.micro.annotation.RequiredServices;
import jadex.platform.service.servicepool.IServicePoolService;

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jadex.platform.service.parallelizer;

import jadex.bridge.service.annotation.Service;
import jadex.bridge.service.types.servicepool.IServicePoolService;
import jadex.micro.annotation.Agent;
import jadex.micro.annotation.Component;
import jadex.micro.annotation.ComponentType;
Expand All @@ -12,7 +13,6 @@
import jadex.micro.annotation.ProvidedServices;
import jadex.micro.annotation.RequiredService;
import jadex.micro.annotation.RequiredServices;
import jadex.platform.service.servicepool.IServicePoolService;

/**
* Agent that wants to offer a service that delegates
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jadex.platform.service.parallelizer;

import jadex.bridge.IInternalAccess;
import jadex.bridge.service.types.servicepool.IServicePoolService;
import jadex.micro.annotation.Agent;
import jadex.micro.annotation.Argument;
import jadex.micro.annotation.Arguments;
Expand All @@ -11,7 +12,6 @@
import jadex.micro.annotation.Configurations;
import jadex.micro.annotation.RequiredService;
import jadex.micro.annotation.RequiredServices;
import jadex.platform.service.servicepool.IServicePoolService;

@Agent
@Arguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
import jadex.bridge.ProxyFactory;
import jadex.bridge.component.IArgumentsResultsFeature;
import jadex.bridge.service.IService;
import jadex.bridge.service.IServiceIdentifier;
import jadex.bridge.service.PublishInfo;
import jadex.bridge.service.ServiceScope;
import jadex.bridge.service.annotation.OnInit;
import jadex.bridge.service.annotation.Service;
import jadex.bridge.service.component.IProvidedServicesFeature;
import jadex.bridge.service.search.ServiceQuery;
import jadex.bridge.service.types.cms.CreationInfo;
import jadex.bridge.service.types.servicepool.IServicePoolService;
import jadex.commons.DefaultPoolStrategy;
import jadex.commons.IPoolStrategy;
import jadex.commons.future.CounterResultListener;
Expand Down Expand Up @@ -237,51 +236,6 @@ public IFuture<Integer> getFreeCapacity(Class<?> servicetype)
return new Future<Integer>(handler==null? 0: handler.getStrategy().getCapacity());
}

/**
* Test if a service is pooled.
* @param service The service.
* @return True, if it is a pooled service.
*/
public static IFuture<Boolean> isPooledService(IInternalAccess ia, IService service)
{
Future<Boolean> ret = new Future<Boolean>();
IServiceIdentifier sid = service.getServiceId();
ia.searchService(new ServiceQuery<IServicePoolService>(IServicePoolService.class).setProvider(sid.getProviderId()))
.then(ps -> ret.setResult(Boolean.TRUE))
.catchErr(ex -> ret.setResult(Boolean.FALSE));
return ret;
}

/**
* Test if a service is pooled.
* @param service The service.
* @return True, if it is a pooled service.
*/
public static IFuture<Integer> getMaxCapacity(IInternalAccess ia, IService service)
{
Future<Integer> ret = new Future<Integer>();
IServiceIdentifier sid = service.getServiceId();
ia.searchService(new ServiceQuery<IServicePoolService>(IServicePoolService.class).setProvider(sid.getProviderId()))
.then(ps -> ps.getMaxCapacity(sid.getServiceType().getType(ia.getClassLoader())).delegate(ret))
.catchErr(ex -> ret.setResult(-1));
return ret;
}

/**
* Test if a service is pooled.
* @param service The service.
* @return True, if it is a pooled service.
*/
public static IFuture<Integer> getFreeCapacity(IInternalAccess ia, IService service)
{
Future<Integer> ret = new Future<Integer>();
IServiceIdentifier sid = service.getServiceId();
ia.searchService(new ServiceQuery<IServicePoolService>(IServicePoolService.class).setProvider(sid.getProviderId()))
.then(ps -> ps.getFreeCapacity(sid.getServiceType().getType(ia.getClassLoader())).delegate(ret))
.catchErr(ex -> ret.setResult(-1));
return ret;
}

// Not necessary because service publication scope of workers is set to parent
// /**
// * Get the service container.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import jadex.bridge.service.search.ServiceQuery;
import jadex.bridge.service.types.cms.CreationInfo;
import jadex.bridge.service.types.monitoring.IMonitoringService.PublishEventLevel;
import jadex.bridge.service.types.servicepool.IServicePoolService;
import jadex.commons.future.CounterResultListener;
import jadex.commons.future.DelegationResultListener;
import jadex.commons.future.ExceptionDelegationResultListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import jadex.bridge.service.annotation.OnStart;
import jadex.bridge.service.annotation.Service;
import jadex.bridge.service.component.IRequiredServicesFeature;
import jadex.bridge.service.types.servicepool.IServicePoolService;
import jadex.commons.DefaultPoolStrategy;
import jadex.commons.MethodInfo;
import jadex.commons.future.DelegationResultListener;
Expand All @@ -29,7 +30,6 @@
import jadex.micro.annotation.RequiredServices;
import jadex.micro.annotation.Result;
import jadex.micro.annotation.Results;
import jadex.platform.service.servicepool.IServicePoolService;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import jadex.bridge.service.component.IRequiredServicesFeature;
import jadex.bridge.service.component.interceptors.CallAccess;
import jadex.bridge.service.search.ServiceQuery;
import jadex.bridge.service.types.servicepool.IServicePoolService;
import jadex.commons.DefaultPoolStrategy;
import jadex.commons.Tuple2;
import jadex.commons.future.CounterResultListener;
Expand Down
2 changes: 1 addition & 1 deletion platform/bridge/src/main/java/jadex/base/Starter.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ public static IFuture<IExternalAccess> createPlatform(final IPlatformConfigurati
// pass configuration parameters to static fields:
MethodInvocationInterceptor.DEBUG = getBooleanValueWithArgs(args, "debugservices", config.getExtendedPlatformConfiguration().getDebugServices());
ExecutionComponentFeature.DEBUG = getBooleanValueWithArgs(args, "debugsteps", config.getExtendedPlatformConfiguration().getDebugSteps());
// Future.NO_STACK_COMPACTION = true;
Future.NO_STACK_COMPACTION = getBooleanValueWithArgs(args, "nostackcompaction", config.getExtendedPlatformConfiguration().getNoStackCompaction());
// Future.NO_STACK_COMPACTION = true;
Future.DEBUG = getBooleanValueWithArgs(args, "debugfutures", config.getExtendedPlatformConfiguration().getDebugFutures());

// new FastClasspathScanner(new String[]
Expand Down

0 comments on commit b6769ca

Please sign in to comment.