net.bytebuddy.implementation.bind.annotation.Argument Java Examples

The following examples show how to use net.bytebuddy.implementation.bind.annotation.Argument. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WindupPropertyMethodHandler.java    From windup with Eclipse Public License 1.0 6 votes vote down vote up
@RuntimeType
public static void setProperty(@This final ElementFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Object obj)
{
    assert thiz instanceof CachesReflection;
    final Property annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Property.class);
    final String propertyName = annotation.value();
    final Object propertyValue;
    if ((obj != null) && (obj.getClass().isEnum()))
        propertyValue = ((Enum<?>) obj).name();
    else
        propertyValue = obj;

    if (propertyValue == null)
    {
        RemovePropertyInterceptor.removeProperty(thiz, method);
        return;
    }

    Element element = thiz.getElement();
    if (element instanceof Vertex)
        thiz.getGraph().getRawTraversal().V(element.id()).property(propertyName, propertyValue).iterate();
    else
        thiz.getGraph().getRawTraversal().E(element.id()).property(propertyName, propertyValue).iterate();
}
 
Example #2
Source File: RMAppTracer.java    From garmadon with Apache License 2.0 6 votes vote down vote up
public static void intercept(@Argument(0) ApplicationId applicationId, @Argument(3) String name,
                             @Argument(4) String user, @Argument(5) String queue,
                             @Argument(9) long submitTime, @Argument(10) String applicationType) {
    try {
        Header header = Header.newBuilder()
                .withApplicationID(applicationId.toString())
                .withUser(user)
                .withApplicationName(name)
                .withFramework(applicationType.toUpperCase())
                .build();

        ResourceManagerEventProtos.ApplicationEvent event = ResourceManagerEventProtos.ApplicationEvent.newBuilder()
                .setState(State.NEW.name())
                .setQueue(queue)
                .build();

        eventHandler.accept(submitTime, header, event);
    } catch (Throwable ignored) {
    }
}
 
Example #3
Source File: AdjacencyMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static Iterator getVertexes(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) {
    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();
    final TypeResolver resolver = thiz.getGraph().getTypeResolver();

    return thiz.traverse(input -> {
        switch(direction) {
            case IN:
                return resolver.hasType(input.in(label), type);
            case OUT:
                return resolver.hasType(input.out(label), type);
            case BOTH:
                return resolver.hasType(input.both(label), type);
            default:
                throw new IllegalStateException("Direction not recognized.");
        }
    }).frame(type);
}
 
Example #4
Source File: ByteBuddyBuilderUtil.java    From jackson-modules-base with Apache License 2.0 6 votes vote down vote up
public static boolean intercept(@This Object self, @Argument(0) Object other) {
    if (null == other) {
        return false;
    }
    //we are being strict about class equality
    final Class<?> selfClass = self.getClass();
    final Class<?> otherClass = other.getClass();
    if (selfClass != otherClass) {
        return false;
    }
    //take advantage of HashMap's built-in equals method
    try {
        return FieldUtil.toMap(self, selfClass.getDeclaredFields())
                .equals(FieldUtil.toMap(other, other.getClass().getDeclaredFields()));
    } catch (IllegalAccessException e) {
        return false; //this it not a good solution, but should never happen because fields are accessible
    }
}
 
Example #5
Source File: AdjacencyMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static List getVertexes(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) {
    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();
    final TypeResolver resolver = thiz.getGraph().getTypeResolver();

    return thiz.traverse(input -> {
        switch(direction) {
            case IN:
                return resolver.hasType(input.in(label), type);
            case OUT:
                return resolver.hasType(input.out(label), type);
            case BOTH:
                return resolver.hasType(input.both(label), type);
            default:
                throw new IllegalStateException("Direction not recognized.");
        }
    }).toList(type);
}
 
Example #6
Source File: AdjacencyMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static Set getVertexes(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) {
    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();
    final TypeResolver resolver = thiz.getGraph().getTypeResolver();

    return thiz.traverse(input -> {
        switch(direction) {
            case IN:
                return resolver.hasType(input.in(label), type);
            case OUT:
                return resolver.hasType(input.out(label), type);
            case BOTH:
                return resolver.hasType(input.both(label), type);
            default:
                throw new IllegalStateException("Direction not recognized.");
        }
    }).toSet(type);
}
 
Example #7
Source File: AdjacencyMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static Object getVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) {
    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();
    final TypeResolver resolver = thiz.getGraph().getTypeResolver();

    return thiz.traverse(input -> {
        switch(direction) {
            case IN:
                return resolver.hasType(input.in(label), type);
            case OUT:
                return resolver.hasType(input.out(label), type);
            case BOTH:
                return resolver.hasType(input.both(label), type);
            default:
                throw new IllegalStateException("Direction not recognized.");
        }
    }).next(type);
}
 
Example #8
Source File: AdjacencyMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static Object addVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final VertexFrame newVertex) {
    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();

    switch (direction) {
        case BOTH:
            thiz.getGraph().addFramedEdge(newVertex, thiz, label);
            thiz.getGraph().addFramedEdge(thiz, newVertex, label);
            break;
        case IN:
            thiz.getGraph().addFramedEdge(newVertex, thiz, label);
            break;
        case OUT:
            thiz.getGraph().addFramedEdge(thiz, newVertex, label);
            break;
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }

    return newVertex;
}
 
Example #9
Source File: AdjacencyMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static Object addVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final VertexFrame newVertex, @RuntimeType @Argument(1) final ClassInitializer edgeType) {
    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();

    switch (direction) {
        case BOTH:
            thiz.getGraph().addFramedEdge(newVertex, thiz, label, edgeType);
            thiz.getGraph().addFramedEdge(thiz, newVertex, label, edgeType);
            break;
        case IN:
            thiz.getGraph().addFramedEdge(newVertex, thiz, label, edgeType);
            break;
        case OUT:
            thiz.getGraph().addFramedEdge(thiz, newVertex, label, edgeType);
            break;
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }

    return newVertex;
}
 
Example #10
Source File: IncidenceMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static Object addVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final ClassInitializer vertexType, @RuntimeType @Argument(1) final ClassInitializer edgeType) {
    final Object newNode = thiz.getGraph().addFramedVertex(vertexType);
    assert newNode instanceof VertexFrame;
    final VertexFrame newVertex = ((VertexFrame) newNode);

    assert thiz instanceof CachesReflection;
    final Incidence annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Incidence.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();

    assert vertexType.getInitializationType().isInstance(newNode);

    switch (direction) {
        case BOTH:
            throw new IllegalStateException(method.getName() + " is annotated with direction BOTH, this is not allowed for add methods annotated with @Incidence.");
        case IN:
            return thiz.getGraph().addFramedEdge(newVertex, thiz, label, edgeType);
        case OUT:
            return thiz.getGraph().addFramedEdge(thiz, newVertex, label, edgeType);
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }
}
 
Example #11
Source File: IncidenceMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static Object addVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final VertexFrame newVertex) {
    assert thiz instanceof CachesReflection;
    final Incidence annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Incidence.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();

    switch (direction) {
        case BOTH:
            throw new IllegalStateException(method.getName() + " is annotated with direction BOTH, this is not allowed for add methods annotated with @Incidence.");
        case IN:
            return thiz.getGraph().addFramedEdge(newVertex, thiz, label);
        case OUT:
            return thiz.getGraph().addFramedEdge(thiz, newVertex, label);
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }
}
 
Example #12
Source File: IncidenceMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static Object addVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final VertexFrame newVertex, @RuntimeType @Argument(1) final ClassInitializer edgeType) {
    assert thiz instanceof CachesReflection;
    final Incidence annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Incidence.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();

    switch (direction) {
        case BOTH:
            throw new IllegalStateException(method.getName() + " is annotated with direction BOTH, this is not allowed for add methods annotated with @Incidence.");
        case IN:
            return thiz.getGraph().addFramedEdge(newVertex, thiz, label, edgeType);
        case OUT:
            return thiz.getGraph().addFramedEdge(thiz, newVertex, label, edgeType);
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }
}
 
Example #13
Source File: IncidenceMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static List getEdges(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) {
    assert thiz instanceof CachesReflection;
    final Incidence annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Incidence.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();
    final TypeResolver resolver = thiz.getGraph().getTypeResolver();

    switch (direction) {
        case BOTH:
            return thiz.traverse(input -> resolver.hasType(input.bothE(label), type)).toList(type);
        case IN:
            return thiz.traverse(input -> resolver.hasType(input.inE(label), type)).toList(type);
        case OUT:
            return thiz.traverse(input -> resolver.hasType(input.outE(label), type)).toList(type);
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }
}
 
Example #14
Source File: IncidenceMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static Object addVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(value = 0) final ClassInitializer vertexType) {
    final Object newNode = thiz.getGraph().addFramedVertex(vertexType);
    assert newNode instanceof VertexFrame;
    final VertexFrame newVertex = ((VertexFrame) newNode);

    assert thiz instanceof CachesReflection;
    final Incidence annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Incidence.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();

    assert vertexType.getInitializationType().isInstance(newNode);

    switch (direction) {
        case BOTH:
            throw new IllegalStateException(method.getName() + " is annotated with direction BOTH, this is not allowed for add methods annotated with @Incidence.");
        case IN:
            return thiz.getGraph().addFramedEdge(newVertex, thiz, label);
        case OUT:
            return thiz.getGraph().addFramedEdge(thiz, newVertex, label);
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }
}
 
Example #15
Source File: WindupAdjacencyMethodHandler.java    From windup with Eclipse Public License 1.0 6 votes vote down vote up
@RuntimeType
public static Object addVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final VertexFrame newVertex, @RuntimeType @Argument(1) final ClassInitializer edgeType) {
    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();

    switch (direction) {
        case BOTH:
            thiz.getGraph().addFramedEdge(newVertex, thiz, label, edgeType);
            thiz.getGraph().addFramedEdge(thiz, newVertex, label, edgeType);
            break;
        case IN:
            thiz.getGraph().addFramedEdge(newVertex, thiz, label, edgeType);
            break;
        case OUT:
            thiz.getGraph().addFramedEdge(thiz, newVertex, label, edgeType);
            break;
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }

    return newVertex;
}
 
Example #16
Source File: WindupAdjacencyMethodHandler.java    From windup with Eclipse Public License 1.0 6 votes vote down vote up
@RuntimeType
public static Object addVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final VertexFrame newVertex) {
    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();

    switch (direction) {
        case BOTH:
            thiz.getGraph().addFramedEdge(newVertex, thiz, label);
            thiz.getGraph().addFramedEdge(thiz, newVertex, label);
            break;
        case IN:
            thiz.getGraph().addFramedEdge(newVertex, thiz, label);
            break;
        case OUT:
            thiz.getGraph().addFramedEdge(thiz, newVertex, label);
            break;
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }

    return newVertex;
}
 
Example #17
Source File: WindupAdjacencyMethodHandler.java    From windup with Eclipse Public License 1.0 6 votes vote down vote up
@RuntimeType
public static Object getVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) {
    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();
    final TypeResolver resolver = thiz.getGraph().getTypeResolver();

    return thiz.traverse(input -> {
        switch(direction) {
            case IN:
                return resolver.hasType(input.in(label), type);
            case OUT:
                return resolver.hasType(input.out(label), type);
            case BOTH:
                return resolver.hasType(input.both(label), type);
            default:
                throw new IllegalStateException("Direction not recognized.");
        }
    }).next(type);
}
 
Example #18
Source File: WindupAdjacencyMethodHandler.java    From windup with Eclipse Public License 1.0 6 votes vote down vote up
@RuntimeType
public static Set getVertexes(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) {
    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();
    final TypeResolver resolver = thiz.getGraph().getTypeResolver();

    return thiz.traverse(input -> {
        switch(direction) {
            case IN:
                return resolver.hasType(input.in(label), type);
            case OUT:
                return resolver.hasType(input.out(label), type);
            case BOTH:
                return resolver.hasType(input.both(label), type);
            default:
                throw new IllegalStateException("Direction not recognized.");
        }
    }).toSet(type);
}
 
Example #19
Source File: WindupAdjacencyMethodHandler.java    From windup with Eclipse Public License 1.0 6 votes vote down vote up
@RuntimeType
public static List getVertexes(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) {
    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();
    final TypeResolver resolver = thiz.getGraph().getTypeResolver();

    return thiz.traverse(input -> {
        switch(direction) {
            case IN:
                return resolver.hasType(input.in(label), type);
            case OUT:
                return resolver.hasType(input.out(label), type);
            case BOTH:
                return resolver.hasType(input.both(label), type);
            default:
                throw new IllegalStateException("Direction not recognized.");
        }
    }).toList(type);
}
 
Example #20
Source File: WindupAdjacencyMethodHandler.java    From windup with Eclipse Public License 1.0 6 votes vote down vote up
@RuntimeType
public static Iterator getVertexes(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) {
    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();
    final TypeResolver resolver = thiz.getGraph().getTypeResolver();

    return thiz.traverse(input -> {
        switch(direction) {
            case IN:
                return resolver.hasType(input.in(label), type);
            case OUT:
                return resolver.hasType(input.out(label), type);
            case BOTH:
                return resolver.hasType(input.both(label), type);
            default:
                throw new IllegalStateException("Direction not recognized.");
        }
    }).frame(type);
}
 
Example #21
Source File: IncidenceMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static Object getEdge(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) {
    assert thiz instanceof CachesReflection;
    final Incidence annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Incidence.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();
    final TypeResolver resolver = thiz.getGraph().getTypeResolver();

    switch (direction) {
        case BOTH:
            return thiz.traverse(input -> resolver.hasType(input.bothE(label), type)).next(type);
        case IN:
            return thiz.traverse(input -> resolver.hasType(input.inE(label), type)).next(type);
        case OUT:
            return thiz.traverse(input -> resolver.hasType(input.outE(label), type)).next(type);
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }
}
 
Example #22
Source File: IncidenceMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static Set getEdges(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) {
    assert thiz instanceof CachesReflection;
    final Incidence annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Incidence.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();
    final TypeResolver resolver = thiz.getGraph().getTypeResolver();

    switch (direction) {
        case BOTH:
            return thiz.traverse(input -> resolver.hasType(input.bothE(label), type)).toSet(type);
        case IN:
            return thiz.traverse(input -> resolver.hasType(input.inE(label), type)).toSet(type);
        case OUT:
            return thiz.traverse(input -> resolver.hasType(input.outE(label), type)).toSet(type);
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }
}
 
Example #23
Source File: IncidenceMethodHandler.java    From Ferma with Apache License 2.0 6 votes vote down vote up
@RuntimeType
public static Iterator getEdges(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(0) final Class type) {
    assert thiz instanceof CachesReflection;
    final Incidence annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Incidence.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();
    final TypeResolver resolver = thiz.getGraph().getTypeResolver();

    switch (direction) {
        case BOTH:
            return thiz.traverse(input -> resolver.hasType(input.bothE(label), type)).frame(type);
        case IN:
            return thiz.traverse(input -> resolver.hasType(input.inE(label), type)).frame(type);
        case OUT:
            return thiz.traverse(input -> resolver.hasType(input.outE(label), type)).frame(type);
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }
}
 
Example #24
Source File: FileSystemTracer.java    From garmadon with Apache License 2.0 5 votes vote down vote up
@RuntimeType
public static Object intercept(
    @SuperCall Callable<?> zuper,
    @This Object o,
    @Argument(0) Object src,
    @Argument(1) Object dst) throws Exception {
    return callDistributedFileSystem(zuper, o, src.toString(), dst.toString(), FsAction.RENAME.name());
}
 
Example #25
Source File: ContainerResourceMonitoringTracer.java    From garmadon with Apache License 2.0 5 votes vote down vote up
public static void intercept(@This Object containerMetrics,
                             @Argument(1) int milliVcoresUsed) throws Exception {
    try {
        if (getField() != null) {
            ContainerId cID = (ContainerId) getField().get(containerMetrics);
            ApplicationAttemptId applicationAttemptId = cID.getApplicationAttemptId();
            String applicationId = applicationAttemptId.getApplicationId().toString();
            String attemptId = applicationAttemptId.toString();

            float cpuVcoreUsed = (milliVcoresUsed > 0) ? (float) milliVcoresUsed / 1000 : 0f;
            int cpuVcoreLimit = ((ContainerMetrics) containerMetrics).cpuVcoreLimit.value();

            Header header = Header.newBuilder()
                    .withId(applicationId)
                    .withApplicationID(applicationId)
                    .withAttemptID(attemptId)
                    .withContainerID(cID.toString())
                    .build();

            ContainerEventProtos.ContainerResourceEvent event = ContainerEventProtos.ContainerResourceEvent.newBuilder()
                    .setType(ContainerType.VCORE.name())
                    .setValue(cpuVcoreUsed)
                    .setLimit(cpuVcoreLimit)
                    .build();
            eventHandler.accept(System.currentTimeMillis(), header, event);
        } else {
            LOGGER.warn("ContainerMetrics class does not have containerId field");
        }
    } catch (Throwable ignored) {
    }
}
 
Example #26
Source File: FileSystemTracer.java    From garmadon with Apache License 2.0 5 votes vote down vote up
@RuntimeType
public static Object intercept(
    @SuperCall Callable<?> zuper,
    @This Object o,
    @Argument(0) Object dst) throws Exception {
    return callDistributedFileSystem(zuper, o, null, dst.toString(), FsAction.READ.name());
}
 
Example #27
Source File: FileSystemTracer.java    From garmadon with Apache License 2.0 5 votes vote down vote up
@RuntimeType
public static Object intercept(
    @SuperCall Callable<?> zuper,
    @This Object o,
    @Argument(0) Object dst) throws Exception {
    return callDistributedFileSystem(zuper, o, null, dst.toString(), FsAction.DELETE.name());
}
 
Example #28
Source File: MapReduceTracer.java    From garmadon with Apache License 2.0 5 votes vote down vote up
public static void intercept(@Argument(1) JobConf jobConf) {
    String paths = (jobConf.get(FILE_OUTPUT_FORMAT_OUTPUT_DIR) != null) ?
            jobConf.get(FILE_OUTPUT_FORMAT_OUTPUT_DIR) : jobConf.get(DEPRECATED_FILE_OUTPUT_FORMAT_OUTPUT_DIR);
    if (paths != null) {
        DataAccessEventProtos.PathEvent pathEvent = DataAccessEventProtos.PathEvent
                .newBuilder()
                .setPath(paths)
                .setType(PathType.OUTPUT.name())
                .build();
        eventHandler.accept(System.currentTimeMillis(), pathEvent);
    }
}
 
Example #29
Source File: MapReduceTracer.java    From garmadon with Apache License 2.0 5 votes vote down vote up
public static void intercept(@Argument(1) JobConf jobConf) throws Exception {
    String paths = (jobConf.get(FILE_INPUT_FORMAT_INPUT_DIR) != null) ?
            jobConf.get(FILE_INPUT_FORMAT_INPUT_DIR) : jobConf.get(DEPRECATED_FILE_INPUT_FORMAT_INPUT_DIR);
    if (paths != null) {
        DataAccessEventProtos.PathEvent pathEvent = DataAccessEventProtos.PathEvent
                .newBuilder()
                .setPath(paths)
                .setType(PathType.INPUT.name())
                .build();
        eventHandler.accept(System.currentTimeMillis(), pathEvent);
    }
}
 
Example #30
Source File: WindupAdjacencyMethodHandler.java    From windup with Eclipse Public License 1.0 5 votes vote down vote up
@RuntimeType
public static Object addVertex(@This final VertexFrame thiz, @Origin final Method method, @RuntimeType @Argument(value = 0) final ClassInitializer vertexType) {
    final Object newNode = thiz.getGraph().addFramedVertex(vertexType);
    assert newNode instanceof VertexFrame;
    final VertexFrame newVertex = ((VertexFrame) newNode);

    assert thiz instanceof CachesReflection;
    final Adjacency annotation = ((CachesReflection) thiz).getReflectionCache().getAnnotation(method, Adjacency.class);
    final Direction direction = annotation.direction();
    final String label = annotation.label();

    assert vertexType.getInitializationType().isInstance(newNode);

    switch (direction) {
        case BOTH:
            thiz.getGraph().addFramedEdge(newVertex, thiz, label);
            thiz.getGraph().addFramedEdge(thiz, newVertex, label);
            break;
        case IN:
            thiz.getGraph().addFramedEdge(newVertex, thiz, label);
            break;
        case OUT:
            thiz.getGraph().addFramedEdge(thiz, newVertex, label);
            break;
        default:
            throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
    }

    return newNode;
}