use of org.drools.compiler.kproject.ReleaseIdImpl in project drools by kiegroup.
the class KieModuleRepoTest method removeStoreArtifactMapTest.
// remove request followed by a store request on a high load system
// * remove does not completely finish before store starts
@Test(timeout = 5000)
public void removeStoreArtifactMapTest() throws Exception {
// actual test
final ReleaseIdImpl releaseId = new ReleaseIdImpl("org", "redeploy", "2.0");
final InternalKieModule originalKieModule = mock(InternalKieModule.class);
when(originalKieModule.getReleaseId()).thenReturn(releaseId);
when(originalKieModule.getCreationTimestamp()).thenReturn(0l);
final InternalKieModule redeployKieModule = mock(InternalKieModule.class);
when(redeployKieModule.getReleaseId()).thenReturn(releaseId);
when(redeployKieModule.getCreationTimestamp()).thenReturn(1l);
// 1. initial deploy ("long ago")
kieModuleRepo.store(originalKieModule);
final CyclicBarrier storeRemoveOperationBarrier = new CyclicBarrier(2);
final CyclicBarrier operationsSerializationBarrier = new CyclicBarrier(2);
final CyclicBarrier threadsFinishedBarrier = new CyclicBarrier(3);
final Runnable removeRunnable = () -> {
waitFor(storeRemoveOperationBarrier);
kieModuleRepo.remove(releaseId);
waitFor(operationsSerializationBarrier);
waitFor(threadsFinishedBarrier);
};
final Runnable redeployRunnable = () -> {
waitFor(storeRemoveOperationBarrier);
waitFor(operationsSerializationBarrier);
kieModuleRepo.store(redeployKieModule);
waitFor(threadsFinishedBarrier);
};
final ExecutorService executor = Executors.newFixedThreadPool(2);
// 2. remove and redploy
executor.submit(removeRunnable);
executor.submit(redeployRunnable);
try {
waitFor(threadsFinishedBarrier);
} finally {
executor.shutdownNow();
}
final String ga = releaseId.getGroupId() + ":" + releaseId.getArtifactId();
final Map<ComparableVersion, KieModule> artifactMap = kieModuleRepo.kieModules.get(ga);
assertNotNull("Artifact Map for GA '" + ga + "' not in KieModuleRepo!", artifactMap);
// never gets this far, but this is a good check
final KieModule redeployedKieModule = artifactMap.get(new ComparableVersion(releaseId.getVersion()));
assertNotNull("Redeployed module has disappeared from KieModuleRepo!", redeployedKieModule);
assertEquals("Original module retrieved instead of redeployed module!", 1l, redeployKieModule.getCreationTimestamp());
}
use of org.drools.compiler.kproject.ReleaseIdImpl in project drools by kiegroup.
the class KieModuleDeploymentHelperImpl method createKieJarAndDeployToMaven.
@Override
public void createKieJarAndDeployToMaven(String groupId, String artifactId, String version, String kbaseName, String ksessionName, List<String> resourceFilePaths, List<Class<?>> classesForKjar, List<String> dependencies) {
ReleaseId releaseId = new ReleaseIdImpl(groupId, artifactId, version);
internalCreateAndDeployKjarToMaven(releaseId, kbaseName, ksessionName, resourceFilePaths, classesForKjar, dependencies);
}
use of org.drools.compiler.kproject.ReleaseIdImpl in project drools by kiegroup.
the class KieRepositoryScannerImpl method buildArtifact.
private InternalKieModule buildArtifact(Artifact artifact, ArtifactResolver resolver) {
DependencyDescriptor dependencyDescriptor = new DependencyDescriptor(artifact);
ReleaseId releaseId = adapt(dependencyDescriptor.getReleaseId());
if (releaseId.isSnapshot()) {
((ReleaseIdImpl) releaseId).setSnapshotVersion(artifact.getVersion());
}
InternalKieModule kieModule = createKieModule(releaseId, artifact.getFile());
if (kieModule != null) {
addDependencies(kieModule, resolver, resolver.getArtifactDependecies(dependencyDescriptor.toString()));
kieModule.build();
}
return kieModule;
}
Aggregations