Search in sources :

Example 71 with UncheckedExecutionException

use of com.google.common.util.concurrent.UncheckedExecutionException in project streamline by hortonworks.

the class StormTopologyMetricsImpl method getTopologyInfo.

private Map<String, ?> getTopologyInfo(String topologyId, String asUser) {
    LOG.debug("[START] getTopologyInfo - topology id: {}, asUser: {}", topologyId, asUser);
    Stopwatch stopwatch = Stopwatch.createStarted();
    try {
        Map<String, ?> responseMap;
        try {
            responseMap = topologyRetrieveCache.get(new ImmutablePair<>(topologyId, asUser));
        } catch (ExecutionException e) {
            if (e.getCause() != null) {
                throw new RuntimeException(e.getCause());
            } else {
                throw new RuntimeException(e);
            }
        } catch (UncheckedExecutionException e) {
            Throwable cause = e.getCause();
            if (cause instanceof RuntimeException) {
                throw (RuntimeException) cause;
            } else {
                throw new RuntimeException(e);
            }
        }
        LOG.debug("[END] getTopologyInfo - topology id: {}, elapsed: {} ms", topologyId, stopwatch.elapsed(TimeUnit.MILLISECONDS));
        return responseMap;
    } finally {
        stopwatch.stop();
    }
}
Also used : UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Stopwatch(com.google.common.base.Stopwatch) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ExecutionException(java.util.concurrent.ExecutionException)

Example 72 with UncheckedExecutionException

use of com.google.common.util.concurrent.UncheckedExecutionException in project meghanada-server by mopemope.

the class LocationSearcher method getFieldLocationFromProject.

private Optional<Location> getFieldLocationFromProject(final String fqcn, final String fieldName, final File file) {
    try {
        final Source declaringClassSrc = getSource(project, file);
        final String path = declaringClassSrc.getFile().getPath();
        return declaringClassSrc.getClassScopes().stream().map(cs -> getMatchField(cs, fqcn, fieldName)).filter(Optional::isPresent).map(optional -> {
            final Variable variable = optional.get();
            return new Location(path, variable.range.begin.line, variable.range.begin.column);
        }).findFirst();
    } catch (Exception e) {
        throw new UncheckedExecutionException(e);
    }
}
Also used : DecompilationListener(org.jboss.windup.decompiler.api.DecompilationListener) FunctionUtils.wrapIOConsumer(meghanada.utils.FunctionUtils.wrapIOConsumer) ConstructorDeclaration(com.github.javaparser.ast.body.ConstructorDeclaration) Map(java.util.Map) ZipFile(java.util.zip.ZipFile) MethodCall(meghanada.analyze.MethodCall) CompilationUnit(com.github.javaparser.ast.CompilationUnit) Path(java.nio.file.Path) ZipEntry(java.util.zip.ZipEntry) FunctionUtils.wrapIO(meghanada.utils.FunctionUtils.wrapIO) GlobalCache(meghanada.cache.GlobalCache) SimpleName(com.github.javaparser.ast.expr.SimpleName) TypeDeclaration(com.github.javaparser.ast.body.TypeDeclaration) StandardOpenOption(java.nio.file.StandardOpenOption) StandardCharsets(java.nio.charset.StandardCharsets) UncheckedIOException(java.io.UncheckedIOException) Objects(java.util.Objects) List(java.util.List) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) MethodScope(meghanada.analyze.MethodScope) ClassNameUtils(meghanada.utils.ClassNameUtils) Optional(java.util.Optional) Project(meghanada.project.Project) Pattern(java.util.regex.Pattern) ProjectDependency(meghanada.project.ProjectDependency) Config(meghanada.config.Config) Parameter(com.github.javaparser.ast.body.Parameter) Position(com.github.javaparser.Position) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) VariableDeclarator(com.github.javaparser.ast.body.VariableDeclarator) Variable(meghanada.analyze.Variable) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ClassScope(meghanada.analyze.ClassScope) OutputStream(java.io.OutputStream) Filter(org.jboss.windup.decompiler.util.Filter) DecompilationResult(org.jboss.windup.decompiler.api.DecompilationResult) Files(java.nio.file.Files) BufferedWriter(java.io.BufferedWriter) BodyDeclaration(com.github.javaparser.ast.body.BodyDeclaration) FileOutputStream(java.io.FileOutputStream) FileUtils.existsFQCN(meghanada.utils.FileUtils.existsFQCN) IOException(java.io.IOException) CachedASMReflector(meghanada.reflect.asm.CachedASMReflector) FileUtils(meghanada.utils.FileUtils) EntryMessage(org.apache.logging.log4j.message.EntryMessage) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) FieldDeclaration(com.github.javaparser.ast.body.FieldDeclaration) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) Paths(java.nio.file.Paths) Source(meghanada.analyze.Source) FernflowerDecompiler(org.jboss.windup.decompiler.fernflower.FernflowerDecompiler) TypeScope(meghanada.analyze.TypeScope) LogManager(org.apache.logging.log4j.LogManager) JavaParser(com.github.javaparser.JavaParser) InputStream(java.io.InputStream) Variable(meghanada.analyze.Variable) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) Optional(java.util.Optional) Source(meghanada.analyze.Source) UncheckedIOException(java.io.UncheckedIOException) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Example 73 with UncheckedExecutionException

use of com.google.common.util.concurrent.UncheckedExecutionException in project meghanada-server by mopemope.

the class CachedASMReflector method reflect.

public List<MemberDescriptor> reflect(final String className) {
    final ClassName cn = new ClassName(className);
    // check type parameter
    final String classWithoutTP = cn.getName();
    final GlobalCache globalCache = GlobalCache.getInstance();
    try {
        final List<MemberDescriptor> members = new ArrayList<>(16);
        List<MemberDescriptor> list = globalCache.getMemberDescriptors(classWithoutTP);
        for (final MemberDescriptor md : list) {
            members.add(md.clone());
        }
        if (cn.hasTypeParameter()) {
            return this.replaceMembers(classWithoutTP, className, members);
        }
        return members;
    } catch (ExecutionException e) {
        throw new UncheckedExecutionException(e);
    }
}
Also used : GlobalCache(meghanada.cache.GlobalCache) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) MemberDescriptor(meghanada.reflect.MemberDescriptor) ClassName(meghanada.utils.ClassName) ArrayList(java.util.ArrayList) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ExecutionException(java.util.concurrent.ExecutionException)

Example 74 with UncheckedExecutionException

use of com.google.common.util.concurrent.UncheckedExecutionException in project spf4j by zolyfarkas.

the class SpecificRecordOpenTypeMapping method typeFromSpecificRecord.

private static CompositeType typeFromSpecificRecord(final SpecificRecordBase r, final JMXBeanMappingSupplier typeMapper) throws NotSerializableException {
    Schema schema = r.getSchema();
    List<Schema.Field> fields = schema.getFields();
    int size = fields.size();
    String[] names = new String[size];
    String[] descriptions = new String[size];
    OpenType<?>[] types = new OpenType<?>[size];
    for (Schema.Field field : fields) {
        int pos = field.pos();
        names[pos] = field.name();
        descriptions[pos] = field.doc();
        types[pos] = typeMapper.get(getGenericType(field.schema())).getOpenType();
    }
    try {
        return new CompositeType(schema.getFullName(), schema.getDoc(), names, descriptions, types);
    } catch (OpenDataException ex) {
        throw new UncheckedExecutionException(ex);
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) OpenDataException(javax.management.openmbean.OpenDataException) Schema(org.apache.avro.Schema) CompositeType(javax.management.openmbean.CompositeType)

Example 75 with UncheckedExecutionException

use of com.google.common.util.concurrent.UncheckedExecutionException in project incubator-gobblin by apache.

the class HiveSource method createWorkunitsForPartitionedTable.

protected void createWorkunitsForPartitionedTable(HiveDataset hiveDataset, AutoReturnableObject<IMetaStoreClient> client) throws IOException {
    boolean setLineageInfo = false;
    long tableProcessTime = new DateTime().getMillis();
    this.watermarker.onTableProcessBegin(hiveDataset.getTable(), tableProcessTime);
    Optional<String> partitionFilter = Optional.absent();
    // If the table is date partitioned, use the partition name to filter partitions older than lookback
    if (hiveDataset.getProperties().containsKey(LookbackPartitionFilterGenerator.PARTITION_COLUMN) && hiveDataset.getProperties().containsKey(LookbackPartitionFilterGenerator.DATETIME_FORMAT) && hiveDataset.getProperties().containsKey(LookbackPartitionFilterGenerator.LOOKBACK)) {
        partitionFilter = Optional.of(new LookbackPartitionFilterGenerator(hiveDataset.getProperties()).getFilter(hiveDataset));
        log.info(String.format("Getting partitions for %s using partition filter %s", hiveDataset.getTable().getCompleteName(), partitionFilter.get()));
    }
    List<Partition> sourcePartitions = HiveUtils.getPartitions(client.get(), hiveDataset.getTable(), partitionFilter);
    for (Partition sourcePartition : sourcePartitions) {
        if (isOlderThanLookback(sourcePartition)) {
            continue;
        }
        LongWatermark lowWatermark = watermarker.getPreviousHighWatermark(sourcePartition);
        try {
            if (!shouldCreateWorkUnit(new Path(sourcePartition.getLocation()))) {
                log.info(String.format("Not creating workunit for partition %s as partition path %s contains data path tokens to ignore %s", sourcePartition.getCompleteName(), sourcePartition.getLocation(), this.ignoreDataPathIdentifierList));
                continue;
            }
            long updateTime = this.updateProvider.getUpdateTime(sourcePartition);
            if (shouldCreateWorkunit(sourcePartition, lowWatermark)) {
                log.debug(String.format("Processing partition: %s", sourcePartition));
                long partitionProcessTime = new DateTime().getMillis();
                this.watermarker.onPartitionProcessBegin(sourcePartition, partitionProcessTime, updateTime);
                LongWatermark expectedPartitionHighWatermark = this.watermarker.getExpectedHighWatermark(sourcePartition, tableProcessTime, partitionProcessTime);
                HiveWorkUnit hiveWorkUnit = workUnitForPartition(hiveDataset, sourcePartition);
                hiveWorkUnit.setWatermarkInterval(new WatermarkInterval(lowWatermark, expectedPartitionHighWatermark));
                EventWorkunitUtils.setPartitionSlaEventMetadata(hiveWorkUnit, hiveDataset.getTable(), sourcePartition, updateTime, lowWatermark.getValue(), this.beginGetWorkunitsTime);
                if (hiveDataset instanceof ConvertibleHiveDataset && !setLineageInfo) {
                    setLineageInfo((ConvertibleHiveDataset) hiveDataset, hiveWorkUnit, this.sharedJobBroker);
                    log.info("Added lineage event for dataset " + hiveDataset.getUrn());
                    // Add lineage information only once per hive table
                    setLineageInfo = true;
                }
                workunits.add(hiveWorkUnit);
                log.info(String.format("Creating workunit for partition %s as updateTime %s is greater than low watermark %s", sourcePartition.getCompleteName(), updateTime, lowWatermark.getValue()));
            } else {
                // If watermark tracking at a partition level is necessary, create a dummy workunit for this partition here.
                log.info(String.format("Not creating workunit for partition %s as updateTime %s is lesser than low watermark %s", sourcePartition.getCompleteName(), updateTime, lowWatermark.getValue()));
            }
        } catch (UpdateNotFoundException e) {
            log.error(String.format("Not creating workunit for %s as update time was not found. %s", sourcePartition.getCompleteName(), e.getMessage()));
        } catch (SchemaNotFoundException e) {
            log.error(String.format("Not creating workunit for %s as schema was not found. %s", sourcePartition.getCompleteName(), e.getMessage()));
        } catch (UncheckedExecutionException e) {
            log.error(String.format("Not creating workunit for %s because an unchecked exception occurred. %s", sourcePartition.getCompleteName(), e.getMessage()));
        }
    }
}
Also used : LookbackPartitionFilterGenerator(org.apache.gobblin.data.management.copy.hive.filter.LookbackPartitionFilterGenerator) Path(org.apache.hadoop.fs.Path) UpdateNotFoundException(org.apache.gobblin.data.management.conversion.hive.provider.UpdateNotFoundException) Partition(org.apache.hadoop.hive.ql.metadata.Partition) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ConvertibleHiveDataset(org.apache.gobblin.data.management.conversion.hive.dataset.ConvertibleHiveDataset) DateTime(org.joda.time.DateTime) WatermarkInterval(org.apache.gobblin.source.extractor.WatermarkInterval) SchemaNotFoundException(org.apache.gobblin.data.management.conversion.hive.avro.SchemaNotFoundException) LongWatermark(org.apache.gobblin.source.extractor.extract.LongWatermark)

Aggregations

UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)101 ExecutionException (java.util.concurrent.ExecutionException)60 IOException (java.io.IOException)31 InvalidCacheLoadException (com.google.common.cache.CacheLoader.InvalidCacheLoadException)22 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 Test (org.junit.Test)9 Map (java.util.Map)8 ArrayList (java.util.ArrayList)7 File (java.io.File)6 TimeoutException (java.util.concurrent.TimeoutException)6 Stopwatch (com.google.common.base.Stopwatch)5 ImmutableMap (com.google.common.collect.ImmutableMap)5 HashMap (java.util.HashMap)5 List (java.util.List)5 NoSuchElementException (java.util.NoSuchElementException)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 InputStream (java.io.InputStream)4 Callable (java.util.concurrent.Callable)4 SirixIOException (org.sirix.exception.SirixIOException)4 TypeSignature (com.facebook.presto.common.type.TypeSignature)3