hutch-xamplr 1.0.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION.yml +2 -2
- data/examples/random-people-shared-addresses/Makefile +2 -2
- data/examples/random-people-shared-addresses/batch-load-users.rb +2 -5
- data/examples/random-people-shared-addresses/find-mentions.rb +1 -4
- data/examples/random-people-shared-addresses/find-people-by-address.rb +1 -4
- data/examples/random-people-shared-addresses/optimise.rb +1 -4
- data/examples/random-people-shared-addresses/people.rb +0 -15
- data/examples/random-people-shared-addresses/query.rb +1 -4
- data/examples/random-people-shared-addresses/query2.rb +1 -4
- data/examples/random-people-shared-addresses/results.write.BASELINE +298 -0
- data/examples/random-people-shared-addresses/results.write.NEW_ATTR_ENCODING +294 -0
- data/examples/random-people-shared-addresses/settings.rb +3 -0
- data/examples/random-people/batch-load-users.rb +1 -4
- data/examples/random-people/optimise.rb +1 -4
- data/examples/random-people/people.rb +0 -3
- data/examples/random-people/query.rb +1 -5
- data/examples/random-people/query2.rb +1 -4
- data/examples/random-people/settings.rb +3 -0
- data/examples/random-people/what-to-query-on.rb +1 -3
- data/examples/read-testing/Makefile +10 -0
- data/examples/read-testing/load.rb +65 -0
- data/examples/read-testing/read.rb +51 -0
- data/examples/read-testing/results.read.BASELINE +6 -0
- data/examples/read-testing/results.read.FAST +5 -0
- data/examples/read-testing/rrr.rb +87 -0
- data/examples/read-testing/settings.rb +2 -0
- data/examples/read-testing/xampl-gen.rb +36 -0
- data/examples/read-testing/xml/text.xml +8 -0
- data/lib/xamplr.rb +10 -1
- data/lib/xamplr/exceptions.rb +97 -0
- data/lib/xamplr/from-xml-orig.rb +350 -0
- data/lib/xamplr/from-xml.rb +272 -183
- data/lib/xamplr/handwritten/example.rb +0 -58
- data/lib/xamplr/handwritten/hand-example.rb +0 -27
- data/lib/xamplr/handwritten/test-handwritten.rb +0 -37
- data/lib/xamplr/mixins.rb +10 -48
- data/lib/xamplr/persist-to-xml.rb +249 -0
- data/lib/xamplr/persistence.rb +44 -412
- data/lib/xamplr/persistence.rb.more_thread_safe +0 -13
- data/lib/xamplr/persistence.rb.partially_thread_safe +0 -13
- data/lib/xamplr/persister.rb +298 -0
- data/lib/xamplr/{persister → persisters}/caches.rb +0 -0
- data/lib/xamplr/{persister → persisters}/caching.rb +1 -1
- data/lib/xamplr/{persister → persisters}/filesystem.rb +4 -5
- data/lib/xamplr/{persister → persisters}/in-memory.rb +1 -1
- data/lib/xamplr/{persister → persisters}/simple.rb +0 -0
- data/lib/xamplr/{persister → persisters}/tokyo-cabinet.rb +53 -15
- data/lib/xamplr/simpleTemplate/{input-c.r4 → obsolete/input-c.r4} +0 -0
- data/lib/xamplr/simpleTemplate/{play.r6.txt → obsolete/play.r6.txt} +0 -0
- data/lib/xamplr/simpleTemplate/{play_more.r6.txt → obsolete/play_more.r6.txt} +0 -0
- data/lib/xamplr/simpleTemplate/{test001.r5 → obsolete/test001.r5} +0 -0
- data/lib/xamplr/simpleTemplate/{test002.r5 → obsolete/test002.r5} +0 -0
- data/lib/xamplr/simpleTemplate/{test003.r5 → obsolete/test003.r5} +0 -0
- data/lib/xamplr/templates/child_indexed.template +1 -1
- data/lib/xamplr/templates/element_classes.template +1 -1
- data/lib/xamplr/templates/element_data.template +0 -39
- data/lib/xamplr/templates/element_empty.template +0 -40
- data/lib/xamplr/templates/element_mixed.template +0 -41
- data/lib/xamplr/templates/element_simple.template +0 -40
- data/lib/xamplr/test-support/bench.rb +6 -26
- data/lib/xamplr/test-support/test.rb +1 -89
- data/lib/xamplr/visitor.rb +0 -778
- data/lib/xamplr/visitors.rb +573 -0
- data/lib/xamplr/xampl-generator.rb +1 -1
- data/lib/xamplr/xampl-hand-generated.rb +0 -85
- data/lib/xamplr/xampl-module.rb +36 -0
- data/lib/xamplr/xampl-object-internals.rb +6 -0
- data/lib/xamplr/xampl-object.rb +10 -341
- data/lib/xamplr/xampl-persisted-object.rb +122 -0
- data/lib/xamplr/xml-text.rb +117 -0
- metadata +53 -18
- data/lib/xamplr/persister/subversion.rb +0 -61
- data/lib/xamplr/rac.sh +0 -6
- data/lib/xamplr/rac_gen.sh +0 -1
- data/lib/xamplr/templates/child_indexed.template.000 +0 -87
data/lib/xamplr/persistence.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
|
3
2
|
require 'sync'
|
4
3
|
|
@@ -91,9 +90,7 @@ module Xampl
|
|
91
90
|
|
92
91
|
def Xampl.print_known_persisters
|
93
92
|
puts "Known Persisters:: --------------------------"
|
94
|
-
@@known_persisters.each { | n, k |
|
95
|
-
puts " #{n} #{k}"
|
96
|
-
}
|
93
|
+
@@known_persisters.each { | n, k | puts " #{n} #{k}" }
|
97
94
|
puts "---------------------------------------------"
|
98
95
|
end
|
99
96
|
|
@@ -104,14 +101,15 @@ module Xampl
|
|
104
101
|
Xampl.print_known_persisters
|
105
102
|
end
|
106
103
|
|
107
|
-
def Xampl.drop_all_persisters
|
108
|
-
puts "Drop All Persisters:: --------------------------"
|
109
|
-
@@known_persisters.each
|
110
|
-
puts " #{
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
104
|
+
def Xampl.drop_all_persisters(verbose=false)
|
105
|
+
puts "Drop All Persisters:: --------------------------" if verbose
|
106
|
+
@@known_persisters.each do |name, persister|
|
107
|
+
puts " #{ name } #{ persister.class.name }" if verbose
|
108
|
+
next if persister == @@persister
|
109
|
+
persister.close
|
110
|
+
persister.clear_cache
|
111
|
+
end
|
112
|
+
puts "---------------------------------------------" if verbose
|
115
113
|
GC.start
|
116
114
|
GC.start
|
117
115
|
GC.start
|
@@ -149,8 +147,10 @@ module Xampl
|
|
149
147
|
rollback = true
|
150
148
|
exception = nil
|
151
149
|
original_automatic = @@persister.automatic
|
150
|
+
|
152
151
|
begin
|
153
152
|
#TODO -- impose some rules on nested transactions/enable_persisters??
|
153
|
+
|
154
154
|
Xampl.auto_persistence(automatic)
|
155
155
|
result = yield
|
156
156
|
Xampl.block_future_changes(true)
|
@@ -297,7 +297,9 @@ module Xampl
|
|
297
297
|
end
|
298
298
|
|
299
299
|
def Xampl.introduce_to_persister(xampl)
|
300
|
-
|
300
|
+
raise NoActivePersister unless @@persister
|
301
|
+
|
302
|
+
@@persister.introduce(xampl)
|
301
303
|
end
|
302
304
|
|
303
305
|
def Xampl.count_changed
|
@@ -324,12 +326,14 @@ module Xampl
|
|
324
326
|
end
|
325
327
|
|
326
328
|
def Xampl.clear_cache
|
327
|
-
|
329
|
+
raise NoActivePersister unless @@persister
|
330
|
+
@@persister.clear_cache
|
328
331
|
end
|
329
332
|
|
330
333
|
def Xampl.sync
|
331
334
|
#raise XamplException.new(:live_across_rollback) if @@persister.rolled_back
|
332
|
-
|
335
|
+
raise NoActivePersister unless @@persister
|
336
|
+
@@persister.sync
|
333
337
|
end
|
334
338
|
|
335
339
|
def Xampl.version(stream)
|
@@ -337,9 +341,7 @@ module Xampl
|
|
337
341
|
end
|
338
342
|
|
339
343
|
def Xampl.sync_all
|
340
|
-
@@known_persisters.each{ | name, persister |
|
341
|
-
persister.sync
|
342
|
-
}
|
344
|
+
@@known_persisters.each{ | name, persister | persister.sync }
|
343
345
|
end
|
344
346
|
|
345
347
|
def Xampl.close_all_persisters
|
@@ -349,52 +351,34 @@ module Xampl
|
|
349
351
|
end
|
350
352
|
|
351
353
|
def Xampl.rollback(persister=@@persister)
|
352
|
-
raise NoActivePersister unless persister
|
354
|
+
raise NoActivePersister unless @@persister
|
353
355
|
persister.rollback_cleanup
|
354
356
|
end
|
355
357
|
|
356
358
|
def Xampl.rollback_all
|
357
|
-
@@known_persisters.values.each{ | persister |
|
358
|
-
persister.rollback
|
359
|
-
}
|
359
|
+
@@known_persisters.values.each { | persister | persister.rollback }
|
360
360
|
end
|
361
361
|
|
362
362
|
def Xampl.lazy_load(xampl)
|
363
|
+
raise NoActivePersister.new unless @@persister
|
364
|
+
|
363
365
|
pid = xampl.get_the_index
|
364
|
-
if xampl and pid
|
365
|
-
@@persister.lazy_load(xampl, xampl.class, pid)
|
366
|
+
if xampl and pid then
|
367
|
+
@@persister.lazy_load(xampl, xampl.class, pid)
|
366
368
|
xampl.load_needed = false
|
367
369
|
else
|
368
|
-
|
370
|
+
raise "XAMPL.LAZY_LOAD -- REFUSED"
|
369
371
|
end
|
370
372
|
end
|
371
373
|
|
372
374
|
def Xampl.lookup(klass, pid)
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
def Xampl.lookup_lazy(klass, pid)
|
377
|
-
# TODO -- Make this work
|
378
|
-
puts "LOOKUP LAZY(#{klass.name}, #{pid})"
|
379
|
-
|
380
|
-
xampl = Xampl.find_known(klass, pid)
|
381
|
-
|
382
|
-
puts "LOOKUP LAZY(#{klass.name}, #{pid}) -- EXISTING: #{xampl}"
|
383
|
-
return xampl if xampl
|
384
|
-
|
385
|
-
#xampl = @@persister.lookup(klass, pid) if nil != persister
|
386
|
-
if nil != persister then
|
387
|
-
xampl = klass.new(pid) if nil != persister
|
388
|
-
xampl.load_needed = true
|
389
|
-
end
|
390
|
-
|
391
|
-
puts "LOOKUP LAZY(#{klass.name}, #{pid}) -- LAZY LOADER: #{xampl}"
|
392
|
-
|
393
|
-
return xampl
|
375
|
+
raise NoActivePersister unless @@persister
|
376
|
+
@@persister.lookup(klass, pid)
|
394
377
|
end
|
395
378
|
|
396
379
|
def Xampl.find_known(klass, pid)
|
397
|
-
|
380
|
+
raise NoActivePersister unless @@persister
|
381
|
+
xampl, ignore = @@persister.find_known(klass, pid)
|
398
382
|
return xampl
|
399
383
|
end
|
400
384
|
|
@@ -499,387 +483,35 @@ module Xampl
|
|
499
483
|
end
|
500
484
|
|
501
485
|
def Xampl.optimise(opts={})
|
502
|
-
|
486
|
+
raise NoActivePersister unless @@persister
|
487
|
+
|
488
|
+
@@persister.optimise(opts)
|
503
489
|
end
|
504
490
|
|
505
491
|
def Xampl.query(hint=false)
|
506
|
-
|
492
|
+
raise NoActivePersister unless @@persister
|
493
|
+
@@persister.query(hint) { | q | yield q }
|
507
494
|
end
|
508
495
|
|
509
496
|
def Xampl.find_xampl(hint=false)
|
510
|
-
|
497
|
+
raise NoActivePersister unless @@persister
|
498
|
+
@@persister.find_xampl(hint) { | q | yield q }
|
511
499
|
end
|
512
500
|
|
513
501
|
def Xampl.find_meta(hint=false)
|
514
|
-
|
502
|
+
raise NoActivePersister unless @@persister
|
503
|
+
@@persister.find_meta(hint) { | q | yield q }
|
515
504
|
end
|
516
505
|
|
517
506
|
def Xampl.find_pids(hint=false)
|
518
|
-
|
507
|
+
raise NoActivePersister unless @@persister
|
508
|
+
@@persister.find_pids(hint) { | q | yield q }
|
519
509
|
end
|
520
510
|
|
521
511
|
def Xampl.find_mentions_of(xampl)
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
class Persister
|
526
|
-
attr_accessor :name,
|
527
|
-
:automatic,
|
528
|
-
:block_changes,
|
529
|
-
:read_count, :total_read_count,
|
530
|
-
:write_count, :total_write_count,
|
531
|
-
:total_sync_count, :total_rollback_count,
|
532
|
-
:cache_hits, :total_cache_hits,
|
533
|
-
:last_write_count,
|
534
|
-
:rolled_back
|
535
|
-
attr_reader :syncing, :format
|
536
|
-
|
537
|
-
def initialize(name=nil, format=nil)
|
538
|
-
@name = name
|
539
|
-
@format = format
|
540
|
-
@automatic = false
|
541
|
-
@changed = {}
|
542
|
-
@cache_hits = 0
|
543
|
-
@total_cache_hits = 0
|
544
|
-
@read_count = 0
|
545
|
-
@total_read_count = 0
|
546
|
-
@write_count = 0
|
547
|
-
@total_write_count = 0
|
548
|
-
@last_write_count = 0
|
549
|
-
@total_sync_count = 0
|
550
|
-
@total_rollback_count = 0
|
551
|
-
@rolled_back = false
|
552
|
-
@syncing = false
|
553
|
-
|
554
|
-
@busy_count = 0
|
555
|
-
end
|
556
|
-
|
557
|
-
def optimise(opts)
|
558
|
-
end
|
559
|
-
|
560
|
-
def close
|
561
|
-
self.sync
|
562
|
-
end
|
563
|
-
|
564
|
-
def busy(yes)
|
565
|
-
if yes then
|
566
|
-
@busy_count += 1
|
567
|
-
elsif 0 < @busy_count then
|
568
|
-
@busy_count -= 1
|
569
|
-
end
|
570
|
-
end
|
571
|
-
|
572
|
-
def is_busy
|
573
|
-
return 0 < @busy_count
|
574
|
-
end
|
575
|
-
|
576
|
-
def introduce(xampl)
|
577
|
-
if xampl.introduce_persister(self) then
|
578
|
-
cache(xampl)
|
579
|
-
end
|
580
|
-
has_changed(xampl) if xampl.is_changed
|
581
|
-
end
|
582
|
-
|
583
|
-
def has_changed(xampl)
|
584
|
-
#raise XamplException.new(:live_across_rollback) if @rolled_back
|
585
|
-
# puts "!!!! has_changed #{xampl} #{xampl.get_the_index} -- persist required: #{xampl.persist_required}"
|
586
|
-
if xampl.persist_required && xampl.is_changed then
|
587
|
-
unless self == xampl.persister
|
588
|
-
raise MixedPersisters.new(xampl.persister, self)
|
589
|
-
end
|
590
|
-
@changed[xampl] = xampl
|
591
|
-
# puts "!!!! change recorded ==> #{@changed.size}/#{count_changed} #{@changed.object_id} !!!!"
|
592
|
-
# @changed.each{ | thing, ignore |
|
593
|
-
# puts " changed: #{thing}, index: #{thing.get_the_index}, changed: #{thing.is_changed}"
|
594
|
-
# }
|
595
|
-
end
|
596
|
-
end
|
597
|
-
|
598
|
-
def has_not_changed(xampl)
|
599
|
-
# puts "!!!! has_not_changed #{xampl} #{xampl.get_the_index} -- in @changed: #{nil != @changed[xampl]}"
|
600
|
-
@changed.delete(xampl) if xampl
|
601
|
-
end
|
602
|
-
|
603
|
-
def count_changed
|
604
|
-
# @changed.each{ | thing, ignore |
|
605
|
-
# puts "changed: #{thing}, index: #{thing.get_the_index}"
|
606
|
-
# }
|
607
|
-
return @changed.size
|
608
|
-
end
|
609
|
-
|
610
|
-
def cache(xampl)
|
611
|
-
raise XamplException.new(:unimplemented)
|
612
|
-
end
|
613
|
-
|
614
|
-
def uncache(xampl)
|
615
|
-
raise XamplException.new(:unimplemented)
|
616
|
-
end
|
617
|
-
|
618
|
-
def clear_cache
|
619
|
-
raise XamplException.new(:unimplemented)
|
620
|
-
end
|
621
|
-
|
622
|
-
def Persister.replace(old_xampl, new_xampl)
|
623
|
-
pid = old_xampl.get_the_index
|
624
|
-
if old_xampl.persister != @@persister then
|
625
|
-
raise MixedPersisters.new(@@persister, old_xampl.persister)
|
626
|
-
end
|
627
|
-
if new_xampl.persister != @@persister then
|
628
|
-
raise MixedPersisters.new(@@persister, new_xampl.persister)
|
629
|
-
end
|
630
|
-
|
631
|
-
new_xampl.note_replacing(old_xampl)
|
632
|
-
|
633
|
-
unless old_xampl.load_needed then
|
634
|
-
Xampl.log.warn("Replacing live xampl: #{old_xampl} pid: #{pid}")
|
635
|
-
@@persister.uncache(old_xampl)
|
636
|
-
old_xampl.invalidate
|
637
|
-
end
|
638
|
-
new_xampl.pid = nil
|
639
|
-
new_xampl.pid = pid
|
640
|
-
@@persister.introduce(new_xampl)
|
641
|
-
end
|
642
|
-
|
643
|
-
def represent(xampl, mentions=[])
|
644
|
-
#puts "REPRESENT #{xampl} load needed: #{xampl.load_needed}"
|
645
|
-
# return nil if xampl.load_needed
|
646
|
-
case xampl.default_persister_format || @format
|
647
|
-
when nil, :xml_format then
|
648
|
-
return xampl.persist("", mentions)
|
649
|
-
when :ruby_format then
|
650
|
-
return xampl.to_ruby(mentions)
|
651
|
-
when :yaml_format then
|
652
|
-
return xampl.as_yaml
|
653
|
-
end
|
654
|
-
end
|
655
|
-
|
656
|
-
def realise(representation, target=nil)
|
657
|
-
# Normally we'd expect to see the representation in the @format format, but
|
658
|
-
# that isn't necessarily the case. Try to work out what the format might be...
|
659
|
-
|
660
|
-
if representation =~ /^</ then
|
661
|
-
return XamplObject.realise_from_xml_string(representation, target)
|
662
|
-
elsif representation =~ /^-/ then
|
663
|
-
return XamplObject.from_yaml(representation, target)
|
664
|
-
else
|
665
|
-
XamplObject.from_ruby(representation, target)
|
666
|
-
end
|
667
|
-
|
668
|
-
# case @format
|
669
|
-
# when nil, :xml_format then
|
670
|
-
# return XamplObject.realise_from_xml_string(representation, target)
|
671
|
-
# when :ruby_format then
|
672
|
-
# XamplObject.from_ruby(representation, target)
|
673
|
-
# when :yaml_format then
|
674
|
-
# return XamplObject.from_yaml(representation, target)
|
675
|
-
# end
|
676
|
-
end
|
677
|
-
|
678
|
-
def version(stream)
|
679
|
-
raise XamplException.new(:unimplemented)
|
680
|
-
# catch(:refuse_to_version) do
|
681
|
-
# end
|
682
|
-
end
|
683
|
-
|
684
|
-
def write(xampl)
|
685
|
-
raise XamplException.new(:unimplemented)
|
686
|
-
end
|
687
|
-
|
688
|
-
def read(klass, pid, target=nil)
|
689
|
-
raise XamplException.new(:unimplemented)
|
690
|
-
end
|
691
|
-
|
692
|
-
def lookup(klass, pid)
|
693
|
-
#raise XamplException.new(:live_across_rollback) if @rolled_back
|
694
|
-
#puts "#{File.basename(__FILE__)} #{__LINE__} LOOKUP:: klass: #{klass} pid: #{pid}"
|
695
|
-
|
696
|
-
begin
|
697
|
-
busy(true)
|
698
|
-
xampl = read(klass, pid)
|
699
|
-
ensure
|
700
|
-
busy(false)
|
701
|
-
end
|
702
|
-
|
703
|
-
#puts "#{File.basename(__FILE__)} #{__LINE__} ---> #{ xampl }"
|
704
|
-
|
705
|
-
return xampl
|
706
|
-
end
|
707
|
-
|
708
|
-
def find_known(klass, pid)
|
709
|
-
#raise XamplException.new(:live_across_rollback) if @rolled_back
|
710
|
-
|
711
|
-
xampl = read_from_cache(klass, pid, nil)
|
712
|
-
|
713
|
-
return xampl
|
714
|
-
end
|
715
|
-
|
716
|
-
def lazy_load(target, klass, pid)
|
717
|
-
# puts "#{File.basename(__FILE__)} #{__LINE__} LAZY_LOAD:: klass: #{klass} pid: #{pid} target: #{target}"
|
718
|
-
|
719
|
-
xampl = read(klass, pid, target)
|
720
|
-
|
721
|
-
# puts " LAZY_LOAD --> #{xampl}"
|
722
|
-
|
723
|
-
return xampl
|
724
|
-
end
|
725
|
-
|
726
|
-
def put_changed(msg="")
|
727
|
-
puts "Changed::#{msg}:"
|
728
|
-
@changed.each { | xampl, ignore | puts " #{xampl.tag} #{xampl.get_the_index}" }
|
729
|
-
end
|
730
|
-
|
731
|
-
def do_sync_write
|
732
|
-
unchanged_in_changed_list = 0
|
733
|
-
@changed.each { | xampl, ignore |
|
734
|
-
unchanged_in_changed_list += 1 unless xampl.is_changed
|
735
|
-
unless xampl.kind_of?(InvalidXampl) then
|
736
|
-
write(xampl)
|
737
|
-
end
|
738
|
-
}
|
739
|
-
end
|
740
|
-
|
741
|
-
def sync
|
742
|
-
#raise XamplException.new(:live_across_rollback) if @rolled_back
|
743
|
-
begin
|
744
|
-
#puts "SYNC"
|
745
|
-
#puts "SYNC"
|
746
|
-
#puts "SYNC changed: #{@changed.size}" if 0 < @changed.size
|
747
|
-
#@changed.each do | key, value |
|
748
|
-
##puts " #{key.class.name}"
|
749
|
-
##puts "key: #{key.class.name}, value: #{value.class.name}"
|
750
|
-
#puts key.to_xml
|
751
|
-
#end
|
752
|
-
#puts "SYNC"
|
753
|
-
#puts "SYNC"
|
754
|
-
|
755
|
-
#if 0 < @changed.size then
|
756
|
-
#puts "SYNC changed: #{@changed.size}"
|
757
|
-
##caller(0).each do | trace |
|
758
|
-
## next if /xamplr/ =~ trace
|
759
|
-
## puts " #{trace}"
|
760
|
-
## break if /actionpack/ =~ trace
|
761
|
-
##end
|
762
|
-
#end
|
763
|
-
busy(true)
|
764
|
-
@syncing = true
|
765
|
-
|
766
|
-
do_sync_write
|
767
|
-
|
768
|
-
@changed = {}
|
769
|
-
|
770
|
-
@total_read_count = @total_read_count + @read_count
|
771
|
-
@total_write_count = @total_write_count + @write_count
|
772
|
-
@total_cache_hits = @total_cache_hits + @cache_hits
|
773
|
-
@total_sync_count = @total_sync_count + 1
|
774
|
-
|
775
|
-
@read_count = 0
|
776
|
-
@last_write_count = @write_count
|
777
|
-
@write_count = 0
|
778
|
-
|
779
|
-
self.sync_done()
|
780
|
-
|
781
|
-
return @last_write_count
|
782
|
-
ensure
|
783
|
-
busy(false)
|
784
|
-
@syncing = false
|
785
|
-
end
|
786
|
-
end
|
787
|
-
|
788
|
-
def sync_done
|
789
|
-
raise XamplException.new(:unimplemented)
|
790
|
-
end
|
791
|
-
|
792
|
-
def rollback
|
793
|
-
begin
|
794
|
-
busy(true)
|
795
|
-
|
796
|
-
return Xampl.rollback(self)
|
797
|
-
ensure
|
798
|
-
busy(false)
|
799
|
-
end
|
800
|
-
end
|
801
|
-
|
802
|
-
def rollback_cleanup
|
803
|
-
@changed = {}
|
804
|
-
end
|
805
|
-
|
806
|
-
def print_stats
|
807
|
-
printf("SYNC:: TOTAL cache_hits: %d, reads: %d, writes: %d\n",
|
808
|
-
@total_cache_hits, @total_read_count, @total_write_count)
|
809
|
-
printf(" cache_hits: %d, reads: %d, last writes: %d\n",
|
810
|
-
@cache_hits, @read_count, @last_write_count)
|
811
|
-
printf(" syncs: %d\n", @total_sync_count)
|
812
|
-
printf(" changed count: %d (%d)\n", count_changed, @changed.size)
|
813
|
-
@changed.each{ | thing, ignore |
|
814
|
-
if thing.is_changed then
|
815
|
-
puts " changed: #{thing}, index: #{thing.get_the_index}"
|
816
|
-
else
|
817
|
-
puts " UNCHANGED: #{thing}, index: #{thing.get_the_index} <<<<<<<<<<<<<<<<<<< BAD!"
|
818
|
-
end
|
819
|
-
}
|
820
|
-
end
|
821
|
-
end
|
822
|
-
|
823
|
-
class NoActivePersister < Exception
|
824
|
-
def message
|
825
|
-
"No Persister is active"
|
826
|
-
end
|
827
|
-
end
|
828
|
-
|
829
|
-
class BlockedChange < Exception
|
830
|
-
attr_reader :xampl
|
831
|
-
|
832
|
-
def initialize(xampl=nil)
|
833
|
-
@xampl = xampl
|
834
|
-
end
|
835
|
-
|
836
|
-
def message
|
837
|
-
"attempt to change #{@xampl}, pid: #{@xampl.get_the_index}, oid: #{@xampl.object_id} when changes are blocked"
|
838
|
-
end
|
839
|
-
end
|
840
|
-
|
841
|
-
class UnmanagedChange < Exception
|
842
|
-
attr_reader :xampl
|
843
|
-
|
844
|
-
def initialize(xampl=nil)
|
845
|
-
@xampl = xampl
|
846
|
-
end
|
847
|
-
|
848
|
-
def message
|
849
|
-
"attempt to change #{@xampl}, pid: #{@xampl.get_the_index}, oid: #{@xampl.object_id} outside of its persister's management"
|
850
|
-
end
|
851
|
-
end
|
852
|
-
|
853
|
-
class IncompatiblePersisterRequest < Exception
|
854
|
-
attr_reader :msg
|
855
|
-
|
856
|
-
def initialize(persister, feature_name, requested_feature_value, actual_feature_value)
|
857
|
-
@msg = "persister #{persister.name}:: requested feature: #{feature_name} #{requested_feature_value}, actual: #{actual_feature_value}"
|
858
|
-
end
|
859
|
-
|
860
|
-
def message
|
861
|
-
@msg
|
862
|
-
end
|
512
|
+
raise NoActivePersister unless @@persister
|
513
|
+
@@persister.find_mentions_of(xampl)
|
863
514
|
end
|
864
515
|
|
865
|
-
class MixedPersisters < Exception
|
866
|
-
attr_reader :msg
|
867
|
-
|
868
|
-
def initialize(active, local)
|
869
|
-
@msg = "mixed persisters:: active #{active.name}, local: #{local.name}"
|
870
|
-
end
|
871
|
-
|
872
|
-
def message
|
873
|
-
@msg
|
874
|
-
end
|
875
|
-
end
|
876
|
-
|
877
|
-
require "xamplr/persister/simple"
|
878
|
-
require "xamplr/persister/in-memory"
|
879
|
-
require "xamplr/persister/filesystem"
|
880
|
-
|
881
|
-
if require 'tokyocabinet' then
|
882
|
-
require "xamplr/persister/tokyo-cabinet"
|
883
|
-
end
|
884
516
|
end
|
885
517
|
|