本文整理汇总了Java中org.apache.falcon.entity.v0.Entity类的典型用法代码示例。如果您正苦于以下问题:Java Entity类的具体用法?Java Entity怎么用?Java Entity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Entity类属于org.apache.falcon.entity.v0包,在下文中一共展示了Entity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onAdd
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
@Override
public void onAdd(Entity entity) throws FalconException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasService.onAdd({})", entity);
}
try {
activatePluginClassLoader();
configChangeListenerImpl.onAdd(entity);
} finally {
deactivatePluginClassLoader();
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasService.onAdd({})", entity);
}
}
示例2: onRemove
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
@Override
public void onRemove(Entity entity) throws FalconException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasService.onRemove({})", entity);
}
try {
activatePluginClassLoader();
configChangeListenerImpl.onRemove(entity);
} finally {
deactivatePluginClassLoader();
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasService.onRemove({})", entity);
}
}
示例3: onChange
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
@Override
public void onChange(Entity entity, Entity entity1) throws FalconException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasService.onChange({}, {})", entity, entity1);
}
try {
activatePluginClassLoader();
configChangeListenerImpl.onChange(entity, entity1);
} finally {
deactivatePluginClassLoader();
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasService.onChange({}, {})", entity, entity1);
}
}
示例4: onReload
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
@Override
public void onReload(Entity entity) throws FalconException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> AtlasService.onReload({})", entity);
}
try {
activatePluginClassLoader();
configChangeListenerImpl.onReload(entity);
} finally {
deactivatePluginClassLoader();
}
if (LOG.isDebugEnabled()) {
LOG.debug("<== AtlasService.onReload({})", entity);
}
}
示例5: onAdd
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
@Override
public void onAdd(Entity entity) throws FalconException {
try {
EntityType entityType = entity.getEntityType();
switch (entityType) {
case CLUSTER:
addEntity(entity, FalconEvent.OPERATION.ADD_CLUSTER);
break;
case PROCESS:
addEntity(entity, FalconEvent.OPERATION.ADD_PROCESS);
break;
case FEED:
addEntity(entity, FalconEvent.OPERATION.ADD_FEED);
break;
default:
LOG.debug("Entity type not processed {}", entityType);
}
} catch(Throwable t) {
LOG.warn("Error handling entity {}", entity, t);
}
}
示例6: onChange
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
@Override
public void onChange(Entity oldEntity, Entity newEntity) throws FalconException {
/**
* Skipping update for now - update uses full update currently and this might result in all attributes wiped for hive entities
EntityType entityType = newEntity.getEntityType();
switch (entityType) {
case CLUSTER:
addEntity(newEntity, FalconEvent.OPERATION.UPDATE_CLUSTER);
break;
case PROCESS:
addEntity(newEntity, FalconEvent.OPERATION.UPDATE_PROCESS);
break;
case FEED:
FalconEvent.OPERATION operation = isReplicationFeed((Feed) newEntity) ?
FalconEvent.OPERATION.UPDATE_REPLICATION_FEED :
FalconEvent.OPERATION.UPDATE_FEED;
addEntity(newEntity, operation);
break;
default:
LOG.debug("Entity type not processed {}", entityType);
}
**/
}
示例7: loadEntity
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
private <T extends Entity> T loadEntity(EntityType type, String resource, String name) throws JAXBException {
Entity entity = (Entity) type.getUnmarshaller().unmarshal(this.getClass().getResourceAsStream(resource));
switch (entity.getEntityType()) {
case CLUSTER:
((Cluster) entity).setName(name);
break;
case FEED:
((Feed) entity).setName(name);
break;
case PROCESS:
((org.apache.falcon.entity.v0.process.Process) entity).setName(name);
break;
}
return (T)entity;
}
示例8: submitAndSchedule
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
/**
* Submits a new entity and schedules it immediately
*
* @param type
* @return
*/
public APIResult submitAndSchedule(
@Context HttpServletRequest request, @Dimension("entityType") @PathParam("type") String type,
@Dimension("colo") @PathParam("colo") String colo) {
checkColo(colo);
try {
checkSchedulableEntity(type);
audit(request, "STREAMED_DATA", type, "SUBMIT_AND_SCHEDULE");
Entity entity = submitInternal(request, type);
scheduleInternal(type, entity.getName());
return new APIResult(APIResult.Status.SUCCEEDED,
entity.getName() + "(" + type + ") scheduled successfully");
} catch (Throwable e) {
LOG.error("Unable to submit and schedule ", e);
throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
}
}
示例9: suspend
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
/**
* Suspends a running entity
*
* @param type
* @param entity
* @return APIResult
*/
public APIResult suspend(
@Context HttpServletRequest request, @Dimension("entityType") @PathParam("type") String type,
@Dimension("entityName") @PathParam("entity") String entity,
@Dimension("entityName") @PathParam("entity") String colo) {
checkColo(colo);
try {
checkSchedulableEntity(type);
audit(request, entity, type, "SUSPEND");
Entity entityObj = EntityUtil.getEntity(type, entity);
if (getWorkflowEngine().isActive(entityObj)) {
getWorkflowEngine().suspend(entityObj);
} else {
throw new FalconException(entity + "(" + type + ") is not scheduled");
}
return new APIResult(APIResult.Status.SUCCEEDED, entity + "(" + type + ") suspended successfully");
} catch (Throwable e) {
LOG.error("Unable to suspend entity", e);
throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
}
}
示例10: resume
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
/**
* Resumes a suspended entity
*
* @param type
* @param entity
* @return APIResult
*/
public APIResult resume(
@Context HttpServletRequest request, @Dimension("entityType") @PathParam("type") String type,
@Dimension("entityName") @PathParam("entity") String entity,
@Dimension("colo") @PathParam("colo") String colo) {
checkColo(colo);
try {
checkSchedulableEntity(type);
audit(request, entity, type, "RESUME");
Entity entityObj = EntityUtil.getEntity(type, entity);
if (getWorkflowEngine().isActive(entityObj)) {
getWorkflowEngine().resume(entityObj);
} else {
throw new FalconException(entity + "(" + type + ") is not scheduled");
}
return new APIResult(APIResult.Status.SUCCEEDED, entity + "(" + type + ") resumed successfully");
} catch (Throwable e) {
LOG.error("Unable to resume entity", e);
throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
}
}
示例11: getApplicableColos
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
protected Set<String> getApplicableColos(String type, Entity entity) throws FalconWebException {
try {
if (DeploymentUtil.isEmbeddedMode()) {
return DeploymentUtil.getDefaultColos();
}
if (EntityType.valueOf(type.toUpperCase()) == EntityType.CLUSTER) {
return getAllColos();
}
Set<String> clusters = EntityUtil.getClustersDefined(entity);
Set<String> colos = new HashSet<String>();
for (String cluster : clusters) {
Cluster clusterEntity = EntityUtil.getEntity(EntityType.CLUSTER, cluster);
colos.add(clusterEntity.getColo());
}
return colos;
} catch (FalconException e) {
throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
}
}
示例12: validateUpdate
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
private void validateUpdate(Entity oldEntity, Entity newEntity) throws FalconException {
if (oldEntity.getEntityType() != newEntity.getEntityType() || !oldEntity.equals(newEntity)) {
throw new FalconException(
oldEntity.toShortString() + " can't be updated with " + newEntity.toShortString());
}
if (oldEntity.getEntityType() == EntityType.CLUSTER) {
throw new FalconException("Update not supported for clusters");
}
String[] props = oldEntity.getEntityType().getImmutableProperties();
for (String prop : props) {
Object oldProp, newProp;
try {
oldProp = PropertyUtils.getProperty(oldEntity, prop);
newProp = PropertyUtils.getProperty(newEntity, prop);
} catch (Exception e) {
throw new FalconException(e);
}
if (!ObjectUtils.equals(oldProp, newProp)) {
throw new ValidationException(oldEntity.toShortString() + ": " + prop + " can't be changed");
}
}
}
示例13: submitInternal
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
protected synchronized Entity submitInternal(HttpServletRequest request, String type)
throws IOException, FalconException {
EntityType entityType = EntityType.valueOf(type.toUpperCase());
Entity entity = deserializeEntity(request, entityType);
Entity existingEntity = configStore.get(entityType, entity.getName());
if (existingEntity != null) {
if (EntityUtil.equals(existingEntity, entity)) {
return existingEntity;
}
throw new EntityAlreadyExistsException(
entity.toShortString() + " already registered with configuration store. "
+ "Can't be submitted again. Try removing before submitting.");
}
validate(entity);
configStore.publish(entityType, entity);
LOG.info("Submit successful: (" + type + ")" + entity.getName());
return entity;
}
示例14: getDependencies
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
/**
* Returns the list of entities registered of a given type.
*
* @param type
* @return String
*/
public EntityList getDependencies(String type) {
try {
EntityType entityType = EntityType.valueOf(type.toUpperCase());
Collection<String> entityNames = configStore.getEntities(entityType);
if (entityNames == null || entityNames.equals("")) {
return new EntityList(new Entity[]{});
}
Entity[] entities = new Entity[entityNames.size()];
int index = 0;
for (String entityName : entityNames) {
entities[index++] = configStore.get(entityType, entityName);
}
return new EntityList(entities);
} catch (Exception e) {
LOG.error("Unable to get list for entities for (" + type + ")", e);
throw FalconWebException.newException(e, Response.Status.BAD_REQUEST);
}
}
示例15: getLogs
import org.apache.falcon.entity.v0.Entity; //导入依赖的package包/类
public InstancesResult getLogs(String type, String entity, String startStr,
String endStr, String colo, String runId) {
try {
// TODO getStatus does all validations and filters clusters
InstancesResult result = getStatus(type, entity, startStr, endStr,
colo);
LogProvider logProvider = new LogProvider();
Entity entityObject = EntityUtil.getEntity(type, entity);
for (Instance instance : result.getInstances()) {
logProvider.populateLogUrls(entityObject, instance, runId);
}
return result;
} catch (Exception e) {
LOG.error("Failed to get logs for instances", e);
throw FalconWebException.newInstanceException(e,
Response.Status.BAD_REQUEST);
}
}