Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This issue stems from what is currently expected of a ServiceDeploymentContributor in its contributeService method.
Basically each service deployment contributor is expected to build its own filter chain.
This is currently done by making calls to Deploymentcontext.contributeFilter.
While this provides a great deal of flexibility for each service to define a custom chain we have found that this isn't commonly necessary.
Furthermore it makes if very difficult if not impossible to introduce new provider/filters without impacting all services.
This design will provide an abstraction to the service deployment contributors that can create either a default or specifically configured chain of providers/filters.

The goal is to support a pattern in service deployment contributors that looks like this:

Code Block
java
java
titleServiceDeploymentContributor.contributeService
linenumberstrue
  public void contributeService( DeploymentContext context, Service service ) throws Exception {
    List<ServiceParamDescriptor> params = null; // Default if null, otherwise map of per provider role map of name/value pairs.  
    ResourceDescriptor resource = context.addResource()
    resource.role( "WEBHDFS" );
    resource.pattern( "webhdfs/v1/**?**" );
    context.contributeChain( service, resource, params );
  }

The over all context into which the method above fits into the deployment infrastructure is shown in the sequence diagram below.

PlantUML
@startuml
title Contribute Chain
hide footbox
autonumber

participant "Deployment\nFactory\n(df)" as df
participant "Deployment\nContext\n(dc)" as dc
participant "Service\nDeployment\nContributor\n(sdc)" as sdc
participant "Provider\nDeployment\nContributor\n(pdc)" as pdc

activate df
create dc
df -> dc: new
df -> sdc: contributeService(dc)
  activate sdc
  sdc -> dc: contributeChain()
    activate dc
    dc -> pdc: contributeFilter()
    deactivate dc
  sdc --> df
  deactivate sdc
deactivate df
@endup

The method below shows a more complete example of a contributeService method as it might be implemented for WebHDFS.

Code Block
java
java
titleWebHdfsDeploymentContributor.contributeService
linenumberstrue
  public void contributeService( DeploymentContext context, Service service ) throws Exception {
    UrlRewriteRulesDescriptor serviceRules = loadRulesFromClassPath();
    UrlRewriteRulesDescriptor clusterRules = context.getDescriptor( "rewrite" );
    clusterRules.addRules( serviceRules );

    ResourceDescriptor resource;
    List<ServiceParamDescriptor> params;

    resource = context.getGatewayDescriptor().addResource();
    resource.role( "WEBHDFS" );
    resource.pattern( "webhdfs/v1/?**" );
    resource.pattern( "webhdfs/v1/**?**" );
    params = new ArrayList<ServiceParamDescriptor>();
    params.add( resource.createParam().role( "rewrite", "request.url", "/webhdfs/namenode/inbound/path" );
    params.add( resource.createParam().role( "rewrite", "response.headers", "/webhdfs/namenode/outbound/headers" );
    context.contributeChain( service, resource, params );

    resource = context.getGatewayDescriptor().addResource();
    nameNode.role( "WEBHDFS" );
    nameNode.pattern( "webhdfs/data/v1/**?**" );
    params = new ArrayList<ServiceParamDescriptor>();
    params.add( resource.createParam().role( "rewrite", "request.url", "/webhdfs/datanode/inbound/path" );
    context.contributeChain( service, resource, params );
  }

This is a sketch of how topology files would need to be extended to support the external chain definitions.

Code Block
xml
xml
titleSample Topology Descriptor
linenumberstrue
<topology>

  <gateway>

    <provider>
      <role>...</role>
      <name>...</name>
      <!-- Config for the provider. -->
      <param><name>...</name><value>...</value></param>
    </provider>

    <!-- NOTE: There will be a "built-in" "default" chain definition. -->  
    <chain>
      <name>...</name>
      <provider-ref>
        <role>...</role>
        <name>...</name>
        <!-- Config for the provider to override those in the provider. -->
        <param><name>...</name><value>...</value></param>
      </provider-ref>
      <provider-ref>...</provider-ref>
    </chain>
    <chain>...</chain>

  </gateway>

  <service>
    <role>...</role>
    <url>...</url>
    <chain-ref>
      <name>...</name>
      <!-- Config for the provider to override those in the chain. -->
      <param><role></role><name></name><value></value></param>
    </chain-ref>
    <!-- Config for the service. -->
    <param><name></name><value></value></param>
  </service>

</topology>

...