Search in sources :

Example 1 with TenantAwareFunction0

use of io.spine.server.tenant.TenantAwareFunction0 in project core-java by SpineEventEngine.

the class Rescheduler method rescheduleForTenant.

private void rescheduleForTenant(final TenantId tenantId) {
    final TenantAwareFunction0<Iterator<Command>> func = new TenantAwareFunction0<Iterator<Command>>(tenantId) {

        @Override
        public Iterator<Command> apply() {
            return commandStore().iterator(SCHEDULED);
        }
    };
    final Iterator<Command> commands = func.execute(Empty.getDefaultInstance());
    final TenantAwareOperation op = new TenantAwareOperation(tenantId) {

        @Override
        public void run() {
            while (commands.hasNext()) {
                final Command command = commands.next();
                reschedule(command);
            }
        }
    };
    op.execute();
}
Also used : Command(io.spine.base.Command) TenantAwareFunction0(io.spine.server.tenant.TenantAwareFunction0) Iterator(java.util.Iterator) TenantAwareOperation(io.spine.server.tenant.TenantAwareOperation)

Aggregations

Command (io.spine.base.Command)1 TenantAwareFunction0 (io.spine.server.tenant.TenantAwareFunction0)1 TenantAwareOperation (io.spine.server.tenant.TenantAwareOperation)1 Iterator (java.util.Iterator)1