Skip to content

Commit

Permalink
Merge branch 'feature_cmdb' into 0.7.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	api/pom.xml
#	api/src/main/java/com/alibaba/nacos/api/exception/NacosException.java
#	client/pom.xml
#	client/src/main/java/com/alibaba/nacos/client/config/impl/HttpSimpleClient.java
#	client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java
#	common/pom.xml
#	config/pom.xml
#	console/pom.xml
#	core/pom.xml
#	distribution/conf/application.properties
#	distribution/conf/nacos-logback.xml
#	distribution/pom.xml
#	distribution/release-nacos.xml
#	example/pom.xml
#	naming/pom.xml
#	naming/src/main/java/com/alibaba/nacos/naming/web/ApiCommands.java
#	pom.xml
#	test/pom.xml
  • Loading branch information
nkorange committed Dec 14, 2018
2 parents e623384 + 7a64ce2 commit d2e4f4e
Show file tree
Hide file tree
Showing 56 changed files with 2,126 additions and 456 deletions.
52 changes: 52 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/cmdb/pojo/Entity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.api.cmdb.pojo;

import java.util.Map;

/**
* @author <a href="mailto:[email protected]">nkorange</a>
*/
public class Entity {

private String type;
private String name;
private Map<String, String> labels;

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Map<String, String> getLabels() {
return labels;
}

public void setLabels(Map<String, String> labels) {
this.labels = labels;
}
}
50 changes: 50 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/cmdb/pojo/EntityEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.api.cmdb.pojo;

/**
* @author <a href="mailto:[email protected]">nkorange</a>
*/
public class EntityEvent {

private EntityEventType type;
private String entityName;
private String entityType;

public EntityEventType getType() {
return type;
}

public void setType(EntityEventType type) {
this.type = type;
}

public String getEntityName() {
return entityName;
}

public void setEntityName(String entityName) {
this.entityName = entityName;
}

public String getEntityType() {
return entityType;
}

public void setEntityType(String entityType) {
this.entityType = entityType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.api.cmdb.pojo;

/**
* @author <a href="mailto:[email protected]">nkorange</a>
*/
public enum EntityEventType {
/**
*
*/
ENTITY_ADD_OR_UPDATE,
/**
*
*/
ENTITY_REMOVE
}
52 changes: 52 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/cmdb/pojo/Label.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.api.cmdb.pojo;

import java.util.Set;

/**
* @author <a href="mailto:[email protected]">nkorange</a>
*/
public class Label {

private String name;
private Set<String> values;
private String description;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Set<String> getValues() {
return values;
}

public void setValues(Set<String> values) {
this.values = values;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.api.cmdb.pojo;

/**
* @author <a href="mailto:[email protected]">nkorange</a>
*/
public enum PreservedEntityTypes {
/**
*
*/
ip,
/**
*
*/
service
}
97 changes: 97 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/cmdb/spi/CmdbService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.api.cmdb.spi;

import com.alibaba.nacos.api.cmdb.pojo.Entity;
import com.alibaba.nacos.api.cmdb.pojo.EntityEvent;
import com.alibaba.nacos.api.cmdb.pojo.Label;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* Service to visit CMDB store
*
* @author <a href="mailto:[email protected]">nkorange</a>
*/
public interface CmdbService {

/**
* Get all label names stored in CMDB
*
* @return label name set
*/
Set<String> getLabelNames();

/**
* Get all possible entity types in CMDB
*
* @return all entity types
*/
Set<String> getEntityTypes();

/**
* Get label info
*
* @param labelName label name
* @return label info
*/
Label getLabel(String labelName);

/**
* Get label value of label name of ip
*
* @param entityType entity type
* @param entityValue entity value
* @param labelName target label name
* @return label value
*/
String getLabelValue(String entityValue, String entityType, String labelName);

/**
* Get all label value of ip
*
* @param entityType entity type
* @param entityValue entity value
* @return all label values
*/
Map<String, String> getLabelValues(String entityValue, String entityType);

/**
* Dump all entities in CMDB
*
* @return all entities
*/
Map<String, Map<String, Entity>> getAllEntities();

/**
* get label change events
*
* @param timestamp start time of generated events
* @return label events
*/
List<EntityEvent> getEntityEvents(long timestamp);

/**
* Get single entity
*
* @param entityName name of entity
* @param entityType type of entity
* @return
*/
Entity getEntity(String entityName, String entityType);
}
12 changes: 12 additions & 0 deletions api/src/main/java/com/alibaba/nacos/api/naming/NamingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ListView;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
import com.alibaba.nacos.api.selector.AbstractSelector;

import java.util.List;

Expand Down Expand Up @@ -186,6 +187,17 @@ public interface NamingService {
*/
ListView<String> getServicesOfServer(int pageNo, int pageSize) throws NacosException;

/**
* Get all service names from server
*
* @param pageNo page index
* @param pageSize page size
* @param selector selector to filter the resource
* @return list of service names
* @throws NacosException
*/
ListView<String> getServicesOfServer(int pageNo, int pageSize, AbstractSelector selector) throws NacosException;

/**
* Get all subscribed services of current client
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package com.alibaba.nacos.api.naming.pojo;

import com.alibaba.nacos.api.common.Constants;

import java.util.HashMap;
import java.util.Map;

Expand Down
19 changes: 17 additions & 2 deletions api/src/main/java/com/alibaba/nacos/api/naming/pojo/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.api.naming.pojo;

import com.alibaba.nacos.api.selector.AbstractSelector;

import java.util.HashMap;
import java.util.Map;

Expand All @@ -39,15 +41,20 @@ public class Service {
private String app;

/**
* Service group is meant to classify services into different sets.
* Service group is meant to classify services into different sets
*/
private String group;

/**
* Health check mode.
* Health check mode
*/
private String healthCheckMode;

/**
* Selector name of this service
*/
private AbstractSelector selector;

private Map<String, String> metadata = new HashMap<String, String>();

public Service(String name) {
Expand Down Expand Up @@ -105,4 +112,12 @@ public void setMetadata(Map<String, String> metadata) {
public void addMetadata(String key, String value) {
this.metadata.put(key, value);
}

public AbstractSelector getSelector() {
return selector;
}

public void setSelector(AbstractSelector selector) {
this.selector = selector;
}
}
Loading

0 comments on commit d2e4f4e

Please sign in to comment.