EntityIdentifier entity = new EntityIdentifier(entityId, entityType); } else { byte[] b = createStartTimeLookupKey(entity.getId(), entity.getType()); byte[] v = starttimedb.get(b); if (v == null) {
@Override public V get(K entityId) { V result = null; // Read the start time from the index byte[] startTimeBytes = entityDb.get(getStartTimeKey(entityId)); if (startTimeBytes == null) { return null; } // Build the key for the entity storage and read it try { result = getEntityForKey(getEntityKey(entityId, startTimeBytes)); } catch (IOException e) { LOG.error("GenericObjectMapper cannot read key from key " + entityId.toString() + " into an object. Read aborted! "); LOG.error(e.getMessage()); } return result; }
@Override public synchronized TimelineEntity getEntity(String entityId, String entityType, EnumSet<Field> fieldsToRetrieve) { if (fieldsToRetrieve == null) { fieldsToRetrieve = EnumSet.allOf(Field.class); } TimelineEntity entity = entities.get(new EntityIdentifier(entityId, entityType)); if (entity == null) { return null; } else { return maskFields(entity, fieldsToRetrieve); } }
startTimeMap.put(startTime, entities); entities.add(new EntityIdentifier(entityId, entityType)); for (EntityIdentifier entityIdentifier : entry.getValue()) { EventsOfOneEntity entity = new EventsOfOneEntity(); entity.setEntityId(entityIdentifier.getId()); entity.setEntityType(entityType); events.addEvent(entity); KeyBuilder kb = KeyBuilder.newInstance().add(ENTITY_ENTRY_PREFIX) .add(entityType).add(revStartTime).add(entityIdentifier.getId()) .add(EVENTS_COLUMN); byte[] prefix = kb.getBytesForLookup();
entityPrefixKeyBuilder.add(startTimeBytes, true); if (startId != null) { entityPrefixKeyBuilder.add(startId.getId());
@Override public synchronized TimelineEntity getEntity(String entityId, String entityType, EnumSet<Field> fieldsToRetrieve) { if (fieldsToRetrieve == null) { fieldsToRetrieve = EnumSet.allOf(Field.class); } TimelineEntity entity = entities.get(new EntityIdentifier(entityId, entityType)); if (entity == null) { return null; } else { return maskFields(entity, fieldsToRetrieve); } }
private byte[] getEntityKey(K entityId, byte[] startTimeBytes) { LeveldbUtils.KeyBuilder entityKeyBuilder = LeveldbUtils.KeyBuilder.newInstance(); entityKeyBuilder.add(ENTITY_STORAGE_PREFIX).add(startTimeBytes, true) .add(entityId.getId()).add(entityId.getType()); return entityKeyBuilder.getBytes(); } }
startTimeMap.put(startTime, entities); entities.add(new EntityIdentifier(entityId, entityType)); for (EntityIdentifier entityIdentifier : entry.getValue()) { EventsOfOneEntity entity = new EventsOfOneEntity(); entity.setEntityId(entityIdentifier.getId()); entity.setEntityType(entityType); events.addEvent(entity); KeyBuilder kb = KeyBuilder.newInstance().add(ENTITY_ENTRY_PREFIX) .add(entityType).add(revStartTime).add(entityIdentifier.getId()) .add(EVENTS_COLUMN); byte[] prefix = kb.getBytesForLookup();
EntityIdentifier entity = new EntityIdentifier(entityId, entityType); try { } else { byte[] b = createStartTimeLookupKey(entity.getId(), entity.getType()); byte[] v = db.get(b); if (v == null) {
public boolean check(TimelineEntity entity) throws IOException { try{ return timelineACLsManager.checkAccess( ugi, ApplicationAccessType.VIEW_APP, entity); } catch (YarnException e) { LOG.info("Error when verifying access for user " + ugi + " on the events of the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType()), e); return false; } } }
startTimeMap.put(startTime, entities); entities.add(new EntityIdentifier(entityId, entityType)); for (EntityIdentifier entityIdentifier : entry.getValue()) { EventsOfOneEntity entity = new EventsOfOneEntity(); entity.setEntityId(entityIdentifier.getId()); entity.setEntityType(entityType); events.addEvent(entity); KeyBuilder kb = KeyBuilder.newInstance().add(entityType) .add(revStartTime).add(entityIdentifier.getId()) .add(EVENTS_COLUMN); byte[] prefix = kb.getBytesForLookup();
EntityIdentifier entity = new EntityIdentifier(entityId, entityType); try { } else { byte[] b = createStartTimeLookupKey(entity.getId(), entity.getType()); byte[] v = db.get(b); if (v == null) {
public boolean check(TimelineEntity entity) throws IOException { try{ return timelineACLsManager.checkAccess( ugi, ApplicationAccessType.VIEW_APP, entity); } catch (YarnException e) { LOG.info("Error when verifying access for user " + ugi + " on the events of the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType()), e); return false; } } }
startTimeMap.put(startTime, entities); entities.add(new EntityIdentifier(entityId, entityType)); for (EntityIdentifier entityIdentifier : entry.getValue()) { EventsOfOneEntity entity = new EventsOfOneEntity(); entity.setEntityId(entityIdentifier.getId()); entity.setEntityType(entityType); events.addEvent(entity); KeyBuilder kb = KeyBuilder.newInstance().add(ENTITY_ENTRY_PREFIX) .add(entityType).add(revStartTime).add(entityIdentifier.getId()) .add(EVENTS_COLUMN); byte[] prefix = kb.getBytesForLookup();
EntityIdentifier entity = new EntityIdentifier(entityId, entityType); try { } else { byte[] b = createStartTimeLookupKey(entity.getId(), entity.getType()); byte[] v = db.get(b); if (v == null) {
public boolean check(TimelineEntity entity) throws IOException { try{ return timelineACLsManager.checkAccess( ugi, ApplicationAccessType.VIEW_APP, entity); } catch (YarnException e) { LOG.info("Error when verifying access for user " + ugi + " on the events of the timeline entity " + new EntityIdentifier(entity.getEntityId(), entity.getEntityType()), e); return false; } } }
@Override public void remove(K entityId) { // Read the start time from the index (key starts with an "i") then delete // the record LeveldbUtils.KeyBuilder startTimeKeyBuilder = LeveldbUtils.KeyBuilder.newInstance(); startTimeKeyBuilder.add(TIME_INDEX_PREFIX).add(entityId.getId()) .add(entityId.getType()); byte[] startTimeBytes = entityDb.get(startTimeKeyBuilder.getBytes()); if (startTimeBytes == null) { return; } entityDb.delete(startTimeKeyBuilder.getBytes()); // Build the key for the entity storage and delete it entityDb.delete(getEntityKey(entityId, startTimeBytes)); }