forked from apache/gobblin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GOBBLIN-334] Implement SharedResourceFactory for LineageInfo
Closes apache#2187 from zxcware/share
- Loading branch information
Showing
16 changed files
with
275 additions
and
35 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
gobblin-api/src/main/java/org/apache/gobblin/broker/StringNameSharedResourceKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.gobblin.broker; | ||
|
||
import org.apache.gobblin.broker.iface.SharedResourceKey; | ||
|
||
|
||
/** | ||
* A {@link SharedResourceKey} with only a string name | ||
*/ | ||
public class StringNameSharedResourceKey implements SharedResourceKey { | ||
private final String name; | ||
|
||
public StringNameSharedResourceKey(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String toConfigurationKey() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
|
||
StringNameSharedResourceKey that = (StringNameSharedResourceKey) o; | ||
|
||
return name != null ? name.equals(that.name) : that.name == null; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return name != null ? name.hashCode() : 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...blin-metrics-base/src/main/java/org/apache/gobblin/metrics/broker/LineageInfoFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.gobblin.metrics.broker; | ||
|
||
import org.apache.gobblin.broker.EmptyKey; | ||
import org.apache.gobblin.broker.ResourceInstance; | ||
import org.apache.gobblin.broker.gobblin_scopes.GobblinScopeTypes; | ||
import org.apache.gobblin.broker.iface.ConfigView; | ||
import org.apache.gobblin.broker.iface.NotConfiguredException; | ||
import org.apache.gobblin.broker.iface.ScopedConfigView; | ||
import org.apache.gobblin.broker.iface.SharedResourceFactory; | ||
import org.apache.gobblin.broker.iface.SharedResourceFactoryResponse; | ||
import org.apache.gobblin.broker.iface.SharedResourcesBroker; | ||
import org.apache.gobblin.metrics.event.lineage.LineageInfo; | ||
|
||
|
||
/** | ||
* A {@link SharedResourceFactory} to share a job level {@link LineageInfo} instance | ||
*/ | ||
public class LineageInfoFactory implements SharedResourceFactory<LineageInfo, EmptyKey, GobblinScopeTypes> { | ||
public static final String FACTORY_NAME = "lineageInfo"; | ||
|
||
@Override | ||
public String getName() { | ||
return FACTORY_NAME; | ||
} | ||
|
||
@Override | ||
public SharedResourceFactoryResponse<LineageInfo> createResource(SharedResourcesBroker<GobblinScopeTypes> broker, | ||
ScopedConfigView<GobblinScopeTypes, EmptyKey> config) | ||
throws NotConfiguredException { | ||
return new ResourceInstance<>(new LineageInfo(config.getConfig())); | ||
} | ||
|
||
@Override | ||
public GobblinScopeTypes getAutoScope(SharedResourcesBroker<GobblinScopeTypes> broker, ConfigView<GobblinScopeTypes, EmptyKey> config) { | ||
return GobblinScopeTypes.JOB; | ||
} | ||
} |
Oops, something went wrong.