private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); definitionMetadata = deserializeObjectNode(in); }
private void writeObject(final ObjectOutputStream out) throws IOException { out.defaultWriteObject(); serializeObjectNode(out, definitionMetadata); } }
/** * {@inheritDoc} */ @Override public List<String> get_databases(final String hivePattern) throws TException { return requestWrapper("get_databases", new Object[]{hivePattern}, () -> { List<String> result = v1.getCatalog(catalogName).getDatabases(); if (hivePattern != null) { // Unsure about the pattern format. I couldn't find any tests. Assuming it is regex. final Pattern pattern = PATTERNS.getUnchecked("(?i)" + hivePattern.replaceAll("\\*", ".*")); result = result.stream().filter(name -> pattern.matcher(name).matches()) .collect(Collectors.toList()); } return result; }); }
private List<QualifiedName> getDatabaseNamesToRefresh(final CatalogDto catalogDto) { List<QualifiedName> result = null; if (!config.getElasticSearchRefreshIncludeDatabases().isEmpty()) { result = config.getElasticSearchRefreshIncludeDatabases().stream() .filter(q -> catalogDto.getName().getCatalogName().equals(q.getCatalogName())) .collect(Collectors.toList()); } else { result = catalogDto.getDatabases().stream() .map(n -> QualifiedName.ofDatabase(catalogDto.getName().getCatalogName(), n)) .collect(Collectors.toList()); } if (!config.getElasticSearchRefreshExcludeQualifiedNames().isEmpty()) { result.removeAll(config.getElasticSearchRefreshExcludeQualifiedNames()); } return result; }
public CatalogDto get(final QualifiedName name, final GetCatalogServiceParameters getCatalogServiceParameters) { final Set<MetacatCatalogConfig> configs = connectorManager.getCatalogConfigs(name.getCatalogName()); final CatalogDto result = new CatalogDto(); result.setName(name); final ConnectorRequestContext context = converterUtil.toConnectorContext(MetacatContextManager.getContext()); final List<String> databases = Lists.newArrayList(); QualifiedName qName = name; if (config.getSchemaWhitelist().isEmpty()) { result.setType(config.getType()); } else { qName = QualifiedName.ofDatabase(name.getCatalogName(), config.getSchemaWhitelist().get(0)); result.setDatabases(databases); if (getCatalogServiceParameters.isIncludeUserMetadata()) { userMetadataService.populateMetadata(result, false);
@SuppressWarnings("checkstyle:methodname") private ListenableFuture<Void> _processCatalogs(final List<String> catalogNames) { log.info("Start: Full refresh of catalogs: {}", catalogNames); final List<ListenableFuture<CatalogDto>> getCatalogFutures = catalogNames.stream() .map(catalogName -> service.submit(() -> { CatalogDto result = null; try { result = getCatalog(catalogName); } catch (Exception e) { log.error("Failed to retrieve catalog: {}", catalogName); elasticSearchUtil.log("ElasticSearchRefresh.getCatalog", ElasticSearchDoc.Type.catalog.name(), catalogName, null, e.getMessage(), e, true); } return result; })) .collect(Collectors.toList()); return Futures.transformAsync(Futures.successfulAsList(getCatalogFutures), input -> { final List<ListenableFuture<Void>> processCatalogFutures = input.stream().filter(NOT_NULL).map( catalogDto -> { final List<QualifiedName> databaseNames = getDatabaseNamesToRefresh(catalogDto); return _processDatabases(catalogDto.getName(), databaseNames); }).filter(NOT_NULL).collect(Collectors.toList()); return Futures.transform(Futures.successfulAsList(processCatalogFutures), Functions.constant(null), defaultService); }, defaultService); }
/** * {@inheritDoc} */ @Override public List<String> get_databases(final String hivePattern) throws TException { return requestWrapper("get_databases", new Object[]{hivePattern}, () -> { List<String> result = v1.getCatalog(catalogName).getDatabases(); if (hivePattern != null) { // Unsure about the pattern format. I couldn't find any tests. Assuming it is regex. final Pattern pattern = PATTERNS.getUnchecked("(?i)" + hivePattern.replaceAll("\\*", ".*")); result = result.stream().filter(name -> pattern.matcher(name).matches()) .collect(Collectors.toList()); } return result; }); }
/** * {@inheritDoc} */ @Override public List<String> get_all_databases() throws TException { return requestWrapper("get_all_databases", new Object[]{}, () -> v1.getCatalog(catalogName).getDatabases()); }
private void writeObject(final ObjectOutputStream out) throws IOException { out.defaultWriteObject(); serializeObjectNode(out, definitionMetadata); } }
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); definitionMetadata = deserializeObjectNode(in); }
/** * {@inheritDoc} */ @Override public List<String> get_all_databases() throws TException { return requestWrapper("get_all_databases", new Object[]{}, () -> v1.getCatalog(catalogName).getDatabases()); }
/** * {@inheritDoc} */ @Override public boolean exists(final QualifiedName name) { final CatalogDto catalogDto = catalogService.get(QualifiedName.ofCatalog(name.getCatalogName())); return catalogDto.getDatabases().contains(name.getDatabaseName()); }