|
@@ -18,7 +18,6 @@ package jp.sf.fess.helper;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FilenameFilter;
|
|
|
-import java.io.IOException;
|
|
|
import java.io.Serializable;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLEncoder;
|
|
@@ -28,25 +27,20 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
import java.util.UUID;
|
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
|
import jp.sf.fess.Constants;
|
|
|
import jp.sf.fess.FessSystemException;
|
|
|
import jp.sf.fess.db.exentity.RoleType;
|
|
|
-import jp.sf.fess.job.JobExecutor;
|
|
|
import jp.sf.fess.service.RoleTypeService;
|
|
|
import jp.sf.fess.util.ResourceUtil;
|
|
|
|
|
|
-import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.codelibs.solr.lib.SolrGroup;
|
|
|
import org.codelibs.solr.lib.policy.QueryType;
|
|
|
import org.codelibs.solr.lib.policy.StatusPolicy;
|
|
|
import org.seasar.framework.container.SingletonS2Container;
|
|
|
-import org.seasar.framework.container.annotation.tiger.DestroyMethod;
|
|
|
import org.seasar.framework.container.annotation.tiger.InitMethod;
|
|
|
import org.seasar.framework.util.FileUtil;
|
|
|
import org.seasar.framework.util.StringUtil;
|
|
@@ -63,10 +57,6 @@ public class SystemHelper implements Serializable {
|
|
|
private static final Logger logger = LoggerFactory
|
|
|
.getLogger(SystemHelper.class);
|
|
|
|
|
|
- private final ConcurrentHashMap<String, Process> runningProcessMap = new ConcurrentHashMap<String, Process>();
|
|
|
-
|
|
|
- private final ConcurrentHashMap<Long, JobExecutor> runningJobExecutorMap = new ConcurrentHashMap<Long, JobExecutor>();
|
|
|
-
|
|
|
private String adminRole = "fess";
|
|
|
|
|
|
private String[] crawlerJavaOptions = new String[] {
|
|
@@ -168,53 +158,6 @@ public class SystemHelper implements Serializable {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @DestroyMethod
|
|
|
- public void destroy() {
|
|
|
- for (final String sessionId : runningProcessMap.keySet()) {
|
|
|
- destroyCrawlerProcess(sessionId);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public Process startCrawlerProcess(final String sessionId,
|
|
|
- final ProcessBuilder processBuilder) {
|
|
|
- destroyCrawlerProcess(sessionId);
|
|
|
- Process currentProcess;
|
|
|
- try {
|
|
|
- currentProcess = processBuilder.start();
|
|
|
- destroyCrawlerProcess(runningProcessMap.putIfAbsent(sessionId,
|
|
|
- currentProcess));
|
|
|
- return currentProcess;
|
|
|
- } catch (final IOException e) {
|
|
|
- throw new FessSystemException("Crawler Process terminated.", e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void destroyCrawlerProcess(final String sessionId) {
|
|
|
- final Process process = runningProcessMap.remove(sessionId);
|
|
|
- destroyCrawlerProcess(process);
|
|
|
- }
|
|
|
-
|
|
|
- protected void destroyCrawlerProcess(final Process process) {
|
|
|
- if (process != null) {
|
|
|
- try {
|
|
|
- IOUtils.closeQuietly(process.getInputStream());
|
|
|
- } catch (final Exception e) {
|
|
|
- }
|
|
|
- try {
|
|
|
- IOUtils.closeQuietly(process.getErrorStream());
|
|
|
- } catch (final Exception e) {
|
|
|
- }
|
|
|
- try {
|
|
|
- IOUtils.closeQuietly(process.getOutputStream());
|
|
|
- } catch (final Exception e) {
|
|
|
- }
|
|
|
- try {
|
|
|
- process.destroy();
|
|
|
- } catch (final Exception e) {
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public String getUsername() {
|
|
|
String username = RequestUtil.getRequest().getRemoteUser();
|
|
|
if (StringUtil.isBlank(username)) {
|
|
@@ -227,10 +170,6 @@ public class SystemHelper implements Serializable {
|
|
|
return new Timestamp(System.currentTimeMillis());
|
|
|
}
|
|
|
|
|
|
- public boolean isCrawlProcessRunning() {
|
|
|
- return !runningProcessMap.isEmpty();
|
|
|
- }
|
|
|
-
|
|
|
public String getLogFilePath() {
|
|
|
return logFilePath;
|
|
|
}
|
|
@@ -451,10 +390,6 @@ public class SystemHelper implements Serializable {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public Set<String> getRunningSessionIdSet() {
|
|
|
- return runningProcessMap.keySet();
|
|
|
- }
|
|
|
-
|
|
|
public boolean isForceStop() {
|
|
|
return forceStop.get();
|
|
|
}
|
|
@@ -463,19 +398,6 @@ public class SystemHelper implements Serializable {
|
|
|
forceStop.set(true);
|
|
|
}
|
|
|
|
|
|
- public JobExecutor startJobExecutoer(final Long id,
|
|
|
- final JobExecutor jobExecutor) {
|
|
|
- return runningJobExecutorMap.putIfAbsent(id, jobExecutor);
|
|
|
- }
|
|
|
-
|
|
|
- public void finishJobExecutoer(final Long id) {
|
|
|
- runningJobExecutorMap.remove(id);
|
|
|
- }
|
|
|
-
|
|
|
- public JobExecutor getJobExecutoer(final Long id) {
|
|
|
- return runningJobExecutorMap.get(id);
|
|
|
- }
|
|
|
-
|
|
|
public String generateDocId(final Map<String, Object> map) {
|
|
|
return UUID.randomUUID().toString().replace("-", "");
|
|
|
}
|