...
Code Block |
---|
| java |
---|
| java |
---|
title | ServiceDeploymentContributor.contributeService |
---|
linenumbers | true |
---|
|
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
|
...
Code Block |
---|
| java |
---|
| java |
---|
title | WebHdfsDeploymentContributor.contributeService |
---|
linenumbers | true |
---|
|
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();
resource.role( "WEBHDFS" );
resource.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 );
}
|
...
Code Block |
---|
| xml |
---|
| xml |
---|
title | Sample Topology Descriptor |
---|
linenumbers | true |
---|
|
<topology>
<gateway>
<provider>
<role>...</role>
<name>...</name>
<param><name>...</name><value>...</value></param>
</provider>
<chain>
<name>...</name>
<provider-ref>
<role>...</role>
<name>...</name>
<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>
<param><role></role><name></name><value></value></param>
</chain-ref>
<param><name></name><value></value></param>
</service>
</topology>
|
...
Code Block |
---|
| java |
---|
| java |
---|
title | DeploymentContext |
---|
linenumbers | true |
---|
|
public interface DeploymentContext {
...
@Deprecated
void contributeFilter(
Service service,
ResourceDescriptor resource,
String role,
String name,
List<FilterParamDescriptor> params );
void contributeChain(
Service service,
ResourceDescriptor resource,
List<ServiceParamDescriptor> params );
...
}
|
...
Code Block |
---|
| java |
---|
| java |
---|
title | ServiceDeploymentContributor |
---|
linenumbers | true |
---|
|
public interface ServiceDeploymentContributor {
...
// Called per service based on the service's role.
void contributeService( DeploymentContext context, Service service ) throws Exception;
...
}
|
...
Code Block |
---|
| java |
---|
| java |
---|
title | ProviderDeploymentContributor |
---|
linenumbers | true |
---|
|
public interface ProviderDeploymentContributor {
...
// This will be called indirectly by a ServiceDeploymentContributor when it asks
// for a chain to be contributed via DeploymentContext.contributeChain.
void contributeFilter(
DeploymentContext context,
Provider provider,
Service service,
ResourceDescriptor resource,
List<FilterParamDescriptor> params );
...
}
|