forked from apache/nifi
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial setup of API and creation in FlowController
- Loading branch information
Showing
7 changed files
with
253 additions
and
0 deletions.
There are no files selected for viewing
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
36 changes: 36 additions & 0 deletions
36
nifi-framework-api/src/main/java/org/apache/nifi/nar/NarManager.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,36 @@ | ||
/* | ||
* 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.nifi.nar; | ||
|
||
import org.apache.nifi.bundle.BundleCoordinate; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Set; | ||
|
||
public interface NarManager { | ||
|
||
void initialize(NarManagerInitializationContext initializationContext) throws IOException; | ||
|
||
void shutdown(); | ||
|
||
BundleCoordinate addNar(String filename, InputStream inputStream); | ||
|
||
Set<BundleCoordinate> getNars(); | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
nifi-framework-api/src/main/java/org/apache/nifi/nar/NarManagerException.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,29 @@ | ||
/* | ||
* 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.nifi.nar; | ||
|
||
public class NarManagerException extends RuntimeException { | ||
|
||
public NarManagerException(final String message) { | ||
super(message); | ||
} | ||
|
||
public NarManagerException(final String message, final Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
nifi-framework-api/src/main/java/org/apache/nifi/nar/NarManagerInitializationContext.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,31 @@ | ||
/* | ||
* 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.nifi.nar; | ||
|
||
import org.apache.nifi.components.PropertyValue; | ||
|
||
import java.util.Map; | ||
|
||
public interface NarManagerInitializationContext { | ||
|
||
/** | ||
* @return the properties that have been configured for the NarManager | ||
*/ | ||
Map<String, String> getProperties(); | ||
|
||
} |
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
69 changes: 69 additions & 0 deletions
69
...i-framework/nifi-framework-core/src/main/java/org/apache/nifi/nar/StandardNarManager.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,69 @@ | ||
/* | ||
* 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.nifi.nar; | ||
|
||
import org.apache.nifi.bundle.BundleCoordinate; | ||
import org.apache.nifi.util.StringUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public class StandardNarManager implements NarManager { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(StandardNarManager.class); | ||
|
||
private static final String DIRECTORY_PROPERTY = "directory"; | ||
|
||
private volatile String directory; | ||
|
||
@Override | ||
public void initialize(final NarManagerInitializationContext initializationContext) throws IOException { | ||
directory = getRequiredValue(initializationContext, DIRECTORY_PROPERTY); | ||
// TODO ensure location exists | ||
LOGGER.info("Initialization completed - NARs will be stored at [{}]", directory); | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
// TODO | ||
} | ||
|
||
@Override | ||
public BundleCoordinate addNar(final String filename, final InputStream inputStream) { | ||
// TODO | ||
return null; | ||
} | ||
|
||
@Override | ||
public Set<BundleCoordinate> getNars() { | ||
// TODO | ||
return null; | ||
} | ||
|
||
private String getRequiredValue(final NarManagerInitializationContext initializationContext, final String property) { | ||
final Map<String, String> properties = initializationContext.getProperties(); | ||
final String value = properties.get(property); | ||
if (StringUtils.isBlank(value)) { | ||
throw new IllegalStateException("Missing required property: " + property); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ework-core/src/main/java/org/apache/nifi/nar/StandardNarManagerInitializationContext.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,36 @@ | ||
/* | ||
* 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.nifi.nar; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
public class StandardNarManagerInitializationContext implements NarManagerInitializationContext { | ||
|
||
private final Map<String, String> properties; | ||
|
||
public StandardNarManagerInitializationContext(final Map<String, String> properties) { | ||
this.properties = properties == null ? Collections.emptyMap() : Map.copyOf(properties); | ||
} | ||
|
||
@Override | ||
public Map<String, String> getProperties() { | ||
return properties; | ||
} | ||
|
||
} |