当前位置: 首页>>代码示例>>Java>>正文


Java StoredProcedure类代码示例

本文整理汇总了Java中com.microsoft.azure.documentdb.StoredProcedure的典型用法代码示例。如果您正苦于以下问题:Java StoredProcedure类的具体用法?Java StoredProcedure怎么用?Java StoredProcedure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StoredProcedure类属于com.microsoft.azure.documentdb包,在下文中一共展示了StoredProcedure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStoredProcedureRequest

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
private RxDocumentServiceRequest getStoredProcedureRequest(String collectionLink, StoredProcedure storedProcedure,
        RequestOptions options, OperationType operationType) {
    if (StringUtils.isEmpty(collectionLink)) {
        throw new IllegalArgumentException("collectionLink");
    }
    if (storedProcedure == null) {
        throw new IllegalArgumentException("storedProcedure");
    }

    validateResource(storedProcedure);

    String path = Utils.joinPath(collectionLink, Paths.STORED_PROCEDURES_PATH_SEGMENT);
    Map<String, String> requestHeaders = this.getRequestHeaders(options);
    RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, ResourceType.StoredProcedure,
            path, storedProcedure, requestHeaders);
    return request;
}
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:18,代码来源:RxDocumentClientImpl.java

示例2: createStoredProcedure

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
@Override
public Observable<ResourceResponse<StoredProcedure>> createStoredProcedure(String collectionLink,
        StoredProcedure storedProcedure, RequestOptions options) {

    return Observable.defer(() -> {
        // we are using an observable factory here
        // observable will be created fresh upon subscription
        // this is to ensure we capture most up to date information (e.g.,
        // session)
        try {

            logger.debug("Creating a StoredProcedure. collectionLink: [{}], storedProcedure id [{}]",
                    collectionLink, storedProcedure.getId());
            RxDocumentServiceRequest request = getStoredProcedureRequest(collectionLink, storedProcedure, options,
                    OperationType.Create);

            return this.doCreate(request).map(response -> toResourceResponse(response, StoredProcedure.class));

        } catch (Exception e) {
            // this is only in trace level to capture what's going on
            logger.debug("Failure in creating a StoredProcedure due to [{}]", e.getMessage(), e);
            return Observable.error(e);
        }
    });
}
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:26,代码来源:RxDocumentClientImpl.java

示例3: upsertStoredProcedure

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
@Override
public Observable<ResourceResponse<StoredProcedure>> upsertStoredProcedure(String collectionLink,
        StoredProcedure storedProcedure, RequestOptions options) {
    return Observable.defer(() -> {
        // we are using an observable factory here
        // observable will be created fresh upon subscription
        // this is to ensure we capture most up to date information (e.g.,
        // session)
        try {

            logger.debug("Upserting a StoredProcedure. collectionLink: [{}], storedProcedure id [{}]",
                    collectionLink, storedProcedure.getId());
            RxDocumentServiceRequest request = getStoredProcedureRequest(collectionLink, storedProcedure, options,
                    OperationType.Upsert);

            return this.doUpsert(request).map(response -> toResourceResponse(response, StoredProcedure.class));

        } catch (Exception e) {
            // this is only in trace level to capture what's going on
            logger.debug("Failure in upserting a StoredProcedure due to [{}]", e.getMessage(), e);
            return Observable.error(e);
        }
    });
}
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:25,代码来源:RxDocumentClientImpl.java

示例4: createStoredProcedure

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
@Test(groups = { "simple" }, timeOut = TIMEOUT)
public void createStoredProcedure() throws Exception {

    // create a stored procedure
    StoredProcedure storedProcedureDef = new StoredProcedure();
    storedProcedureDef.setId(UUID.randomUUID().toString());
    storedProcedureDef.setBody("function() {var x = 10;}");

    Observable<ResourceResponse<StoredProcedure>> createObservable = client.createStoredProcedure(getCollectionLink(), storedProcedureDef, null);

    // validate stored procedure creation
    ResourceResponseValidator<StoredProcedure> validator = new ResourceResponseValidator.Builder<StoredProcedure>()
            .withId(storedProcedureDef.getId())
            .withBody("function() {var x = 10;}")
            .notNullEtag()
            .build();
    validateSuccess(createObservable, validator);
}
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:19,代码来源:StoredProcedureCrudTest.java

示例5: readStoredProcedure

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
@Test(groups = { "simple" }, timeOut = TIMEOUT)
public void readStoredProcedure() throws Exception {
    // create a stored procedure
    StoredProcedure storedProcedureDef = new StoredProcedure();
    storedProcedureDef.setId(UUID.randomUUID().toString());
    storedProcedureDef.setBody("function() {var x = 10;}");
    StoredProcedure storedProcedure = client.createStoredProcedure(getCollectionLink(), storedProcedureDef, null).toBlocking().single().getResource();

    // read stored procedure
    Observable<ResourceResponse<StoredProcedure>> readObservable = client.readStoredProcedure(storedProcedure.getSelfLink(), null);


    ResourceResponseValidator<StoredProcedure> validator = new ResourceResponseValidator.Builder<StoredProcedure>()
            .withId(storedProcedureDef.getId())
            .withBody("function() {var x = 10;}")
            .notNullEtag()
            .build();
    validateSuccess(readObservable, validator);
}
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:20,代码来源:StoredProcedureCrudTest.java

示例6: deleteStoredProcedure

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
@Test(groups = { "simple" }, timeOut = TIMEOUT)
public void deleteStoredProcedure() throws Exception {
    // create a stored procedure
    StoredProcedure storedProcedureDef = new StoredProcedure();
    storedProcedureDef.setId(UUID.randomUUID().toString());
    storedProcedureDef.setBody("function() {var x = 10;}");
    StoredProcedure storedProcedure = client.createStoredProcedure(getCollectionLink(), storedProcedureDef, null).toBlocking().single().getResource();

    // delete
    Observable<ResourceResponse<StoredProcedure>> deleteObservable = client.deleteStoredProcedure(storedProcedure.getSelfLink(), null);

    // validate
    ResourceResponseValidator<StoredProcedure> validator = new ResourceResponseValidator.Builder<StoredProcedure>()
            .nullResource()
            .build();
    validateSuccess(deleteObservable, validator);

    //TODO validate after deletion the resource is actually deleted (not found)
}
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:20,代码来源:StoredProcedureCrudTest.java

示例7: executeStoredProcWithArgs

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
@Test
public void executeStoredProcWithArgs() throws DocumentClientException {
    // create stored procedure
    StoredProcedure storedProcedure = new StoredProcedure(
            "{" +
                    "  'id': 'multiplySample'," +
                    "  'body':" +
                    "    'function (value, num) {" +
                    "      getContext().getResponse().setBody(" +
                    "          \"2*\" + value + \" is \" + num * 2 );" +
                    "    }'" +
            "}");

    client.createStoredProcedure(collection.getSelfLink(), storedProcedure, null).getResource();

    // execute stored procedure
    RequestOptions requestOptions = new RequestOptions();
    requestOptions.setPartitionKey(new PartitionKey("Seattle"));

    String storedProcLink = String.format("/dbs/%s/colls/%s/sprocs/%s", databaseId, collectionId, "multiplySample");

    Object[] storedProcedureArgs = new Object[] {"a", 123};
    String storedProcResultAsString = client.executeStoredProcedure(storedProcLink, requestOptions, storedProcedureArgs).getResponseAsString();
    assertThat(storedProcResultAsString, equalTo("\"2*a is 246\""));
}
 
开发者ID:Azure,项目名称:azure-documentdb-java,代码行数:26,代码来源:StoredProcedureSamples.java

示例8: executeWriteStoredProcedure

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
/**
 * Executes the bulk import stored procedure for a list of documents.
 * The execution takes into consideration throttling and blacklisting of the stored procedure.
 * @param client The DocumentClient instance for DocumentDB
 * @param collectionSelfLink the self-link for the collection to write to.
 * @param sproc The stored procedure to execute
 * @param allDocs The list of documents to write
 * @param upsert  Specifies whether to replace the document if exists or not. By default it's true.
 */
public static void executeWriteStoredProcedure(final DocumentClient client, String collectionSelfLink, final StoredProcedure sproc,
        List<Document> allDocs, final boolean upsert) {
    
    int currentCount = 0;
        
    while (currentCount < allDocs.size())
        {
        String []jsonArrayString = CreateBulkInsertScriptArguments(allDocs, currentCount, MAX_SCRIPT_SIZE);
        BackoffExponentialRetryPolicy retryPolicy = new BackoffExponentialRetryPolicy();
        String response = null;
        while(retryPolicy.shouldRetry()){
            try {
                response = client.executeStoredProcedure(sproc.getSelfLink(), new Object[] { jsonArrayString, upsert })
                    .getResponseAsString();
                break;
            } catch(Exception e){
                retryPolicy.errorOccured(e);  
            }
        }

        int createdCount = Integer.parseInt(response);
        currentCount += createdCount;
    }
}
 
开发者ID:Azure,项目名称:azure-documentdb-hadoop,代码行数:34,代码来源:DocumentDBConnectorUtil.java

示例9: DocumentDBRecordWriter

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
public DocumentDBRecordWriter(Configuration conf, String host, String key, String dbName, String[] collNames,
        int outputStringPrecision, boolean upsert, String offerType) throws IOException {
    try {
        ConnectionPolicy policy = ConnectionPolicy.GetDefault();
        policy.setUserAgentSuffix(DocumentDBConnectorUtil.UserAgentSuffix);
        DocumentClient client = new DocumentClient(host, key, policy,
                ConsistencyLevel.Session);

        Database db = DocumentDBConnectorUtil.GetDatabase(client, dbName);
        this.collections = new DocumentCollection[collNames.length];
        this.sprocs = new StoredProcedure[collNames.length];
        for (int i = 0; i < collNames.length; i++) {
            this.collections[i] =  DocumentDBConnectorUtil.getOrCreateOutputCollection(client, db.getSelfLink(), collNames[i],
                    outputStringPrecision, offerType);
            this.sprocs[i] = DocumentDBConnectorUtil.CreateBulkImportStoredProcedure(client, this.collections[i].getSelfLink());
        }
        
        this.client = client;
        this.enableUpsert = upsert;
        this.cachedDocs = new LinkedList<Document>();
    } catch (Exception e) {
        e.printStackTrace();
        throw new IOException(e);
    }
}
 
开发者ID:Azure,项目名称:azure-documentdb-hadoop,代码行数:26,代码来源:DocumentDBRecordWriter.java

示例10: deleteStoredProcedure

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
@Override
public Observable<ResourceResponse<StoredProcedure>> deleteStoredProcedure(String storedProcedureLink,
        RequestOptions options) {
    return Observable.defer(() -> {
        // we are using an observable factory here
        // observable will be created fresh upon subscription
        // this is to ensure we capture most up to date information (e.g.,
        // session)
        try {

            if (StringUtils.isEmpty(storedProcedureLink)) {
                throw new IllegalArgumentException("storedProcedureLink");
            }

            logger.debug("Deleting a StoredProcedure. storedProcedureLink [{}]", storedProcedureLink);
            String path = Utils.joinPath(storedProcedureLink, null);
            Map<String, String> requestHeaders = this.getRequestHeaders(options);
            RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Delete,
                    ResourceType.StoredProcedure, path, requestHeaders);

            return this.doDelete(request).map(response -> toResourceResponse(response, StoredProcedure.class));

        } catch (Exception e) {
            // this is only in trace level to capture what's going on
            logger.debug("Failure in deleting a StoredProcedure due to [{}]", e.getMessage(), e);
            return Observable.error(e);
        }
    });
}
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:30,代码来源:RxDocumentClientImpl.java

示例11: readStoredProcedure

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
@Override
public Observable<ResourceResponse<StoredProcedure>> readStoredProcedure(String storedProcedureLink,
        RequestOptions options) {

    return Observable.defer(() -> {
        // we are using an observable factory here
        // observable will be created fresh upon subscription
        // this is to ensure we capture most up to date information (e.g.,
        // session)
        try {

            if (StringUtils.isEmpty(storedProcedureLink)) {
                throw new IllegalArgumentException("storedProcedureLink");
            }

            logger.debug("Reading a StoredProcedure. storedProcedureLink [{}]", storedProcedureLink);
            String path = Utils.joinPath(storedProcedureLink, null);
            Map<String, String> requestHeaders = this.getRequestHeaders(options);
            RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Read,
                    ResourceType.StoredProcedure, path, requestHeaders);

            return this.doRead(request).map(response -> toResourceResponse(response, StoredProcedure.class));

        } catch (Exception e) {
            // this is only in trace level to capture what's going on
            logger.debug("Failure in reading a StoredProcedure due to [{}]", e.getMessage(), e);
            return Observable.error(e);
        }
    });

}
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:32,代码来源:RxDocumentClientImpl.java

示例12: createStoredProcedure

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
@Override
public Observable<ResourceResponse<StoredProcedure>> createStoredProcedure(final String collectionLink, final
        StoredProcedure storedProcedure, final RequestOptions options) {
    return this.createResourceResponseObservable(new ImplFunc<ResourceResponse<StoredProcedure>>() {
        @Override
        public ResourceResponse<StoredProcedure> invoke() throws Exception {
            return client.createStoredProcedure(collectionLink, storedProcedure, options);
        }
    });
}
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:11,代码来源:RxWrapperDocumentClientImpl.java

示例13: upsertStoredProcedure

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
@Override
public Observable<ResourceResponse<StoredProcedure>> upsertStoredProcedure(final String collectionLink, final
        StoredProcedure storedProcedure, final RequestOptions options) {
    return this.createResourceResponseObservable(new ImplFunc<ResourceResponse<StoredProcedure>>() {
        @Override
        public ResourceResponse<StoredProcedure> invoke() throws Exception {
            return client.upsertStoredProcedure(collectionLink, storedProcedure, options);
        }
    });
}
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:11,代码来源:RxWrapperDocumentClientImpl.java

示例14: replaceStoredProcedure

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
@Override
public Observable<ResourceResponse<StoredProcedure>> replaceStoredProcedure(final StoredProcedure storedProcedure, final
        RequestOptions options) {
    return this.createResourceResponseObservable(new ImplFunc<ResourceResponse<StoredProcedure>>() {
        @Override
        public ResourceResponse<StoredProcedure> invoke() throws Exception {
            return client.replaceStoredProcedure(storedProcedure, options);
        }
    });
}
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:11,代码来源:RxWrapperDocumentClientImpl.java

示例15: deleteStoredProcedure

import com.microsoft.azure.documentdb.StoredProcedure; //导入依赖的package包/类
@Override
public Observable<ResourceResponse<StoredProcedure>> deleteStoredProcedure(final String storedProcedureLink, final
        RequestOptions options) {
    return this.createResourceResponseObservable(new ImplFunc<ResourceResponse<StoredProcedure>>() {
        @Override
        public ResourceResponse<StoredProcedure> invoke() throws Exception {
            return client.deleteStoredProcedure(storedProcedureLink, options);
        }
    });
}
 
开发者ID:Azure,项目名称:azure-documentdb-rxjava,代码行数:11,代码来源:RxWrapperDocumentClientImpl.java


注:本文中的com.microsoft.azure.documentdb.StoredProcedure类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。