private static InotifyProtos.MetadataUpdateType metadataUpdateTypeConvert( Event.MetadataUpdateEvent.MetadataType type) { switch (type) { case TIMES: return InotifyProtos.MetadataUpdateType.META_TYPE_TIMES; case REPLICATION: return InotifyProtos.MetadataUpdateType.META_TYPE_REPLICATION; case OWNER: return InotifyProtos.MetadataUpdateType.META_TYPE_OWNER; case PERMS: return InotifyProtos.MetadataUpdateType.META_TYPE_PERMS; case ACLS: return InotifyProtos.MetadataUpdateType.META_TYPE_ACLS; case XATTRS: return InotifyProtos.MetadataUpdateType.META_TYPE_XATTRS; default: return null; } }
private static Event.MetadataUpdateEvent.MetadataType metadataUpdateTypeConvert( InotifyProtos.MetadataUpdateType type) { switch (type) { case META_TYPE_TIMES: return Event.MetadataUpdateEvent.MetadataType.TIMES; case META_TYPE_REPLICATION: return Event.MetadataUpdateEvent.MetadataType.REPLICATION; case META_TYPE_OWNER: return Event.MetadataUpdateEvent.MetadataType.OWNER; case META_TYPE_PERMS: return Event.MetadataUpdateEvent.MetadataType.PERMS; case META_TYPE_ACLS: return Event.MetadataUpdateEvent.MetadataType.ACLS; case META_TYPE_XATTRS: return Event.MetadataUpdateEvent.MetadataType.XATTRS; default: return null; } }
static InotifyProtos.MetadataUpdateType metadataUpdateTypeConvert( Event.MetadataUpdateEvent.MetadataType type) { switch (type) { case TIMES: return InotifyProtos.MetadataUpdateType.META_TYPE_TIMES; case REPLICATION: return InotifyProtos.MetadataUpdateType.META_TYPE_REPLICATION; case OWNER: return InotifyProtos.MetadataUpdateType.META_TYPE_OWNER; case PERMS: return InotifyProtos.MetadataUpdateType.META_TYPE_PERMS; case ACLS: return InotifyProtos.MetadataUpdateType.META_TYPE_ACLS; case XATTRS: return InotifyProtos.MetadataUpdateType.META_TYPE_XATTRS; default: return null; } }
private static Event.CreateEvent.INodeType createTypeConvert(InotifyProtos.INodeType type) { switch (type) { case I_TYPE_DIRECTORY: return Event.CreateEvent.INodeType.DIRECTORY; case I_TYPE_FILE: return Event.CreateEvent.INodeType.FILE; case I_TYPE_SYMLINK: return Event.CreateEvent.INodeType.SYMLINK; default: return null; } }
private static InotifyProtos.INodeType createTypeConvert(Event.CreateEvent.INodeType type) { switch (type) { case DIRECTORY: return InotifyProtos.INodeType.I_TYPE_DIRECTORY; case FILE: return InotifyProtos.INodeType.I_TYPE_FILE; case SYMLINK: return InotifyProtos.INodeType.I_TYPE_SYMLINK; default: return null; } }
static InotifyProtos.INodeType createTypeConvert(Event.CreateEvent.INodeType type) { switch (type) { case DIRECTORY: return InotifyProtos.INodeType.I_TYPE_DIRECTORY; case FILE: return InotifyProtos.INodeType.I_TYPE_FILE; case SYMLINK: return InotifyProtos.INodeType.I_TYPE_SYMLINK; default: return null; } }
private static Event.CreateEvent.INodeType createTypeConvert( InotifyProtos.INodeType type) { switch (type) { case I_TYPE_DIRECTORY: return Event.CreateEvent.INodeType.DIRECTORY; case I_TYPE_FILE: return Event.CreateEvent.INodeType.FILE; case I_TYPE_SYMLINK: return Event.CreateEvent.INodeType.SYMLINK; default: return null; } }
public static EventsList convert(GetEditsFromTxidResponseProto resp) throws IOException { List<Event> events = Lists.newArrayList(); for (InotifyProtos.EventProto p : resp.getEventsList().getEventsList()) { switch(p.getType()) { case EVENT_CLOSE: InotifyProtos.CloseEventProto close = InotifyProtos.CloseEventProto.parseFrom(p.getContents()); events.add(new Event.CloseEvent(close.getPath(), close.getFileSize(), close.getTimestamp())); break; case EVENT_CREATE: InotifyProtos.CreateEventProto create = InotifyProtos.CreateEventProto.parseFrom(p.getContents()); events.add(new Event.CreateEvent.Builder() .iNodeType(createTypeConvert(create.getType())) .path(create.getPath()) .ctime(create.getCtime()) .ownerName(create.getOwnerName()) .groupName(create.getGroupName()) .perms(convert(create.getPerms())) .replication(create.getReplication()) .symlinkTarget(create.getSymlinkTarget().isEmpty() ? null : create.getSymlinkTarget()) .overwrite(create.getOverwrite()).build()); break; case EVENT_METADATA: InotifyProtos.MetadataUpdateEventProto meta = InotifyProtos.MetadataUpdateEventProto.parseFrom(p.getContents()); events.add(new Event.MetadataUpdateEvent.Builder() .path(meta.getPath()) .metadataType(metadataUpdateTypeConvert(meta.getType())) .mtime(meta.getMtime()) .atime(meta.getAtime()) .replication(meta.getReplication()) .ownerName( meta.getOwnerName().isEmpty() ? null : meta.getOwnerName()) .groupName( meta.getGroupName().isEmpty() ? null : meta.getGroupName()) .perms(meta.hasPerms() ? convert(meta.getPerms()) : null) .acls(meta.getAclsList().isEmpty() ? null : convertAclEntry( meta.getAclsList())) .xAttrs(meta.getXAttrsList().isEmpty() ? null : convertXAttrs( meta.getXAttrsList())) .xAttrsRemoved(meta.getXAttrsRemoved()) .build()); break; case EVENT_RENAME: InotifyProtos.RenameEventProto rename = InotifyProtos.RenameEventProto.parseFrom(p.getContents()); events.add(new Event.RenameEvent(rename.getSrcPath(), rename.getDestPath(), rename.getTimestamp())); break; case EVENT_APPEND: InotifyProtos.AppendEventProto reopen = InotifyProtos.AppendEventProto.parseFrom(p.getContents()); events.add(new Event.AppendEvent(reopen.getPath())); break; case EVENT_UNLINK: InotifyProtos.UnlinkEventProto unlink = InotifyProtos.UnlinkEventProto.parseFrom(p.getContents()); events.add(new Event.UnlinkEvent(unlink.getPath(), unlink.getTimestamp())); break; default: throw new RuntimeException("Unexpected inotify event type: " + p.getType()); } } return new EventsList(events, resp.getEventsList().getFirstTxid(), resp.getEventsList().getLastTxid(), resp.getEventsList().getSyncTxid()); }