Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions modules/classloaders/hdfs-class-loader/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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

https://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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.accumulo</groupId>
<artifactId>classloader-extras</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../../pom.xml</relativePath>
</parent>
<artifactId>hdfs-class-loader</artifactId>
<properties>
<eclipseFormatterStyle>../../../src/build/eclipse-codestyle.xml</eclipseFormatterStyle>
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
</properties>
<dependencies>
<dependency>
<!-- needed for build checks, but not for runtime -->
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<!-- provided by accumulo -->
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<!-- provided by accumulo -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<!-- provided by accumulo -->
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<!-- provided by accumulo -->
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<!-- provided by accumulo -->
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<!-- provided by accumulo -->
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client-minicluster</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>build-test-jars</id>
<goals>
<goal>exec</goal>
</goals>
<phase>process-test-classes</phase>
<configuration>
<executable>../jar-creation/shell/makeTestJars.sh</executable>
</configuration>
</execution>
<execution>
<id>build-helloworld-jars</id>
<goals>
<goal>exec</goal>
</goals>
<phase>process-test-classes</phase>
<configuration>
<executable>../jar-creation/shell/makeHelloWorldJars.sh</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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
*
* https://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.accumulo.classloader.hdfs;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;

public class ClassLoaderStore<K,V> {
private final ConcurrentMap<K,V> store = new ConcurrentHashMap<>();
private final Consumer<Map.Entry<K,V>> onRemove;

public ClassLoaderStore(Consumer<Map.Entry<K,V>> onRemove) {
this.onRemove = onRemove;
}

public V get(K key) {
return store.get(key);
}

public boolean isEmpty() {
return store.isEmpty();
}

public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction) {
return store.computeIfPresent(key, remappingFunction);
}

public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction) {
return store.computeIfAbsent(key, mappingFunction);
}

public void removeIf(Predicate<Map.Entry<K,V>> predicate) {
store.entrySet().removeIf(entry -> {
if (predicate.test(entry)) {
onRemove.accept(entry);
return true;
}
return false;
});
}
}
Loading