ADB
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: 'Documentation and Code Structure - RepCRec' tags: 'NYU' --- # Documentation and Code Structure - RepCRec <!-- design doc w/ team members, major modules, what they do, the programming language we use You merely have to create the correct input-output behavior based on the dump(), R, W, begin, end, fail, recover directives. --> ## Team Members - Yu-Wen Lai (yl8332@nyu.edu) - Yu-Hsing Wang (yw5629@nyu.edu) ## Programming Language Java 8 ## Design Graph ![](https://i.imgur.com/PkWL4J0.png) ## Major Modules ### `TransactionManager` > Author: Yu-Hsing Wang, Yu-Wen Lai > Translates operations on variables of sites by transactions using the available copy algorithm. ### `Site` > Author: Yu-Wen Lai > Perform recovery when the site fails. > Manage replicated variables and non-replicated varivable of the sites. ### `LockManager` > Author: Yu-Hsing Wang > Perform locks > Manage read locks and write locks of each sites. ## How To Run * run test1 ~ test24 in the `inputs` directory * use this command: `./runit.sh` * output files will be generated in the `outputs` directory * run certain test * use this command: `java -jar RepCRec.jar ./inputs/test1.txt` * output file `test1.txt_out` will be generated in the `outputs` directory * unzip and run reprounzip file * use this command to unzip: `./reprounzip directory setup RepCRec.rpz ~/yourDesiredDirectoryName` * use this command to run: `./reprounzip directory run ~/yourDesiredDirectoryName` * it will run test1 ~ test24 in the `inputs` directory * output files will be generated in the `outputs` directory ## Testing Scripts * test4 in `inputs/test4.txt` ``` begin(T1) begin(T2) R(T1,x3) > T1 add read lock on x3 of site 4 W(T2,x8,88) > T2 add write lock on x8 of all sites fail(2) > cause T2 abort when it ends because x8 is on site 2 and T2 accessed it > relase all locks on site 2 R(T2,x3) > T2 cannot be executed because it will abort when it ends W(T1,x4,91) > T1 add write lock on x4 of site 1, 3, 4, 5, 6, 7, 8, 9, 10 recover(2) > activate site 2 > replicated variables on site 2 cannot be read until committed write takes place on them end(T2) > T2 aborts because site 2's fail end(T1) > T1 commits, so x4 of site 1, 3, 4, 5, 6, 7, 8, 9, 10 is updated to 91 dump() > x4: 91 at site 1, 3, 4, 5, 6, 7, 8, 9, 10 > All other variables have their initial values ``` * test8 in `inputs/test8.txt` ``` begin(T1) begin(T2) fail(3) fail(4) R(T1,x1) > T1 add read lock on x1 of site 2 W(T2,x8,88) > T2 add write lock on x8 of site 1, 2, 5, 6, 7, 8, 9, 10 end(T1) > T1 commits and releases all locks it caused recover(4) > activate site 4 > replicated variables on site 4 cannot be read until committed write takes place on them recover(3) > activate site 3 > replicated variables on site 3 cannot be read until committed write takes place on them R(T2,x3) > T2 add read lock on x3 of site 4 > because site 4 is recovered and x3 is non-replicated data, so T2 can read it end(T2) > T2 commits, so x8 is updated to 88 on site 1, 2, 5, 6, 7, 8, 9, 10 > releases all locks it caused dump() > x8: 88 at site 1, 2, 5, 6, 7, 8, 9, 10 > All other variables have their initial values ``` * test10 in `inputs/test10.txt` ``` begin(T1) beginRO(T2) > keep all the last commited variables of available sites for non-replicated data and that of site which is active from last committed time till now for replicated data > keep all variables with their initial values R(T2,x1) > T2 read the data it kept when it begins, so x1 is 10 R(T2,x2) > T2 read the data it kept when it begins, so x2 is 20 W(T1,x3,33) > add write lock to x3 of site 4 end(T1) > T1 commits, so x3 of site 4 is updated to 33 > released all locks caused by T1 beginRO(T3) > keep all the last commited variables of available sites for non-replicated data and that of site which is active from last committed time till now for replicated data > keep x3 with value 33 and all other variables with their initial values R(T3,x3) > T3 read the data it kept when it begins, so x3 is 33 R(T2,x3) > T2 read the data it kept when it begins, so x3 is 30 end(T2) > T2 commits end(T3) > T3 commits dump() > x3: 33 at site 4 > All other variables have their initial values ``` * test17 in `inputs/test17.txt` ``` begin(T5) begin(T4) begin(T3) begin(T2) begin(T1) W(T1,x4, 5) > add write lock on x4 of all sites fail(2) > cause T1 abort when it ends because x4 is on site 2 and T1 accessed it > relase all locks on site 2 W(T2,x4,44) > T2 should wait until T1 ends and releases write lock on x4 of site 1,3,4,5,6,7,8,9,10 recover(2) > activate site 2 > replicated variables on site 2 cannot be read until committed write takes place on them W(T3,x4,55) > T3 should wait until T1 ends and releases write lock on x4 of site 1,3,4,5,6,7,8,9,10 W(T4,x4,66) > T4 should wait until T1 ends and releases write lock on x4 of site 1,3,4,5,6,7,8,9,10 W(T5,x4,77) > T5 should wait until T1 ends and releases write lock on x4 of site 1,3,4,5,6,7,8,9,10 end(T1) > T1 aborts because site 2's fail > release all locks T1 caused, so W(T2,x4,44) can be executed > T3, T4, T5 should wait until T2 ends and releases write lock on x4 of all sites end(T2) > T2 commits, so x4 of all sites is updated to 44 > release all locks T2 caused, so W(T3,x4,55) can be executed > T4, T5 should wait until T3 ends and releases write lock on x4 of all sites end(T3) > T3 commits, so x4 of all sites is updated to 55 > release all locks T3 caused, so W(T4,x4,66) can be executed > T5 should wait until T4 ends and releases write lock on x4 of all sites end(T4) > T4 commits, so x4 of all sites is updated to 66 > release all locks T4 caused, so W(T5,x4,77) can be executed end(T5) > T5 commits, so x4 of all sites is updated to 77 > release all locks T4 caused dump() > x4: 77 at all sites > All other variables have their initial values ``` * test23 in `inputs/test23.txt` ``` begin(T1) begin(T2) R(T2, x2) > T2 add read lock on x2 of all sites W(T1, x2, 202) > T1 should wait until T2 ends and releases its read lock on x2 on all sites W(T2, x2, 302) > T2 cannot promote its read lock to a write lock because it cannot skip T1's write operation, so T2 should wait until T1 ends > deadlock happened! T2 is younger, so abort T2 and release all lock T2 caused > W(T1, x2, 202) can be executed end(T1) > T1 commits, so x2 of all sites is updated to 202 > release all locks T1 caused dump() > x2: 202 at all sites > All other variables have their initial values ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully