diff --git a/src/Soil-Core-Tests/SoilBackupTest.class.st b/src/Soil-Core-Tests/SoilBackupTest.class.st index bc48c50d..af7ffebb 100644 --- a/src/Soil-Core-Tests/SoilBackupTest.class.st +++ b/src/Soil-Core-Tests/SoilBackupTest.class.st @@ -88,7 +88,7 @@ SoilBackupTest >> testBackupWithIndexRemoval [ { #category : #tests } SoilBackupTest >> testSimpleBackup [ | tx backup tx2 | - soil settings + soil control databaseFormatVersion: 1; applicationVersion: 5. tx := soil newTransaction. @@ -100,7 +100,7 @@ SoilBackupTest >> testSimpleBackup [ open. [tx2 := backup newTransaction. self assert: tx2 root equals: tx2 root. - self assert: backup settings applicationVersion equals: 5] + self assert: backup control applicationVersion equals: 5] ensure: [ backup close ] diff --git a/src/Soil-Core-Tests/SoilTest.class.st b/src/Soil-Core-Tests/SoilTest.class.st index eda50d25..e25c6474 100644 --- a/src/Soil-Core-Tests/SoilTest.class.st +++ b/src/Soil-Core-Tests/SoilTest.class.st @@ -20,7 +20,7 @@ SoilTest class >> packageNamesUnderTest [ { #category : #accessing } SoilTest >> path [ - ^ 'soil-tests' + ^ 'soil-tests' asFileReference ] { #category : #initialization } @@ -69,6 +69,17 @@ SoilTest >> testCachedSegment [ ] +{ #category : #tests } +SoilTest >> testChangePathToControl [ + soil close. + (self path / #control) moveTo: (self path / #settings). + soil := Soil path: self path. + soil open. + self assert: soil databaseVersion equals: 0 + + +] + { #category : #tests } SoilTest >> testCheckpointEmptyRecordsToCommit [ | tx root skipList obj items | @@ -122,7 +133,7 @@ SoilTest >> testFindRecordWithIndex [ { #category : #tests } SoilTest >> testIncompatibleDatabaseFormatVersion [ - soil settings databaseFormatVersion: 2. + soil control databaseFormatVersion: 2. soil close. soil := Soil path: self path. diff --git a/src/Soil-Core/Soil.class.st b/src/Soil-Core/Soil.class.st index 29cbf66a..3a261f54 100644 --- a/src/Soil-Core/Soil.class.st +++ b/src/Soil-Core/Soil.class.st @@ -33,11 +33,11 @@ Class { 'objectRepository', 'behaviorRegistry', 'semaphore', - 'settings', 'journal', 'notificationHandler', 'serializerClass', - 'materializerClass' + 'materializerClass', + 'control' ], #category : #'Soil-Core-Model' } @@ -94,8 +94,14 @@ Soil >> close [ objectRepository close ]. behaviorRegistry ifNotNil: [ behaviorRegistry close ]. - settings ifNotNil: [ - settings close ] + control ifNotNil: [ + control close ] +] + +{ #category : #accessing } +Soil >> control [ + + ^ control ] { #category : #initialization } @@ -105,12 +111,12 @@ Soil >> critical: aBlock [ { #category : #accessing } Soil >> databaseVersion [ - ^ settings databaseVersion + ^ control databaseVersion ] { #category : #accessing } Soil >> databaseVersion: anInteger [ - settings databaseVersion: anInteger + control databaseVersion: anInteger ] { #category : #'instance creation' } @@ -149,7 +155,7 @@ Soil >> initializeFilesystem [ (path exists and: [ path hasChildren ]) ifTrue: [ SoilDatabaseAlreadyPresent signal: 'the directory ', path asString, ' already exists' ]. self path ensureCreateDirectory. - settings := SoilParameterFile new + control := SoilControlFile new soil: self; initializeFilesystem; yourself. @@ -169,6 +175,13 @@ Soil >> initializeFilesystem [ soil: self ] +{ #category : #inspector } +Soil >> inspectionControl [ + + + ^ self control inspectionControl +] + { #category : #inspector } Soil >> inspectionJournal [ @@ -176,13 +189,6 @@ Soil >> inspectionJournal [ ^ self journal inspectionContent ] -{ #category : #inspector } -Soil >> inspectionParameters [ - - - ^ self settings inspectionParameters -] - { #category : #accessing } Soil >> journal [ ^ journal @@ -190,7 +196,7 @@ Soil >> journal [ { #category : #locking } Soil >> lockDatabaseVersionFor: lockContext [ - ^ settings lockDatabaseVersionFor: lockContext + ^ control lockDatabaseVersionFor: lockContext ] { #category : #locking } @@ -266,7 +272,7 @@ Soil >> objectRepository [ { #category : #'opening/closing' } Soil >> open [ ('open soil database at ', path asString) soilEmit. - settings := SoilParameterFile new + control := SoilControlFile new soil: self; open. objectRepository := SoilObjectRepository new @@ -300,7 +306,7 @@ Soil >> path: aString [ Soil >> printOn: aStream [ aStream << 'Soil [' - << self settings databaseVersion printString + << self control databaseVersion printString << '] ' << self path pathString ] @@ -360,12 +366,6 @@ Soil >> serializerClass: anObject [ serializerClass := anObject ] -{ #category : #accessing } -Soil >> settings [ - - ^ settings -] - { #category : #accessing } Soil >> setup [ ^ SoilSetup new diff --git a/src/Soil-Core/SoilBackupVisitor.class.st b/src/Soil-Core/SoilBackupVisitor.class.st index 152b6cde..2d02930e 100644 --- a/src/Soil-Core/SoilBackupVisitor.class.st +++ b/src/Soil-Core/SoilBackupVisitor.class.st @@ -76,6 +76,14 @@ SoilBackupVisitor >> target: aSoil [ target := aSoil ] +{ #category : #visiting } +SoilBackupVisitor >> visitControl: aSoilControlFile [ + target control + databaseFormatVersion: aSoilControlFile databaseFormatVersion; + databaseVersion: aSoilControlFile databaseVersion; + applicationVersion: aSoilControlFile applicationVersion +] + { #category : #visiting } SoilBackupVisitor >> visitDatabaseJournal: aSoilJournal [ (target path / #journal) ensureCreateDirectory. @@ -101,14 +109,6 @@ SoilBackupVisitor >> visitObjectSegment: aSoilObjectSegment [ super visitObjectSegment: aSoilObjectSegment. ] -{ #category : #visiting } -SoilBackupVisitor >> visitParameters: aSoilParameterFile [ - target settings - databaseFormatVersion: aSoilParameterFile databaseFormatVersion; - databaseVersion: aSoilParameterFile databaseVersion; - applicationVersion: aSoilParameterFile applicationVersion -] - { #category : #visiting } SoilBackupVisitor >> visitPersistentClusterVersion: aSoilPersistentClusterVersion [ | backupCluster | diff --git a/src/Soil-Core/SoilParameterFile.class.st b/src/Soil-Core/SoilControlFile.class.st similarity index 73% rename from src/Soil-Core/SoilParameterFile.class.st rename to src/Soil-Core/SoilControlFile.class.st index c5ba19ae..f5adb2e9 100644 --- a/src/Soil-Core/SoilParameterFile.class.st +++ b/src/Soil-Core/SoilControlFile.class.st @@ -1,5 +1,5 @@ Class { - #name : #SoilParameterFile, + #name : #SoilControlFile, #superclass : #SoilBinaryFile, #instVars : [ 'soil', @@ -12,12 +12,12 @@ Class { } { #category : #visiting } -SoilParameterFile >> acceptSoil: aSoilVisitor [ - ^ aSoilVisitor visitParameters: self +SoilControlFile >> acceptSoil: aSoilVisitor [ + ^ aSoilVisitor visitControl: self ] { #category : #accessing } -SoilParameterFile >> applicationVersion [ +SoilControlFile >> applicationVersion [ ^ semaphore critical: [ applicationVersion ifNil: [ stream position: self applicationVersionPosition. @@ -25,7 +25,7 @@ SoilParameterFile >> applicationVersion [ ] { #category : #accessing } -SoilParameterFile >> applicationVersion: anInteger [ +SoilControlFile >> applicationVersion: anInteger [ semaphore critical: [ self stream position: self applicationVersionPosition; @@ -35,17 +35,17 @@ SoilParameterFile >> applicationVersion: anInteger [ ] { #category : #accessing } -SoilParameterFile >> applicationVersionPosition [ +SoilControlFile >> applicationVersionPosition [ ^ self databaseVersionPosition + self databaseVersionSize ] { #category : #accessing } -SoilParameterFile >> applicationVersionSize [ +SoilControlFile >> applicationVersionSize [ ^ 8 ] { #category : #private } -SoilParameterFile >> basicDatabaseVersion: anInteger [ +SoilControlFile >> basicDatabaseVersion: anInteger [ semaphore critical: [ currentDatabaseVersion := anInteger. self stream @@ -55,7 +55,7 @@ SoilParameterFile >> basicDatabaseVersion: anInteger [ ] { #category : #accessing } -SoilParameterFile >> checkpoint [ +SoilControlFile >> checkpoint [ ^ semaphore critical: [ self stream position: self checkpointPosition. @@ -63,7 +63,7 @@ SoilParameterFile >> checkpoint [ ] { #category : #accessing } -SoilParameterFile >> checkpoint: anInteger [ +SoilControlFile >> checkpoint: anInteger [ semaphore critical: [ self stream position: self checkpointPosition; @@ -72,17 +72,17 @@ SoilParameterFile >> checkpoint: anInteger [ ] { #category : #accessing } -SoilParameterFile >> checkpointPosition [ +SoilControlFile >> checkpointPosition [ ^ self applicationVersionPosition + self applicationVersionSize ] { #category : #accessing } -SoilParameterFile >> checkpointPositionSize [ +SoilControlFile >> checkpointPositionSize [ ^ 8 ] { #category : #accessing } -SoilParameterFile >> databaseFormatVersion [ +SoilControlFile >> databaseFormatVersion [ ^ semaphore critical: [ databaseFormatVersion ifNil: [ stream position: self headerSize. @@ -90,7 +90,7 @@ SoilParameterFile >> databaseFormatVersion [ ] { #category : #accessing } -SoilParameterFile >> databaseFormatVersion: anInteger [ +SoilControlFile >> databaseFormatVersion: anInteger [ semaphore critical: [ self stream position: self headerSize; @@ -100,19 +100,19 @@ SoilParameterFile >> databaseFormatVersion: anInteger [ ] { #category : #accessing } -SoilParameterFile >> databaseFormatVersionSize [ +SoilControlFile >> databaseFormatVersionSize [ ^ 1 ] { #category : #accessing } -SoilParameterFile >> databaseVersion [ +SoilControlFile >> databaseVersion [ ^ semaphore critical: [ stream position: self databaseVersionPosition. (stream next: self databaseVersionSize) asInteger ] ] { #category : #accessing } -SoilParameterFile >> databaseVersion: anInteger [ +SoilControlFile >> databaseVersion: anInteger [ (currentDatabaseVersion < anInteger) ifFalse: [ SoilInvalidDatabaseVersion signal: 'database version can only grow' ]. (self databaseVersion < anInteger) ifFalse: [ @@ -121,32 +121,32 @@ SoilParameterFile >> databaseVersion: anInteger [ ] { #category : #accessing } -SoilParameterFile >> databaseVersionPosition [ +SoilControlFile >> databaseVersionPosition [ ^ self headerSize + self databaseFormatVersionSize ] { #category : #accessing } -SoilParameterFile >> databaseVersionSize [ +SoilControlFile >> databaseVersionSize [ ^ 8 ] { #category : #initialization } -SoilParameterFile >> initialize [ +SoilControlFile >> initialize [ super initialize. semaphore := Semaphore forMutualExclusion. currentDatabaseVersion := 0 ] { #category : #initialization } -SoilParameterFile >> initializeStart [ +SoilControlFile >> initializeStart [ self databaseFormatVersion: 1. self basicDatabaseVersion: 0. self applicationVersion: 1 ] { #category : #inspector } -SoilParameterFile >> inspectionParameters [ - +SoilControlFile >> inspectionControl [ + ^ SpTablePresenter new items: self parameterNames; @@ -158,8 +158,13 @@ SoilParameterFile >> inspectionParameters [ addColumn: (SpStringTableColumn evaluated: [:each | self perform: each asSymbol ])) ] +{ #category : #accessing } +SoilControlFile >> legacyPath [ + ^ soil path / #settings +] + { #category : #locking } -SoilParameterFile >> lockDatabaseVersionFor: lockContext [ +SoilControlFile >> lockDatabaseVersionFor: lockContext [ ^ stream lockFrom: self headerSize length: self databaseVersionSize @@ -167,7 +172,11 @@ SoilParameterFile >> lockDatabaseVersionFor: lockContext [ ] { #category : #'open/close' } -SoilParameterFile >> open [ +SoilControlFile >> open [ + "convert legacy path to new one" + self path exists ifFalse: [ + self legacyPath exists ifTrue: [ + self legacyPath moveTo: self path ] ]. super open. (Soil databaseFormatVersion = self databaseFormatVersion) ifFalse: [ SoilIncompatibleDatabaseFormat signal: 'database format version ', Soil databaseFormatVersion asString, ' does not match persisted database format version ', self databaseFormatVersion asString ]. @@ -175,28 +184,28 @@ SoilParameterFile >> open [ ] { #category : #accessing } -SoilParameterFile >> parameterNames [ +SoilControlFile >> parameterNames [ ^ #( databaseFormatVersion databaseVersion applicationVersion checkpoint ) ] { #category : #accessing } -SoilParameterFile >> path [ - ^ soil path / #settings +SoilControlFile >> path [ + ^ soil path / #control ] { #category : #utilities } -SoilParameterFile >> prefix [ +SoilControlFile >> prefix [ ^ 'SOIL|PARAMETERS' asByteArray ] { #category : #accessing } -SoilParameterFile >> soil [ +SoilControlFile >> soil [ ^ soil ] { #category : #accessing } -SoilParameterFile >> soil: anObject [ +SoilControlFile >> soil: anObject [ soil := anObject ] diff --git a/src/Soil-Core/SoilJournalConverter.class.st b/src/Soil-Core/SoilJournalConverter.class.st index abd1eedb..a49614df 100644 --- a/src/Soil-Core/SoilJournalConverter.class.st +++ b/src/Soil-Core/SoilJournalConverter.class.st @@ -12,7 +12,7 @@ SoilJournalConverter >> convert [ | allJournalFiles | "reset database checkpoint to process all of the transaction logs and set the right position at the end" - soil settings checkpoint: (SoilLogSequenceNumber fileNumber: 0 offset: 0). + soil control checkpoint: (SoilLogSequenceNumber fileNumber: 0 offset: 0). "remove any existing current fragment file to be sure" soil journal resetFragmentFile. "read all transaction logs recursively, sort them and import to the new journal" diff --git a/src/Soil-Core/SoilPersistentDatabaseJournal.class.st b/src/Soil-Core/SoilPersistentDatabaseJournal.class.st index 43e7d386..0725f130 100644 --- a/src/Soil-Core/SoilPersistentDatabaseJournal.class.st +++ b/src/Soil-Core/SoilPersistentDatabaseJournal.class.st @@ -32,13 +32,13 @@ SoilPersistentDatabaseJournal >> appendEntry: aSoilNewCheckpointEntry [ SoilPersistentDatabaseJournal >> checkpoint [ | entry checkpointLSN | entry := SoilCheckpointEntry new - previousCheckpoint: soil settings checkpoint. + previousCheckpoint: soil control checkpoint. entry commitIn: soil. "write the checkpoint entry in the journal and get the position of that entry in the file" checkpointLSN := self writeEntry: entry. "set the checkpoint position so it can be read back" - soil settings checkpoint: checkpointLSN. + soil control checkpoint: checkpointLSN. ^ entry ] @@ -54,7 +54,7 @@ SoilPersistentDatabaseJournal >> createFragmentFile: filename [ SoilPersistentDatabaseJournal >> currentFragmentFile [ | currentLSN filename | ^ currentFragmentFile ifNil: [ - currentLSN := soil settings checkpoint. + currentLSN := soil control checkpoint. filename := self filenameFrom: currentLSN fileNumber. currentFragmentFile := (currentLSN isInitial) ifTrue: [ self createFragmentFile: filename ] diff --git a/src/Soil-Core/SoilVisitor.class.st b/src/Soil-Core/SoilVisitor.class.st index cd7c00c7..417f1c8b 100644 --- a/src/Soil-Core/SoilVisitor.class.st +++ b/src/Soil-Core/SoilVisitor.class.st @@ -27,6 +27,11 @@ SoilVisitor >> visitAll: aCollection [ self visit: each ] ] +{ #category : #visiting } +SoilVisitor >> visitControl: aSoilControlFile [ + +] + { #category : #visiting } SoilVisitor >> visitDatabaseJournal: aSoilJournal [ self visitAll: aSoilJournal fragmentFiles. @@ -75,11 +80,6 @@ SoilVisitor >> visitPagedFileIndexStore: aSoilPagedFileIndexStore [ ] -{ #category : #visiting } -SoilVisitor >> visitParameters: aSoilParameterFile [ - -] - { #category : #visiting } SoilVisitor >> visitPersistentClusterVersion: aSoilPersistentClusterVersion [ aSoilPersistentClusterVersion references @@ -94,7 +94,7 @@ SoilVisitor >> visitSkipList: aSoilSkipList [ { #category : #visiting } SoilVisitor >> visitSoil: aSoil [ - self visit: aSoil settings. + self visit: aSoil control. self visit: aSoil objectRepository. self visit: aSoil journal. ^ aSoil