Search in sources :

Example 66 with Object

use of com.google.storage.v2.Object in project bgpcep by opendaylight.

the class AbstractMessageParser method addVendorInformationObjects.

protected static List<VendorInformationObject> addVendorInformationObjects(final Queue<Object> objects) {
    final List<VendorInformationObject> vendorInfo = new ArrayList<>();
    for (Object obj = objects.peek(); obj instanceof VendorInformationObject; obj = objects.peek()) {
        vendorInfo.add((VendorInformationObject) obj);
        objects.remove();
    }
    return vendorInfo;
}
Also used : VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject) ArrayList(java.util.ArrayList) Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject)

Example 67 with Object

use of com.google.storage.v2.Object in project bgpcep by opendaylight.

the class APITest method testUnknownObject.

@Test
public void testUnknownObject() {
    UnknownObject un = new UnknownObject(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS);
    assertFalse(un.getIgnore());
    assertFalse(un.getProcessingRule());
    assertEquals(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS, un.getError());
    assertEquals(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS.getErrorType(), un.getErrors().get(0).getErrorObject().getType());
    final Object o = new CCloseBuilder().build();
    UnknownObject unknown = new UnknownObject(PCEPErrors.LSP_RSVP_ERROR, o);
    assertEquals(Object.class, unknown.implementedInterface());
    assertEquals(o, unknown.getInvalidObject());
}
Also used : Object(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object) CCloseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.CCloseBuilder) Test(org.junit.Test)

Example 68 with Object

use of com.google.storage.v2.Object in project hadoop-connectors by GoogleCloudDataproc.

the class GoogleCloudStorageGrpcWriteChannel method handleResponse.

@Override
public void handleResponse(WriteObjectResponse response) {
    Object resource = response.getResource();
    Map<String, byte[]> metadata = resource.getMetadataMap().entrySet().stream().collect(toMap(Map.Entry::getKey, entry -> BaseEncoding.base64().decode(entry.getValue())));
    byte[] md5Hash = null;
    byte[] crc32c = null;
    if (resource.hasChecksums()) {
        md5Hash = !resource.getChecksums().getMd5Hash().isEmpty() ? resource.getChecksums().getMd5Hash().toByteArray() : null;
        crc32c = resource.getChecksums().hasCrc32C() ? ByteBuffer.allocate(4).putInt(resource.getChecksums().getCrc32C()).array() : null;
    }
    completedItemInfo = GoogleCloudStorageItemInfo.createObject(resourceId, Timestamps.toMillis(resource.getCreateTime()), Timestamps.toMillis(resource.getUpdateTime()), resource.getSize(), resource.getContentType(), resource.getContentEncoding(), metadata, resource.getGeneration(), resource.getMetageneration(), new VerificationAttributes(md5Hash, crc32c));
}
Also used : Object(com.google.storage.v2.Object) BufferedInputStream(java.io.BufferedInputStream) CommonRequestParams(com.google.storage.v2.CommonRequestParams) Hashing(com.google.common.hash.Hashing) ObjectChecksums(com.google.storage.v2.ObjectChecksums) Callable(java.util.concurrent.Callable) QueryWriteStatusResponse(com.google.storage.v2.QueryWriteStatusResponse) ByteBuffer(java.nio.ByteBuffer) GoogleCloudStorageImpl.encodeMetadata(com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl.encodeMetadata) StorageStub(com.google.storage.v2.StorageGrpc.StorageStub) StreamObserver(io.grpc.stub.StreamObserver) Collectors.toMap(java.util.stream.Collectors.toMap) ClientResponseObserver(io.grpc.stub.ClientResponseObserver) ResilientOperation(com.google.cloud.hadoop.util.ResilientOperation) ClientCalls(io.grpc.stub.ClientCalls) Duration(java.time.Duration) Map(java.util.Map) WriteObjectRequest(com.google.storage.v2.WriteObjectRequest) Status(io.grpc.Status) Hasher(com.google.common.hash.Hasher) QueryWriteStatusRequest(com.google.storage.v2.QueryWriteStatusRequest) ExecutorService(java.util.concurrent.ExecutorService) BackOffFactory(com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl.BackOffFactory) ImmutableSet(com.google.common.collect.ImmutableSet) BaseEncoding(com.google.common.io.BaseEncoding) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Timestamps(com.google.protobuf.util.Timestamps) IOException(java.io.IOException) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) ClientCallStreamObserver(io.grpc.stub.ClientCallStreamObserver) ClientCall(io.grpc.ClientCall) StartResumableWriteResponse(com.google.storage.v2.StartResumableWriteResponse) AbstractGoogleAsyncWriteChannel(com.google.cloud.hadoop.util.AbstractGoogleAsyncWriteChannel) RetryDeterminer(com.google.cloud.hadoop.util.RetryDeterminer) ByteString(com.google.protobuf.ByteString) WriteObjectResponse(com.google.storage.v2.WriteObjectResponse) MAX_WRITE_CHUNK_BYTES(com.google.storage.v2.ServiceConstants.Values.MAX_WRITE_CHUNK_BYTES) CountDownLatch(java.util.concurrent.CountDownLatch) WriteObjectSpec(com.google.storage.v2.WriteObjectSpec) TreeMap(java.util.TreeMap) StorageGrpc(com.google.storage.v2.StorageGrpc) ChecksummedData(com.google.storage.v2.ChecksummedData) ByteStreams(com.google.common.io.ByteStreams) StartResumableWriteRequest(com.google.storage.v2.StartResumableWriteRequest) AsyncWriteChannelOptions(com.google.cloud.hadoop.util.AsyncWriteChannelOptions) InputStream(java.io.InputStream) Object(com.google.storage.v2.Object) ByteString(com.google.protobuf.ByteString) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 69 with Object

use of com.google.storage.v2.Object in project java-storage by googleapis.

the class StorageClientTest method listObjectsTest.

@Test
public void listObjectsTest() throws Exception {
    Object responsesElement = Object.newBuilder().build();
    ListObjectsResponse expectedResponse = ListObjectsResponse.newBuilder().setNextPageToken("").addAllObjects(Arrays.asList(responsesElement)).build();
    mockStorage.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListObjectsPagedResponse pagedListResponse = client.listObjects(parent);
    List<Object> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getObjectsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockStorage.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListObjectsRequest actualRequest = ((ListObjectsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListObjectsPagedResponse(com.google.storage.v2.StorageClient.ListObjectsPagedResponse) Test(org.junit.Test)

Example 70 with Object

use of com.google.storage.v2.Object in project java-storage by googleapis.

the class StorageClientTest method listObjectsTest2.

@Test
public void listObjectsTest2() throws Exception {
    Object responsesElement = Object.newBuilder().build();
    ListObjectsResponse expectedResponse = ListObjectsResponse.newBuilder().setNextPageToken("").addAllObjects(Arrays.asList(responsesElement)).build();
    mockStorage.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListObjectsPagedResponse pagedListResponse = client.listObjects(parent);
    List<Object> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getObjectsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockStorage.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListObjectsRequest actualRequest = ((ListObjectsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListObjectsPagedResponse(com.google.storage.v2.StorageClient.ListObjectsPagedResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)33 ArrayList (java.util.ArrayList)25 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object)18 StorageClient (com.google.storage.v2.StorageClient)16 Object (com.google.storage.v2.Object)12 Test (org.junit.Test)12 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)12 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject)12 Object (no.mnemonic.act.platform.api.model.v1.Object)8 Preconditions (com.google.common.base.Preconditions)6 ObjectRecord (no.mnemonic.act.platform.dao.api.record.ObjectRecord)6 Metrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics)6 Metrics (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.Metrics)5 Ero (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero)5 AbstractMessage (com.google.protobuf.AbstractMessage)4 ByteString (com.google.protobuf.ByteString)4 PCEPErrors (org.opendaylight.protocol.pcep.spi.PCEPErrors)4 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)4 Lsp (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp)4 ListObjectsPagedResponse (com.google.storage.v2.StorageClient.ListObjectsPagedResponse)3