本文整理汇总了Java中org.apache.falcon.entity.v0.Entity.getEntityType方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.getEntityType方法的具体用法?Java Entity.getEntityType怎么用?Java Entity.getEntityType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.falcon.entity.v0.Entity
的用法示例。
在下文中一共展示了Entity.getEntityType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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;
}
示例3: 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");
}
}
}
示例4: getRetry
import org.apache.falcon.entity.v0.Entity; //导入方法依赖的package包/类
public static Retry getRetry(Entity entity) throws FalconException {
switch (entity.getEntityType()) {
case FEED:
if (!RuntimeProperties.get()
.getProperty("feed.retry.allowed", "true")
.equalsIgnoreCase("true")) {
return null;
}
Retry retry = new Retry();
retry.setAttempts(Integer.parseInt(RuntimeProperties.get()
.getProperty("feed.retry.attempts", "3")));
retry.setDelay(new Frequency(RuntimeProperties.get().getProperty(
"feed.retry.frequency", "minutes(5)")));
retry.setPolicy(PolicyType.fromValue(RuntimeProperties.get()
.getProperty("feed.retry.policy", "exp-backoff")));
return retry;
case PROCESS:
Process process = (Process) entity;
return process.getRetry();
default:
throw new FalconException("Cannot create Retry for entity:" + entity.getName());
}
}
示例5: canRemove
import org.apache.falcon.entity.v0.Entity; //导入方法依赖的package包/类
private void canRemove(Entity entity) throws FalconException {
Pair<String, EntityType>[] referencedBy = EntityIntegrityChecker.referencedBy(entity);
if (referencedBy != null && referencedBy.length > 0) {
StringBuffer messages = new StringBuffer();
for (Pair<String, EntityType> ref : referencedBy) {
messages.append(ref).append("\n");
}
throw new FalconException(
entity.getName() + "(" + entity.getEntityType() + ") cant " + "be removed as it is referred by "
+ messages);
}
}
示例6: validateDateRangeFor
import org.apache.falcon.entity.v0.Entity; //导入方法依赖的package包/类
private void validateDateRangeFor(Entity entity, Pair<Date, String> clusterMinStart,
Pair<Date, String> clusterMaxEnd, String start, String end)
throws FalconException {
Date instStart = EntityUtil.parseDateUTC(start);
if (instStart.before(clusterMinStart.first)) {
throw new ValidationException("Start date " + start + " is before "
+ entity.getEntityType() + "'s start "
+ SchemaHelper.formatDateUTC(clusterMinStart.first)
+ " for cluster " + clusterMinStart.second);
}
if (StringUtils.isNotEmpty(end)) {
Date instEnd = EntityUtil.parseDateUTC(end);
if (instStart.after(instEnd)) {
throw new ValidationException("Start date " + start
+ " is after end date " + end);
}
if (instEnd.after(clusterMaxEnd.first)) {
throw new ValidationException("End date " + end + " is after "
+ entity.getEntityType() + "'s end "
+ SchemaHelper.formatDateUTC(clusterMaxEnd.first)
+ " for cluster " + clusterMaxEnd.second);
}
} else if (instStart.after(clusterMaxEnd.first)) {
throw new ValidationException("Start date " + start + " is after "
+ entity.getEntityType() + "'s end "
+ SchemaHelper.formatDateUTC(clusterMaxEnd.first)
+ " for cluster " + clusterMaxEnd.second);
}
}
示例7: onAdd
import org.apache.falcon.entity.v0.Entity; //导入方法依赖的package包/类
@Override
public void onAdd(Entity entity) throws FalconException {
if (entity.getEntityType() != EntityType.CLUSTER) {
return;
}
Cluster cluster = (Cluster) entity;
String currentColo = DeploymentUtil.getCurrentColo();
if (DeploymentUtil.isEmbeddedMode() || currentColo.equals(cluster.getColo())) {
addLibsTo(cluster);
}
}
示例8: onChange
import org.apache.falcon.entity.v0.Entity; //导入方法依赖的package包/类
@Override
public void onChange(Entity oldEntity, Entity newEntity) throws FalconException {
if (oldEntity.getEntityType() != EntityType.CLUSTER) {
return;
}
Cluster oldCluster = (Cluster) oldEntity;
Cluster newCluster = (Cluster) newEntity;
if (!ClusterHelper.getInterface(oldCluster, Interfacetype.WRITE).getEndpoint()
.equals(ClusterHelper.getInterface(newCluster, Interfacetype.WRITE).getEndpoint())
|| !ClusterHelper.getInterface(oldCluster, Interfacetype.WORKFLOW).getEndpoint()
.equals(ClusterHelper.getInterface(newCluster, Interfacetype.WORKFLOW).getEndpoint())) {
addLibsTo(newCluster);
}
}
示例9: findProcesses
import org.apache.falcon.entity.v0.Entity; //导入方法依赖的package包/类
private Set<Process> findProcesses(Set<Entity> referenced) {
Set<Process> processes = new HashSet<Process>();
for (Entity entity : referenced) {
if (entity.getEntityType() == EntityType.PROCESS) {
processes.add((Process) entity);
}
}
return processes;
}
示例10: shouldUpdate
import org.apache.falcon.entity.v0.Entity; //导入方法依赖的package包/类
public static boolean shouldUpdate(Entity oldEntity, Entity newEntity, Entity affectedEntity)
throws FalconException {
if (oldEntity.getEntityType() == EntityType.FEED && affectedEntity.getEntityType() == EntityType.PROCESS) {
return shouldUpdate((Feed) oldEntity, (Feed) newEntity, (Process) affectedEntity);
} else {
LOG.debug(newEntity.toShortString());
LOG.debug(affectedEntity.toShortString());
throw new FalconException("Don't know what to do. Unexpected scenario");
}
}
示例11: onRemove
import org.apache.falcon.entity.v0.Entity; //导入方法依赖的package包/类
@Override
public void onRemove(Entity entity) {
if (entity.getEntityType() != EntityType.CLUSTER) {
return;
}
Cluster cluster = (Cluster) entity;
COLO_CLUSTER_MAP.get(cluster.getColo()).remove(cluster.getName());
if (COLO_CLUSTER_MAP.get(cluster.getColo()).isEmpty()) {
COLO_CLUSTER_MAP.remove(cluster.getColo());
}
}
示例12: onChange
import org.apache.falcon.entity.v0.Entity; //导入方法依赖的package包/类
@Override
public void onChange(Entity oldEntity, Entity newEntity) throws FalconException {
if (oldEntity.getEntityType() != EntityType.CLUSTER) {
return;
}
throw new FalconException("change shouldn't be supported on cluster!");
}
示例13: getEndTime
import org.apache.falcon.entity.v0.Entity; //导入方法依赖的package包/类
public static Date getEndTime(Entity entity, String cluster) {
if (entity.getEntityType() == EntityType.PROCESS) {
return getEndTime((Process) entity, cluster);
} else {
return getEndTime((Feed) entity, cluster);
}
}
示例14: getStartTime
import org.apache.falcon.entity.v0.Entity; //导入方法依赖的package包/类
public static Date getStartTime(Entity entity, String cluster) {
if (entity.getEntityType() == EntityType.PROCESS) {
return getStartTime((Process) entity, cluster);
} else {
return getStartTime((Feed) entity, cluster);
}
}
示例15: getParallel
import org.apache.falcon.entity.v0.Entity; //导入方法依赖的package包/类
public static int getParallel(Entity entity) {
if (entity.getEntityType() == EntityType.PROCESS) {
return getParallel((Process) entity);
} else {
return getParallel((Feed) entity);
}
}