schemaId = metadataInfo.getId(); if (schemaId == null) { throw new org.apache.nifi.schema.access.SchemaNotFoundException("Could not find schema with name '" + schemaName + "'");
private List<SerDesInfo> getSerDesInfos(String schemaName) { Collection<SchemaSerDesMapping> schemaSerDesMappings = getSchemaSerDesMappings(getSchemaMetadataInfo(schemaName) .getId()); List<SerDesInfo> serDesInfos; if (schemaSerDesMappings == null || schemaSerDesMappings.isEmpty()) { serDesInfos = Collections.emptyList(); } else { serDesInfos = new ArrayList<>(); for (SchemaSerDesMapping schemaSerDesMapping : schemaSerDesMappings) { SerDesInfo serDesInfo = getSerDes(schemaSerDesMapping.getSerDesId()); serDesInfos.add(serDesInfo); } } return serDesInfos; }
@Override public Long addSchemaMetadata(SchemaMetadata schemaMetadata) { SchemaMetadataInfo schemaMetadataInfo = schemaMetadataCache.getIfPresent(SchemaMetadataCache.Key.of(schemaMetadata .getName())); if (schemaMetadataInfo == null) { return doRegisterSchemaMetadata(schemaMetadata, currentSchemaRegistryTargets().schemasTarget); } return schemaMetadataInfo.getId(); }
@Override public void mapSchemaWithSerDes(String schemaName, Long serDesId) { SerDesInfo serDesInfo = getSerDes(serDesId); if (serDesInfo == null) { throw new SerDesException("Serializer with given ID " + serDesId + " does not exist"); } SchemaMetadataInfo schemaMetadataInfo = getSchemaMetadataInfo(schemaName); SchemaSerDesMapping schemaSerDesMapping = new SchemaSerDesMapping(schemaMetadataInfo.getId(), serDesId); storageManager.add(schemaSerDesMapping); }
private Long doRegisterSchemaMetadata(SchemaMetadata schemaMetadata, WebTarget schemasTarget) { try { return postEntity(schemasTarget, schemaMetadata, Long.class); } catch(BadRequestException ex) { Response response = ex.getResponse(); CatalogResponse catalogResponse = SchemaRegistryClient.readCatalogResponse(response.readEntity(String.class)); if(catalogResponse.getResponseCode() == CatalogResponse.ResponseMessage.ENTITY_CONFLICT.getCode()) { return getSchemaMetadataInfo(schemaMetadata.getName()).getId(); } else { throw ex; } } }
aggregatedSchemaMetadataInfos.add( new AggregatedSchemaMetadataInfo(schemaMetadata, schemaMetadataInfo.getId(), schemaMetadataInfo.getTimestamp(), schemaRegistry.getAggregatedSchemaBranch(schemaMetadata.getName()),
aggregatedSchemaMetadataInfos.add( new AggregatedSchemaMetadataInfo(schemaMetadata, schemaMetadataInfo.getId(), schemaMetadataInfo.getTimestamp(), schemaRegistry.getAggregatedSchemaBranch(schemaMetadata.getName()),
public static SchemaMetadataStorable fromSchemaMetadataInfo(SchemaMetadataInfo schemaMetadataInfo) { SchemaMetadata schemaMetadata = schemaMetadataInfo.getSchemaMetadata(); SchemaMetadataStorable schemaMetadataStorable = updateSchemaMetadata(new SchemaMetadataStorable(), schemaMetadata); schemaMetadataStorable.setId(schemaMetadataInfo.getId()); schemaMetadataStorable.setTimestamp(schemaMetadataInfo.getTimestamp()); return schemaMetadataStorable; }
public SchemaIdVersion addSchemaVersion(String schemaBranchName, SchemaMetadataInfo schemaMetadataInfo, SchemaVersion schemaVersion) throws SchemaNotFoundException, IncompatibleSchemaException, InvalidSchemaException, SchemaBranchNotFoundException { Preconditions.checkNotNull(schemaBranchName, "Schema branch name can't be null"); checkSchemaText(schemaVersion.getSchemaText()); SchemaVersionInfo schemaVersionInfo; // check whether there exists schema-metadata for schema-metadata-key SchemaMetadata schemaMetadata = schemaMetadataInfo.getSchemaMetadata(); // check whether the same schema text exists schemaVersionInfo = findSchemaVersion(schemaBranchName, schemaMetadata.getType(), schemaVersion.getSchemaText(), schemaMetadataInfo .getSchemaMetadata().getName()); if (schemaVersionInfo == null) { schemaVersionInfo = createSchemaVersion(schemaBranchName, schemaMetadata, schemaMetadataInfo.getId(), schemaVersion); } return new SchemaIdVersion(schemaMetadataInfo.getId(), schemaVersionInfo.getVersion(), schemaVersionInfo.getId()); }
private SchemaIdVersion handleSchemaIdVersionResponse(SchemaMetadataInfo schemaMetadataInfo, Response response) throws IncompatibleSchemaException, InvalidSchemaException { int status = response.getStatus(); String msg = response.readEntity(String.class); if (status == Response.Status.BAD_REQUEST.getStatusCode() || status == Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()) { CatalogResponse catalogResponse = readCatalogResponse(msg); if (CatalogResponse.ResponseMessage.INCOMPATIBLE_SCHEMA.getCode() == catalogResponse.getResponseCode()) { throw new IncompatibleSchemaException(catalogResponse.getResponseMessage()); } else if (CatalogResponse.ResponseMessage.INVALID_SCHEMA.getCode() == catalogResponse.getResponseCode()) { throw new InvalidSchemaException(catalogResponse.getResponseMessage()); } else { throw new RuntimeException(catalogResponse.getResponseMessage()); } } Integer version = readEntity(msg, Integer.class); SchemaVersionInfo schemaVersionInfo = doGetSchemaVersionInfo(new SchemaVersionKey(schemaMetadataInfo.getSchemaMetadata() .getName(), version)); return new SchemaIdVersion(schemaMetadataInfo.getId(), version, schemaVersionInfo.getId()); }
schemaVersionId, existingSchemaVersionInfo.getVersion()); LOG.info(mergeMessage); return new SchemaVersionMergeResult(new SchemaIdVersion(schemaMetadataInfo.getId(), existingSchemaVersionInfo.getVersion(), existingSchemaVersionInfo.getId()), schemaMetadataInfo.getId(), new SchemaVersion(schemaVersionInfo.getSchemaText(), schemaVersionInfo.getDescription(), schemaVersionId, createdSchemaVersionInfo.getVersion()); LOG.info(mergeMessage); return new SchemaVersionMergeResult(new SchemaIdVersion(schemaMetadataInfo.getId(), createdSchemaVersionInfo.getVersion(), createdSchemaVersionInfo.getId()),
private AggregatedSchemaMetadataInfo buildAggregatedSchemaMetadataInfo(SchemaMetadataInfo schemaMetadataInfo) throws SchemaNotFoundException, SchemaBranchNotFoundException { if (schemaMetadataInfo == null) { return null; } List<SerDesInfo> serDesInfos = getSerDesInfos(schemaMetadataInfo.getSchemaMetadata().getName()); return new AggregatedSchemaMetadataInfo(schemaMetadataInfo.getSchemaMetadata(), schemaMetadataInfo.getId(), schemaMetadataInfo.getTimestamp(), getAggregatedSchemaBranch(schemaMetadataInfo.getSchemaMetadata().getName()), serDesInfos); }