use of com.ctrip.framework.apollo.biz.entity.Namespace in project apollo by ctripcorp.
the class ReleaseController method publish.
@Transactional
@PostMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/gray-del-releases")
public ReleaseDTO publish(@PathVariable("appId") String appId, @PathVariable("clusterName") String clusterName, @PathVariable("namespaceName") String namespaceName, @RequestParam("operator") String operator, @RequestParam("releaseName") String releaseName, @RequestParam(name = "comment", required = false) String releaseComment, @RequestParam(name = "isEmergencyPublish", defaultValue = "false") boolean isEmergencyPublish, @RequestParam(name = "grayDelKeys") Set<String> grayDelKeys) {
Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName);
if (namespace == null) {
throw new NotFoundException("Could not find namespace for %s %s %s", appId, clusterName, namespaceName);
}
Release release = releaseService.grayDeletionPublish(namespace, releaseName, releaseComment, operator, isEmergencyPublish, grayDelKeys);
// send release message
Namespace parentNamespace = namespaceService.findParentNamespace(namespace);
String messageCluster;
if (parentNamespace != null) {
messageCluster = parentNamespace.getClusterName();
} else {
messageCluster = clusterName;
}
messageSender.sendMessage(ReleaseMessageKeyGenerator.generate(appId, messageCluster, namespaceName), Topics.APOLLO_RELEASE_TOPIC);
return BeanUtils.transform(ReleaseDTO.class, release);
}
use of com.ctrip.framework.apollo.biz.entity.Namespace in project apollo by ctripcorp.
the class NamespaceAcquireLockAspect method acquireLock.
void acquireLock(long namespaceId, String currentUser) {
if (bizConfig.isNamespaceLockSwitchOff()) {
return;
}
Namespace namespace = namespaceService.findOne(namespaceId);
acquireLock(namespace, currentUser);
}
use of com.ctrip.framework.apollo.biz.entity.Namespace in project apollo by ctripcorp.
the class NamespaceAcquireLockAspect method acquireLock.
void acquireLock(String appId, String clusterName, String namespaceName, String currentUser) {
if (bizConfig.isNamespaceLockSwitchOff()) {
return;
}
Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName);
acquireLock(namespace, currentUser);
}
use of com.ctrip.framework.apollo.biz.entity.Namespace in project apollo by ctripcorp.
the class NamespaceUnlockAspectTest method testNamespaceDeleteItem.
@Test
public void testNamespaceDeleteItem() {
long namespaceId = 1;
Namespace namespace = createNamespace(namespaceId);
Release release = createRelease("{\"k1\":\"v1\"}");
List<Item> items = Collections.singletonList(createItem("k2", "v2"));
when(releaseService.findLatestActiveRelease(namespace)).thenReturn(release);
when(itemService.findItemsWithoutOrdered(namespaceId)).thenReturn(items);
when(namespaceService.findParentNamespace(namespace)).thenReturn(null);
boolean isModified = namespaceUnlockAspect.isModified(namespace);
Assert.assertTrue(isModified);
}
use of com.ctrip.framework.apollo.biz.entity.Namespace in project apollo by ctripcorp.
the class NamespaceUnlockAspectTest method testNamespaceAddItem.
@Test
public void testNamespaceAddItem() {
long namespaceId = 1;
Namespace namespace = createNamespace(namespaceId);
Release release = createRelease("{\"k1\":\"v1\"}");
List<Item> items = Arrays.asList(createItem("k1", "v1"), createItem("k2", "v2"));
when(releaseService.findLatestActiveRelease(namespace)).thenReturn(release);
when(itemService.findItemsWithoutOrdered(namespaceId)).thenReturn(items);
when(namespaceService.findParentNamespace(namespace)).thenReturn(null);
boolean isModified = namespaceUnlockAspect.isModified(namespace);
Assert.assertTrue(isModified);
}
Aggregations