-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added HadoopSession Pooling Libs. Fixed lcd issue not making adjustme…
…nt to local current dir.
- Loading branch information
Showing
10 changed files
with
85 additions
and
22 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
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
20 changes: 20 additions & 0 deletions
20
src/main/java/com/streever/hadoop/HadoopSessionFactory.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,20 @@ | ||
package com.streever.hadoop; | ||
|
||
import org.apache.commons.pool2.BasePooledObjectFactory; | ||
import org.apache.commons.pool2.PooledObject; | ||
import org.apache.commons.pool2.impl.DefaultPooledObject; | ||
|
||
public class HadoopSessionFactory extends BasePooledObjectFactory<HadoopSession> { | ||
@Override | ||
public HadoopSession create() throws Exception { | ||
String[] api = {"-api"}; | ||
HadoopSession rtn = new HadoopSession(); | ||
rtn.start(api); | ||
return rtn; | ||
} | ||
|
||
@Override | ||
public PooledObject<HadoopSession> wrap(HadoopSession hadoopSession) { | ||
return new DefaultPooledObject<HadoopSession>(hadoopSession); | ||
} | ||
} |
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,30 @@ | ||
package com.streever.hadoop; | ||
|
||
import org.apache.commons.pool2.ObjectPool; | ||
|
||
public class HadoopSessionPool { | ||
|
||
private ObjectPool<HadoopSession> pool; | ||
|
||
public HadoopSessionPool(ObjectPool<HadoopSession> pool) { | ||
this.pool = pool; | ||
} | ||
|
||
public HadoopSession borrow() { | ||
HadoopSession rtn = null; | ||
try { | ||
rtn = pool.borrowObject(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
return rtn; | ||
} | ||
|
||
public void returnSession(HadoopSession session) { | ||
try { | ||
pool.returnObject(session); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
src/test/java/com/streever/hadoop/HadoopSessionFactoryTest.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,7 @@ | ||
package com.streever.hadoop; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class HadoopSessionFactoryTest { | ||
|
||
} |
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