|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.TimerTask
org.openstreetmap.josm.data.AutosaveTask
public class AutosaveTask
Saves data layers periodically so they can be recovered in case of a crash. There are 2 directories - autosave dir: copies of the currently open data layers are saved here every PROP_INTERVAL seconds. When a data layer is closed normally, the corresponding files are removed. If this dir is non-empty on start, JOSM assumes that it crashed last time. - deleted layers dir: "secondary archive" - when autosaved layers are restored they are copied to this directory. We cannot keep them in the autosave folder, but just deleting it would be dangerous: Maybe a feature inside the file caused JOSM to crash. If the data is valuable, the user can still try to open with another versions of JOSM or fix the problem manually. The deleted layers dir keeps at most PROP_DELETED_LAYERS files.
Nested Class Summary | |
---|---|
private static class |
AutosaveTask.AutosaveLayerInfo
|
Field Summary | |
---|---|
private static java.lang.String |
AUTOSAVE_DIR
|
private java.io.File |
autosaveDir
|
private java.util.Set<DataSet> |
changedDatasets
|
private DataSetListenerAdapter |
datasetAdapter
|
private static java.lang.String |
DELETED_LAYERS_DIR
|
private java.util.Deque<java.io.File> |
deletedLayers
|
private java.io.File |
deletedLayersDir
|
private static char[] |
ILLEGAL_CHARACTERS
|
private java.util.List<AutosaveTask.AutosaveLayerInfo> |
layersInfo
|
private java.lang.Object |
layersLock
|
static BooleanProperty |
PROP_AUTOSAVE_ENABLED
|
static IntegerProperty |
PROP_DELETED_LAYERS
|
static IntegerProperty |
PROP_FILES_PER_LAYER
|
static IntegerProperty |
PROP_INDEX_LIMIT
|
static IntegerProperty |
PROP_INTERVAL
|
private java.util.Timer |
timer
|
Constructor Summary | |
---|---|
AutosaveTask()
|
Method Summary | |
---|---|
void |
activeLayerChange(Layer oldLayer,
Layer newLayer)
Notifies this listener that the active layer has changed. |
void |
dicardUnsavedLayers()
|
private java.lang.String |
getFileName(java.lang.String layerName,
int index)
|
private java.io.File |
getNewLayerFile(AutosaveTask.AutosaveLayerInfo layer)
|
private java.io.File |
getPidFile(java.io.File osmFile)
|
java.util.List<java.io.File> |
getUnsavedLayersFiles()
Replies the list of .osm files still present in autosave dir, that are not currently managed by another instance of JOSM. |
private boolean |
jvmPerfDataFileExists(java.lang.String jvmId)
|
void |
layerAdded(Layer newLayer)
Notifies this listener that a layer has been added. |
void |
layerRemoved(Layer oldLayer)
Notifies this listener that a layer has been removed. |
private void |
moveToDeletedLayersFolder(java.io.File f)
Move file to the deleted layers directory. |
void |
processDatasetEvent(AbstractDatasetChangedEvent event)
|
void |
recoverUnsavedLayers()
|
private void |
registerNewlayer(OsmDataLayer layer)
|
void |
run()
|
private void |
savelayer(AutosaveTask.AutosaveLayerInfo info)
|
void |
schedule()
|
private void |
setLayerFileName(AutosaveTask.AutosaveLayerInfo layer)
|
Methods inherited from class java.util.TimerTask |
---|
cancel, scheduledExecutionTime |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final char[] ILLEGAL_CHARACTERS
private static final java.lang.String AUTOSAVE_DIR
private static final java.lang.String DELETED_LAYERS_DIR
public static final BooleanProperty PROP_AUTOSAVE_ENABLED
public static final IntegerProperty PROP_FILES_PER_LAYER
public static final IntegerProperty PROP_DELETED_LAYERS
public static final IntegerProperty PROP_INTERVAL
public static final IntegerProperty PROP_INDEX_LIMIT
private final DataSetListenerAdapter datasetAdapter
private final java.util.Set<DataSet> changedDatasets
private final java.util.List<AutosaveTask.AutosaveLayerInfo> layersInfo
private java.util.Timer timer
private final java.lang.Object layersLock
private final java.util.Deque<java.io.File> deletedLayers
private final java.io.File autosaveDir
private final java.io.File deletedLayersDir
Constructor Detail |
---|
public AutosaveTask()
Method Detail |
---|
public void schedule()
private java.lang.String getFileName(java.lang.String layerName, int index)
private void setLayerFileName(AutosaveTask.AutosaveLayerInfo layer)
private java.io.File getNewLayerFile(AutosaveTask.AutosaveLayerInfo layer)
private void savelayer(AutosaveTask.AutosaveLayerInfo info) throws java.io.IOException
java.io.IOException
public void run()
run
in interface java.lang.Runnable
run
in class java.util.TimerTask
public void activeLayerChange(Layer oldLayer, Layer newLayer)
MapView.LayerChangeListener
activeLayerChange
in interface MapView.LayerChangeListener
oldLayer
- The previous active layernewLayer
- The new activer layerprivate void registerNewlayer(OsmDataLayer layer)
public void layerAdded(Layer newLayer)
MapView.LayerChangeListener
layerAdded
in interface MapView.LayerChangeListener
newLayer
- The new added layerpublic void layerRemoved(Layer oldLayer)
MapView.LayerChangeListener
layerRemoved
in interface MapView.LayerChangeListener
oldLayer
- The old removed layerpublic void processDatasetEvent(AbstractDatasetChangedEvent event)
processDatasetEvent
in interface DataSetListenerAdapter.Listener
private final java.io.File getPidFile(java.io.File osmFile)
public java.util.List<java.io.File> getUnsavedLayersFiles()
private boolean jvmPerfDataFileExists(java.lang.String jvmId)
public void recoverUnsavedLayers()
private void moveToDeletedLayersFolder(java.io.File f)
f
- the file, usually from the autosave dirpublic void dicardUnsavedLayers()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |