Apache Geode crud repository findById() returns the wrong array - spring-data-gemfire

I'm using apache geode 1.13.0
The data class is simple, it contains 1 ArrayList and 1 HashMap
The data is stored correctly on geode but then repository.findById() returns the wrong array and map
repository.findAll() works well though
the data is
id | someList | someMap
-- | --------- | ---------------------------------
1 | [1,2,3,4] | {"1":"a","2":"b","3":"c","4":"d"}
2 | [2,3,4] | {"4":"d","2":"b","3":"c"}
3 | [3,4] | {"4":"d","3":"c"}
4 | null | {"4":"d"}
5 | null | null
while the findById retrieves
Class1{id=1, someList=[3, 4], someMap={4=d}}
Class1{id=2, someList=[3, 4], someMap={4=d}}
Class1{id=3, someList=[3, 4], someMap={4=d}}
Class1{id=4, someList=null, someMap={4=d}}
Class1{id=5, someList=null, someMap=null}
the logic is in MyRunner.java
What could be the problem?
here's the class
....
#Region("TestRegion")
public class Class1 implements PdxSerializable {
#Id
Integer id;
ArrayList<Integer> someList;
HashMap<Integer, String> someMap;
public Class1() {}
public Class1(Integer id, ArrayList<Integer> someList, HashMap<Integer, String> someMap) {
this.id = id;
this.someList = someList;
this.someMap = someMap;
}
#Override
public String toString() {
String ret;
ret = "Class1";
ret += "{id=";
if (id == null) { ret += "null"; } else { ret += id.toString(); }
ret += ", someList=";
if (someList == null) { ret += "null"; } else { ret += someList.toString(); }
ret += ", someMap=";
if (someMap == null) { ret += "null"; } else { ret += someMap.toString(); }
ret += "}";
return ret;
}
#Override
public void toData(PdxWriter out) throws PdxFieldAlreadyExistsException, PdxSerializationException {
out.writeInt("id", id);
out.writeObject("someList", someList);
out.writeObject("someMap", someMap);
}
#Override
public void fromData(PdxReader in) throws PdxFieldTypeMismatchException, PdxSerializationException {
id = in.readInt("id");
someList = (ArrayList<Integer>)in.readObject("someList");
someMap = (HashMap<Integer, String>)in.readObject("someMap");
}
}
the repository
#Repository
public interface GeodeRepository extends CrudRepository<Class1, Integer> {
}
geode config class
.....
#EnableEntityDefinedRegions(basePackageClasses = Class1.class, clientRegionShortcut = ClientRegionShortcut.CACHING_PROXY)
#EnableGemfireRepositories(basePackageClasses = GeodeRepository.class)
#Configuration
class GeodeConfiguration {
}
main
....
#SpringBootApplication
class SpringbootCmdTest {
public static void main(String[] args) {
SpringApplication.run(SpringbootCmdTest.class, args);
}
}
MyRunner class
....
#Component
public class MyRunner implements CommandLineRunner {
#Autowired
private GeodeRepository repository;
#Override
public void run(String... args) throws Exception {
//repository.deleteAll(); // doesn't work for partitioned regions as of 2020-11-02 https://jira.spring.io/browse/DATAGEODE-265
repository.deleteAll(repository.findAll());
ArrayList<Integer> l = new ArrayList<>();
HashMap<Integer, String> m = new HashMap<>();
Class1 obj;
Optional<Class1> o;
l.clear(); l.add(1); l.add(2); l.add(3); l.add(4);
m.clear(); m.put(1, "a"); m.put(2, "b"); m.put(3, "c"); m.put(4, "d");
obj = new Class1(1, l, m);
repository.save(obj);
l.clear(); l.add(2); l.add(3); l.add(4);
m.clear(); m.put(2, "b"); m.put(3, "c"); m.put(4, "d");
obj = new Class1(2, l, m);
repository.save(obj);
l.clear(); l.add(3); l.add(4);
m.clear(); m.put(3, "c"); m.put(4, "d");
obj = new Class1(3, l, m);
repository.save(obj);
m.clear(); m.put(4, "d");
obj = new Class1(4, null, m);
repository.save(obj);
obj = new Class1(5, null, null);
repository.save(obj);
System.out.println("\n-- findAll().foreach works -------------------------------");
repository.findAll().forEach((item) ->System.out.println(item.toString()));
System.out.println("\n-- optional directly to string. issue with the array and map. displays the last entry --");
System.out.println(repository.findById(1).toString());
System.out.println(repository.findById(2).toString());
System.out.println(repository.findById(3).toString());
System.out.println(repository.findById(4).toString());
System.out.println(repository.findById(5).toString());
System.out.println("\n-- first convert the optional to object. issue with the array and map. displays the last entry --");
o = repository.findById(1);
o.ifPresent(ob -> System.out.println(ob.toString()));
o = repository.findById(2);
o.ifPresent(ob -> System.out.println(ob.toString()));
o = repository.findById(3);
o.ifPresent(ob -> System.out.println(ob.toString()));
o = repository.findById(4);
o.ifPresent(ob -> System.out.println(ob.toString()));
o = repository.findById(5);
o.ifPresent(ob -> System.out.println(ob.toString()));
System.out.println("\n-- findAllById().foreach does not work either -------------------------------");
ArrayList<Integer> il = new ArrayList<>();
il.add(1); il.add(2); il.add(3); il.add(4); il.add(5);
repository.findAllById(il).forEach((item) ->System.out.println(item.toString()));
System.out.println("\n---------------------------------");
}
}
application.properties
spring.profiles.active = dev
logging.level.org.springframework.boot = INFO
logging.level.org.springframework.transaction = TRACE
logging.level.owa = DEBUG
logging.file.name = Test.log
spring.main.banner-mode=off
spring.profiles.include=common
spring.data.gemfire.pool.locators = localhost[2001]
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/><!-- lookup parent from repository -->
</parent>
<groupId>org.Test</groupId>
<artifactId>SpringbootCmdTest</artifactId>
<version>20.10.0</version>
<name>SpringbootCmdTest</name>
<description>Springboot Cmd Line For Testing</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.geode</groupId>
<artifactId>spring-geode-starter</artifactId>
<version>1.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.geode</groupId>
<artifactId>geode-core</artifactId>
<version>1.13.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.8.1</version>
<executions>
<execution>
<goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>compileTests</goal>
<goal>removeStubs</goal>
<goal>removeTestStubs</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
gfsh query
gfsh>query --query="select * from /TestRegion"
Result : true
Limit : 100
Rows : 5
id | someList | someMap
-- | --------- | ---------------------------------
1 | [1,2,3,4] | {"1":"a","2":"b","3":"c","4":"d"}
2 | [2,3,4] | {"4":"d","2":"b","3":"c"}
3 | [3,4] | {"4":"d","3":"c"}
4 | null | {"4":"d"}
5 | null | null
output
-- findAll().foreach works -------------------------------
Class1{id=1, someList=[1, 2, 3, 4], someMap={1=a, 2=b, 3=c, 4=d}}
Class1{id=2, someList=[2, 3, 4], someMap={4=d, 2=b, 3=c}}
Class1{id=3, someList=[3, 4], someMap={4=d, 3=c}}
Class1{id=4, someList=null, someMap={4=d}}
Class1{id=5, someList=null, someMap=null}
-- optional directly to string. issue with the array and map. displays the last entry --
Optional[Class1{id=1, someList=[3, 4], someMap={4=d}}]
Optional[Class1{id=2, someList=[3, 4], someMap={4=d}}]
Optional[Class1{id=3, someList=[3, 4], someMap={4=d}}]
Optional[Class1{id=4, someList=null, someMap={4=d}}]
Optional[Class1{id=5, someList=null, someMap=null}]
-- first convert the optional to object. issue with the array and map. displays the last entry --
Class1{id=1, someList=[3, 4], someMap={4=d}}
Class1{id=2, someList=[3, 4], someMap={4=d}}
Class1{id=3, someList=[3, 4], someMap={4=d}}
Class1{id=4, someList=null, someMap={4=d}}
Class1{id=5, someList=null, someMap=null}
-- findAllById().foreach does not work either -------------------------------
Class1{id=1, someList=[3, 4], someMap={4=d}}
Class1{id=2, someList=[3, 4], someMap={4=d}}
Class1{id=3, someList=[3, 4], someMap={4=d}}
Class1{id=4, someList=null, someMap={4=d}}
Class1{id=5, someList=null, someMap=null}

Note: This behavior is not exclusive to Spring and can be reproduced using Apache Geode alone.
Because you have clientRegionShortcut set to ClientRegionShortcut.CACHING_PROXY, your data is stored both on the server and on the client in a local region. When you access data by id, the local region is checked first, and if the entry is found, it is returned, if it isn't found, it will call out to the server for it.
The reason you're seeing only the most recent values of your list and map is because the local region is holding on to m and l by reference, so when you reuse them and update their contents, the values stored in the local region reflect the change as well, even without saving them. You see the correct values for findAll() and your query because those delegate to the server directly (which doesn't hold the values by reference because it's a separate machine/process) rather than the local region.
There are a couple ways you can get the behavior you expect:
Option 1. Change ClientRegionShortcut.CACHING_PROXY to ClientRegionShortcut.PROXY so the values won't be stored locally and will instead be retrieved from the server every time.
Option 2. You can create a new ArrayList and HashMap every time you want to add an entry instead of reusing the same objects. For example, replacing l.clear() and m.clear() with l = new ArrayList<>() and m = new HashMap<>().

Related

Spring boot data R2DBC requires transaction for read operations

Im trying to fetch a list of objects from the database using Spring boot Webflux with the postgres R2DBC driver, but I get an error saying:
value ignored org.springframework.transaction.reactive.TransactionContextManager$NoTransactionInContextException: No transaction in context Context1{reactor.onNextError.localStrategy=reactor.core.publisher.OnNextFailureStrategy$ResumeStrategy#7c18c255}
it seems all DatabaseClient operations requires to be wrap into a transaction.
I tried different combinations of the dependencies between spring-boot-data and r2db but didn't really work.
Version:
<spring-boot.version>2.2.0.RC1</spring-boot.version>
<spring-data-r2dbc.version>1.0.0.BUILD-SNAPSHOT</spring-data-r2dbc.version>
<r2dbc-releasetrain.version>Arabba-M8</r2dbc-releasetrain.version>
Dependencies:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-r2dbc</artifactId>
<version>${spring-data-r2dbc.version}</version>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-bom</artifactId>
<version>${r2dbc-releasetrain.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
fun findAll(): Flux<Game> {
val games = client
.select()
.from(Game::class.java)
.fetch()
.all()
.onErrorContinue{ throwable, o -> System.out.println("value ignored $throwable $o") }
games.subscribe()
return Flux.empty()
}
#Table("game")
data class Game(#Id val id: UUID = UUID.randomUUID(),
#Column("guess") val guess: Int = Random.nextInt(500))
Github repo: https://github.com/odfsoft/spring-boot-guess-game/tree/r2dbc-issue
I expect read operations to not require #Transactional or to run the query without wrapping into the transactional context manually.
UPDATE:
After a few tries with multiple version I manage to find a combination that works:
<spring-data-r2dbc.version>1.0.0.BUILD-SNAPSHOT</spring-data-r2dbc.version>
<r2dbc-postgres.version>0.8.0.RC2</r2dbc-postgres.version>
Dependencies:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-r2dbc</artifactId>
<version>${spring-data-r2dbc.version}</version>
</dependency>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-postgresql</artifactId>
<version>${r2dbc-postgres.version}</version>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-bom</artifactId>
<version>Arabba-RC2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
it seems the versions notation went from 1.0.0.M7 to 0.8.x for r2dbc due to the following:
https://r2dbc.io/2019/05/13/r2dbc-0-8-milestone-8-released
https://r2dbc.io/2019/10/07/r2dbc-0-8-rc2-released
but after updating to the latest version a new problem appear which is that a transaction is required to run queries as follow:
Update configuration:
#Configuration
class PostgresConfig : AbstractR2dbcConfiguration() {
#Bean
override fun connectionFactory(): ConnectionFactory {
return PostgresqlConnectionFactory(
PostgresqlConnectionConfiguration.builder()
.host("localhost")
.port(5432)
.username("root")
.password("secret")
.database("game")
.build())
}
#Bean
fun reactiveTransactionManager(connectionFactory: ConnectionFactory): ReactiveTransactionManager {
return R2dbcTransactionManager(connectionFactory)
}
#Bean
fun transactionalOperator(reactiveTransactionManager: ReactiveTransactionManager) =
TransactionalOperator.create(reactiveTransactionManager)
}
Query:
fun findAll(): Flux<Game> {
return client
.execute("select id, guess from game")
.`as`(Game::class.java)
.fetch()
.all()
.`as`(to::transactional)
.onErrorContinue{ throwable, o -> System.out.println("value ignored $throwable $o") }
.log()
}
Disclaimer this is not mean to be used in production!! still before GA.

What version of H2O gen-model maven library supports XGBoost MOJO's?

I am trying to use XGBoost MOJO created and downloaded from H2O in runtime using java, but I am getting errors while compiling. I have tries multiple different versions of dependencies but couldn't get through it.
Dependencies :
<dependency>
<groupId>ai.h2o</groupId>
<artifactId>h2o-genmodel</artifactId>
<version>3.22.1.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ai.h2o/h2o-genmodel-ext-xgboost -->
<dependency>
<groupId>ai.h2o</groupId>
<artifactId>h2o-genmodel-ext-xgboost</artifactId>
<version>3.24.0.1</version>
<type>pom</type>
</dependency>
Main.java
import hex.genmodel.easy.EasyPredictModelWrapper;
import hex.genmodel.easy.RowData;
import hex.genmodel.easy.prediction.BinomialModelPrediction;
public class Main {
public static void main(String[] args) throws Exception {
EasyPredictModelWrapper model = new EasyPredictModelWrapper(
MojoModel.load("/Users/p0g0085/Downloads/grid_5dd10c7e_297d_42eb_b422_56c687ba85df_model_18.zip"));
RowData row = new RowData();
row.put("brand", "Great Value");
row.put("product_type", "Cheeses");
row.put("duration", "21.0");
row.put("quantity", "1.0");
row.put("ghs_frequency", "11.3714");
BinomialModelPrediction p = model.predictBinomial(row);
System.out.println("Has penetrated the prostatic capsule (1=yes; 0=no): " + p.label);
System.out.print("Class probabilities: ");
for (int i = 0; i < p.classProbabilities.length; i++) {
if (i > 0) {
System.out.print(",");
}
System.out.print(p.classProbabilities[i]);
}
System.out.println("");
}
}
Error :
Exception in thread "main" java.lang.IllegalStateException: Algorithm `XGBoost` is not supported by this version of h2o-genmodel. If you are using an algorithm implemented in an extension, be sure to include a jar dependency of the extension (eg.: ai.h2o:h2o-genmodel-ext-xgboost)
at hex.genmodel.ModelMojoFactory.getMojoReader(ModelMojoFactory.java:102)
at hex.genmodel.ModelMojoReader.readFrom(ModelMojoReader.java:31)
at hex.genmodel.MojoModel.load(MojoModel.java:37)
at Main.main(Main.java:9)
It took me a while to figure out. Below dependency worked for me.
<dependency>
<groupId>ai.h2o</groupId>
<artifactId>h2o-genmodel-ext-xgboost</artifactId>
<version>3.22.0.3</version>
</dependency>

datanucleus neo4j - Unable to obtain lock on store lock file

I am developing an WebApp that uses datanucleus as JPA - Provider and Neo4j as No-SQL database.
My dependencies are
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>[5.0.0-m1, 5.9)</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jpa</artifactId>
<version>[5.0.0-m1, 5.9)</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>[1.2, 1.3)</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-neo4j</artifactId>
<version>[5.0.0-m1, 5.9)</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>2.3.0</version>
</dependency>
My persistence.xml looks like
<persistence-unit name="neo4j">
<provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
<class>entities.Person</class>
<class>entities.Car</class>
<exclude-unlisted-classes/>
<properties>
<property name="javax.persistence.jdbc.url" value="neo4j:C:\Users\phe\Documents\Neo4j\sampledatanucleus"/>
<!-- <property name="datanucleus.storeManagerType" value="neo4j"/> -->
<property name="datanucleus.storeManagerType" value="neo4j"/>
</properties>
</persistence-unit>
I am persisting the entities like this
Person person = new Person(personName, personAge);
Car car = new Car(carName);
car.setOwner(person);
person.getCars().add(car);
em.persist(person);
When persisting the entities I get an exception:
Caused by: org.neo4j.kernel.StoreLockException: Unable to obtain lock on store lock file: C:\Users\phe\Documents\Neo4j\sampledatanucleus\store_lock. Please ensure no other process is using this database, and that the directory is writable (required even for read-only access)
at org.neo4j.kernel.StoreLocker.storeLockException(StoreLocker.java:93)
at org.neo4j.kernel.StoreLocker.checkLock(StoreLocker.java:85)
at org.neo4j.kernel.StoreLockerLifecycleAdapter.start(StoreLockerLifecycleAdapter.java:44)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:528)
... 153 more
This makes me crazy. The directory I defined in the perstistence.xml is empty when I start the applictaion. Therefore it is impossible that it is locked by another process. DataNucleus then creates the database. I can access it with Neo4j Browser. But Persisting does not work.
Any ideas?
EDIT:
This is the class I use for querying
#Stateless
public class Manager {
#PersistenceContext(unitName = "neo4j")
private EntityManager em;
public List<Person> queryCache() {
String statement = "Select o from Person o";
Query query = em.createQuery(statement, Person.class);
List<Person> list = query.getResultList();
em.close();
return list;
}
public void save(String personName, Double personAge, String carName) {
Person person = new Person(personName, personAge);
Car car = new Car(carName);
car.setOwner(person);
person.getCars().add(car);
em.persist(person);
}
}
These two methods get called by the controller when clicking the corresponding buttons on the view.

hadoop 2.6 cluster cannot be initialized. Successfully run with local jars, but not maven dependency

I'm trying to debug wordcount sample using apache hadoop 2.6.0.I create the project in eclipse. My first try was configure the build path and include all the hadoop jar files (extracted from hadoop folder) in the buildpath. I can successfully run the word count and get the result. Then my second try is to make this project a 'maven' project and using pom.xml to specify needed hadoop jars (and remove local jars in buildpath). Here comes the problem. This time exception throws as follows:
Exception in thread "main" java.io.IOException: Cannot initialize Cluster. Please check your configuration for mapreduce.framework.name and the correspond server addresses.
at org.apache.hadoop.mapreduce.Cluster.initialize(Cluster.java:120)
at org.apache.hadoop.mapreduce.Cluster.<init>(Cluster.java:82)
at org.apache.hadoop.mapreduce.Cluster.<init>(Cluster.java:75)
at org.apache.hadoop.mapreduce.Job$9.run(Job.java:1266)
at org.apache.hadoop.mapreduce.Job$9.run(Job.java:1262)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1628)
at org.apache.hadoop.mapreduce.Job.connect(Job.java:1261)
at org.apache.hadoop.mapreduce.Job.submit(Job.java:1290)
at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1314)
at WordCount.main(WordCount.java:59)
My wordcount code is pretty simple and classic wordcount.
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
public class WordCount {
public static class TokenizerMapper
extends Mapper<Object, Text, Text, IntWritable>{
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
StringTokenizer itr = new StringTokenizer(value.toString());
while (itr.hasMoreTokens()) {
word.set(itr.nextToken());
context.write(word, one);
}
}
}
public static class IntSumReducer
extends Reducer<Text,IntWritable,Text,IntWritable> {
private IntWritable result = new IntWritable();
public void reduce(Text key, Iterable<IntWritable> values,
Context context
) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
result.set(sum);
context.write(key, result);
}
}
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
Job job = Job.getInstance(conf, "word count");
job.setJarByClass(WordCount.class);
job.setMapperClass(TokenizerMapper.class);
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.addInputPath(job, new Path("/home/jsun/share/wc/input"));
FileOutputFormat.setOutputPath(job, new Path("/home/jsun/share/wc/output"));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}
And the pom.xml for maven:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/1/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>wordcount2</groupId>
<artifactId>wordcount2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<repository>
<id>apache</id>
<url>http://central.maven.org/maven2/</url>
</repository>
</repositories>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
<version>2.6.0</version>
<type>jar</type>
</dependency>
</dependencies>
</project>
What is the difference using local hadoop jars and using maven dependencies?
Is that a problem of cluster or the wordcount or using maven?
Thanks in advance.
please check this Link
i had the same issue and i don't have hadoop installed on my machine. you can't run the program without installation. i think it looks for some environment variables to run hadoop commands.
Hope this helps

#NotNull annotation is not checking null queryparameter in Jersey REST resource

I am trying to use javax.validation.validation-api for validating #QueryParam parameters. I have followed steps as below:
Added dependency:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.ext</groupId>
<artifactId>jersey-bean-validation</artifactId>
<version>2.12</version>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
</exclusions>
</dependency>
Jersey resource:
#GET
#Produces(MediaType.APPLICATION_JSON)
#Path("/{param1}")
#ValidateOnExecution
public SomeObject get(#PathParam("param1") String param1,
#NotNull #QueryParam("q1") String q1,
#NotNull #QueryParam("q2") String q2) {
try {
//Assuming q1 and q2 are NOT Null here
...
} catch(Exception exception) {
throw new WebApplicationException(exception,
Response.Status.INTERNAL_SERVER_ERROR);
}
return someObject;
}
I tried giving various combination of URLs as in q1 and q2 both parameters absent, q1 absent or q2 absent. Each time, #NotNull is not getting detected. Means try block code is getting executed irrespective of q1 and q2 being null.
What else needs to be done?
I referred this link - https://jersey.java.net/documentation/latest/bean-validation.html#d0e11956.
How to check Auto-Discoverable feature is on in my environment?