-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #546 from eclipse-passage/568632-3
Bug 568632 Implement feature grant acquire/release
- Loading branch information
Showing
12 changed files
with
219 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...clipse.passage.lic.hc/src/org/eclipse/passage/lic/internal/hc/remote/impl/ServiceAny.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.internal.hc.remote.impl; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
import org.eclipse.passage.lic.floating.model.api.FloatingLicenseAccess; | ||
import org.eclipse.passage.lic.internal.api.ServiceInvocationResult; | ||
import org.eclipse.passage.lic.internal.api.diagnostic.Diagnostic; | ||
import org.eclipse.passage.lic.internal.api.io.KeyKeeperRegistry; | ||
import org.eclipse.passage.lic.internal.api.io.StreamCodecRegistry; | ||
import org.eclipse.passage.lic.internal.base.BaseServiceInvocationResult; | ||
import org.eclipse.passage.lic.internal.base.diagnostic.BaseDiagnostic; | ||
import org.eclipse.passage.lic.internal.base.diagnostic.NoSevereErrors; | ||
import org.eclipse.passage.lic.internal.base.diagnostic.SumOfDiagnostics; | ||
|
||
public abstract class ServiceAny<T, D extends RemoteServiceData> extends ServiceRemote<T, D> { | ||
|
||
protected ServiceAny(KeyKeeperRegistry keys, StreamCodecRegistry codecs) { | ||
super(keys, codecs); | ||
} | ||
|
||
@Override | ||
protected final ServiceInvocationResult<T> withServers(D parameters, Collection<FloatingLicenseAccess> servers) { | ||
List<Diagnostic> diagnostics = new ArrayList<>(); | ||
return servers.stream()// | ||
.map(server -> withServer(parameters, server))// | ||
.peek(result -> diagnostics.add(result.diagnostic())) // | ||
.filter(result -> new NoSevereErrors().test(result.diagnostic()))// | ||
.filter(result -> result.data().isPresent())// | ||
.findFirst()// | ||
.orElse(new BaseServiceInvocationResult<>(sum(diagnostics))); | ||
} | ||
|
||
private Diagnostic sum(List<Diagnostic> particles) { | ||
return particles.stream()// | ||
.reduce(new SumOfDiagnostics())// | ||
.orElseGet(BaseDiagnostic::new); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
...ipse.passage.lic.hc/src/org/eclipse/passage/lic/internal/hc/remote/impl/ServiceEvery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.internal.hc.remote.impl; | ||
|
||
import java.util.Collection; | ||
import java.util.function.BinaryOperator; | ||
|
||
import org.eclipse.passage.lic.floating.model.api.FloatingLicenseAccess; | ||
import org.eclipse.passage.lic.internal.api.ServiceInvocationResult; | ||
import org.eclipse.passage.lic.internal.api.io.KeyKeeperRegistry; | ||
import org.eclipse.passage.lic.internal.api.io.StreamCodecRegistry; | ||
import org.eclipse.passage.lic.internal.base.BaseServiceInvocationResult; | ||
|
||
public abstract class ServiceEvery<T, D extends RemoteServiceData> extends ServiceRemote<T, D> { | ||
|
||
protected ServiceEvery(KeyKeeperRegistry keys, StreamCodecRegistry codecs) { | ||
super(keys, codecs); | ||
} | ||
|
||
@Override | ||
protected ServiceInvocationResult<T> withServers(D params, Collection<FloatingLicenseAccess> servers) { | ||
return servers.stream()// | ||
.map(access -> withServer(params, access))// | ||
.reduce(new BaseServiceInvocationResult.Sum<>(sum()))// | ||
.orElse(new BaseServiceInvocationResult<>(noResult())); | ||
} | ||
|
||
protected abstract BinaryOperator<T> sum(); | ||
|
||
protected abstract T noResult(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
....lic.hc/src/org/eclipse/passage/lic/internal/hc/remote/impl/acquire/OfFeatureRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.internal.hc.remote.impl.acquire; | ||
|
||
import java.util.function.BiFunction; | ||
|
||
import org.eclipse.passage.lic.floating.model.api.FloatingLicenseAccess; | ||
import org.eclipse.passage.lic.internal.hc.remote.impl.RemoteRequest; | ||
import org.eclipse.passage.lic.internal.hc.remote.impl.RemoteServiceData; | ||
import org.eclipse.passage.lic.internal.hc.remote.impl.RemoteServiceData.OfFeature; | ||
import org.eclipse.passage.lic.internal.hc.remote.impl.RequestParameters; | ||
|
||
final class OfFeatureRequest extends RemoteRequest { | ||
|
||
private final OfFeature data; | ||
private final BiFunction<RemoteServiceData.OfFeature, FloatingLicenseAccess, RequestParameters> parameters; | ||
|
||
OfFeatureRequest(OfFeature data, FloatingLicenseAccess access, | ||
BiFunction<RemoteServiceData.OfFeature, FloatingLicenseAccess, RequestParameters> parameters) { | ||
super(data.product(), access); | ||
this.data = data; | ||
this.parameters = parameters; | ||
} | ||
|
||
@Override | ||
protected RequestParameters parameters() { | ||
return parameters.apply(data, access); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.