added serialization

pull/1/head
Michael Peter Christen 13 years ago
parent b2175ea4ef
commit 5deebd02ea

@ -14,7 +14,7 @@
#%env/templates/submenuIndexControl.template%# #%env/templates/submenuIndexControl.template%#
<h2>Federated Index</h2> <h2>Federated Index</h2>
<p> <p>
YaCy supports multiple index storage locations. At this time only the YaCy-internal search index can be used for the Yacy search interface YaCy supports multiple index storage locations. At this time only the YaCy-internal search index can be used for the YaCy search interface
A Solr index storage location is optional. The local index storage location can be disabled. A Solr index storage location is optional. The local index storage location can be disabled.
</p> </p>
@ -65,12 +65,12 @@
</dl> </dl>
</div> </div>
<div> <div>
<h3>Index Scheme</h3><p>If you use a custom Solr schema you may enter a different field name in the column 'cutom Solr Field Name' of the YacY default attribute name</p> <h3>Index Scheme</h3><p>If you use a custom Solr schema you may enter a different field name in the column 'cutom Solr Field Name' of the YaCy default attribute name</p>
<table class="sortable" border="0" cellpadding="2" cellspacing="1"> <table class="sortable" border="0" cellpadding="2" cellspacing="1">
<tr class="TableHeader" valign="bottom"> <tr class="TableHeader" valign="bottom">
<td>Active</td> <td>Active</td>
<td>Attribute</td> <td>Attribute</td>
<td>custom Solr Field Name</td> <td>Custom Solr Field Name</td>
<td>Comment</td> <td>Comment</td>
</tr> </tr>
#{scheme}# #{scheme}#

@ -30,11 +30,14 @@ import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.io.Serializable;
import java.util.Iterator;
import java.util.TreeMap;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.yacy.kelondro.util.FileUtils;
import net.yacy.cora.storage.ConfigurationSet.Entry; import net.yacy.cora.storage.ConfigurationSet.Entry;
import net.yacy.kelondro.util.FileUtils;
import net.yacy.search.index.SolrField; import net.yacy.search.index.SolrField;
/** /**
* this class reads configuration attributes as a list of keywords from a list * this class reads configuration attributes as a list of keywords from a list
@ -49,8 +52,10 @@ import net.yacy.search.index.SolrField;
* - a line may contain a key only or a key=value pair * - a line may contain a key only or a key=value pair
* @author Michael Christen * @author Michael Christen
*/ */
public class ConfigurationSet extends TreeMap<String,Entry> { public class ConfigurationSet extends TreeMap<String,Entry> implements Serializable {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID=-5961730809008841258L;
private final File file; private final File file;
public ConfigurationSet() { public ConfigurationSet() {
@ -103,7 +108,7 @@ public class ConfigurationSet extends TreeMap<String,Entry> {
entry.setComment(comment); entry.setComment(comment);
comment = null; comment = null;
} }
this.put(key, entry); this.put(key, entry);
} }
} }
} }
@ -192,7 +197,7 @@ public class ConfigurationSet extends TreeMap<String,Entry> {
public void commit() throws IOException { public void commit() throws IOException {
if (this.file == null) return; if (this.file == null) return;
// create a temporary bak file, use it as template to preserve user comments // create a temporary bak file, use it as template to preserve user comments
File bakfile = new File (file.getAbsolutePath() + ".bak"); File bakfile = new File (this.file.getAbsolutePath() + ".bak");
FileUtils.copy (this.file, bakfile); FileUtils.copy (this.file, bakfile);
TreeMap tclone = (TreeMap) this.clone(); // clone to write appended entries TreeMap tclone = (TreeMap) this.clone(); // clone to write appended entries
@ -219,7 +224,7 @@ public class ConfigurationSet extends TreeMap<String,Entry> {
// second # = is a line comment // second # = is a line comment
i = s.indexOf("#"); i = s.indexOf("#");
s = s.substring(0,i).trim(); s = s.substring(0,i).trim();
} }
if (s.contains("=")) { if (s.contains("=")) {
i = s.indexOf("="); i = s.indexOf("=");
key = s.substring(0,i).trim(); key = s.substring(0,i).trim();
@ -232,7 +237,7 @@ public class ConfigurationSet extends TreeMap<String,Entry> {
writer.write (e.toString()); writer.write (e.toString());
tclone.remove(key); // remove written entries from clone tclone.remove(key); // remove written entries from clone
} else {writer.write(sorig); } } else {writer.write(sorig); }
writer.write("\n"); writer.write("\n");
} else { } else {
writer.write(sorig+"\n"); writer.write(sorig+"\n");
} }
@ -241,7 +246,7 @@ public class ConfigurationSet extends TreeMap<String,Entry> {
reader.close(); reader.close();
bakfile.delete(); bakfile.delete();
} catch (final IOException e) {} } catch (final IOException e) {}
// write remainig entries (not already written) // write remainig entries (not already written)
Iterator ie = tclone.entrySet().iterator(); Iterator ie = tclone.entrySet().iterator();
while (ie.hasNext()) { while (ie.hasNext()) {

@ -27,9 +27,17 @@ package net.yacy.search.index;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.*; import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import net.yacy.cora.document.ASCII; import net.yacy.cora.document.ASCII;
import net.yacy.cora.document.MultiProtocolURI; import net.yacy.cora.document.MultiProtocolURI;
@ -46,7 +54,9 @@ import net.yacy.kelondro.logging.Log;
import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocument;
public class SolrConfiguration extends ConfigurationSet { public class SolrConfiguration extends ConfigurationSet implements Serializable {
private static final long serialVersionUID=-499100932212840385L;
/** /**
* initialize with an empty ConfigurationSet which will cause that all the index * initialize with an empty ConfigurationSet which will cause that all the index

Loading…
Cancel
Save