Skip to content
Snippets Groups Projects
Commit 549b1796 authored by Powers, Peter M.'s avatar Powers, Peter M.
Browse files

Merge pull request #98 from pmpowers-usgs/config-work

minor config and build edits
parents e56a17e0 24249d46
No related branches found
No related tags found
No related merge requests found
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
<!-- Compile to classes/ --> <!-- Compile to classes/ -->
<javac srcdir="${src.dir}" <javac srcdir="${src.dir}"
destdir="${classes.dir}" destdir="${classes.dir}"
excludes="**/Scratch*.java"
classpathref="library.classpath" classpathref="library.classpath"
nowarn="true" nowarn="true"
fork="true" fork="true"
......
...@@ -24,16 +24,16 @@ final class AsyncList<T> extends AbstractList<ListenableFuture<T>> { ...@@ -24,16 +24,16 @@ final class AsyncList<T> extends AbstractList<ListenableFuture<T>> {
} }
/** /**
* Creates a new {@code AsynList} with an inital capacity of 256 elements. * Creates a new {@code AsyncList} with an initial capacity of 256 elements.
* @return a new {@code AsynList} * @return a new {@code AsyncList}
*/ */
static <T> AsyncList<T> create() { static <T> AsyncList<T> create() {
return new AsyncList<T>(256); return new AsyncList<T>(256);
} }
/** /**
* Creates a new {@code AsynList} with the specified inital capacity. * Creates a new {@code AsyncList} with the specified initial capacity.
* @return a new {@code AsynList} * @return a new {@code AsyncList}
*/ */
static <T> AsyncList<T> createWithCapacity(int initialCapacity) { static <T> AsyncList<T> createWithCapacity(int initialCapacity) {
return new AsyncList<T>(initialCapacity); return new AsyncList<T>(initialCapacity);
......
...@@ -123,7 +123,7 @@ public final class CalcConfig { ...@@ -123,7 +123,7 @@ public final class CalcConfig {
} }
return new StringBuilder("Calc config:") return new StringBuilder("Calc config:")
.append(format(Key.RESOURCE)).append(resource) .append(format(Key.RESOURCE)).append(resource.toAbsolutePath().normalize())
.append(format(Key.EXCEEDANCE_MODEL)).append(exceedanceModel) .append(format(Key.EXCEEDANCE_MODEL)).append(exceedanceModel)
.append(format(Key.TRUNCATION_LEVEL)).append(truncationLevel) .append(format(Key.TRUNCATION_LEVEL)).append(truncationLevel)
.append(format(Key.IMTS)).append(Parsing.enumsToString(imts, Imt.class)) .append(format(Key.IMTS)).append(Parsing.enumsToString(imts, Imt.class))
......
...@@ -204,7 +204,7 @@ public final class Sites { ...@@ -204,7 +204,7 @@ public final class Sites {
boolean region = this instanceof RegionIterable; boolean region = this instanceof RegionIterable;
int size = region ? ((RegionIterable) this).region.size() : Iterables.size(this); int size = region ? ((RegionIterable) this).region.size() : Iterables.size(this);
StringBuilder sb = new StringBuilder() StringBuilder sb = new StringBuilder()
.append(region ? "Region" : "List") .append(region ? ((RegionIterable) this).region.name() + " Region" : "List")
.append(" [size=").append(size).append("]"); .append(" [size=").append(size).append("]");
if (!region) { if (!region) {
for (Site site : Iterables.limit(this, TO_STRING_LIMIT)) { for (Site site : Iterables.limit(this, TO_STRING_LIMIT)) {
......
...@@ -83,7 +83,7 @@ final class ModelConfig { ...@@ -83,7 +83,7 @@ final class ModelConfig {
@Override public String toString() { @Override public String toString() {
return new StringBuilder("Model config:") return new StringBuilder("Model config:")
.append(format(Key.NAME)).append(name) .append(format(Key.NAME)).append(name)
.append(format(Key.RESOURCE)).append(resource) .append(format(Key.RESOURCE)).append(resource.toAbsolutePath().normalize())
.append(format(Key.SURFACE_SPACING)).append(surfaceSpacing) .append(format(Key.SURFACE_SPACING)).append(surfaceSpacing)
.append(format(Key.RUPTURE_FLOATING)).append(ruptureFloating) .append(format(Key.RUPTURE_FLOATING)).append(ruptureFloating)
.append(format(Key.RUPTURE_VARIABILITY)).append(ruptureVariability) .append(format(Key.RUPTURE_VARIABILITY)).append(ruptureVariability)
......
...@@ -15,6 +15,7 @@ import java.util.List; ...@@ -15,6 +15,7 @@ import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.opensha2.calc.CalcConfig; import org.opensha2.calc.CalcConfig;
...@@ -109,7 +110,7 @@ public class HazardCalc { ...@@ -109,7 +110,7 @@ public class HazardCalc {
Iterable<Site> sites = readSites(args[1]); Iterable<Site> sites = readSites(args[1]);
log.info(""); log.info("");
log.info("Sites:" + sites); log.info("Sites: " + sites);
calc(model, config, sites, out, log); calc(model, config, sites, out, log);
log.info(PROGRAM + ": finished"); log.info(PROGRAM + ": finished");
...@@ -157,6 +158,8 @@ public class HazardCalc { ...@@ -157,6 +158,8 @@ public class HazardCalc {
Logger log) throws IOException { Logger log) throws IOException {
ExecutorService execSvc = createExecutor(); ExecutorService execSvc = createExecutor();
int threadCount = ((ThreadPoolExecutor) execSvc).getCorePoolSize();
log.info("Threads: " + threadCount);
Optional<Executor> executor = Optional.<Executor> of(execSvc); Optional<Executor> executor = Optional.<Executor> of(execSvc);
log.info(PROGRAM + ": calculating ..."); log.info(PROGRAM + ": calculating ...");
...@@ -211,12 +214,16 @@ public class HazardCalc { ...@@ -211,12 +214,16 @@ public class HazardCalc {
Site site, Site site,
Optional<Executor> executor) { Optional<Executor> executor) {
// TODO not sure why we're mandating an executor here.
// legacy from refactoring?
Optional<Executor> execLocal = executor.or(Optional.of(createExecutor())); Optional<Executor> execLocal = executor.or(Optional.of(createExecutor()));
try { try {
Hazard result = Calcs.hazard(model, config, site, execLocal); Hazard result = Calcs.hazard(model, config, site, execLocal);
// Shut down the locally created executor if none was supplied // Shut down the locally created executor if none was supplied
if (!executor.isPresent()) ((ExecutorService) execLocal.get()).shutdown(); if (!executor.isPresent()) {
((ExecutorService) execLocal.get()).shutdown();
}
return result; return result;
} catch (ExecutionException | InterruptedException e) { } catch (ExecutionException | InterruptedException e) {
Throwables.propagate(e); Throwables.propagate(e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment