首页 > 其他分享 >CSC8016用户场景

CSC8016用户场景

时间:2023-05-05 12:44:43浏览次数:45  
标签:product 场景 items 用户 transaction CSC8016 user basket should


Coursework CSC8016
Use Case Scenario
We want to implement a virtual shopping system, whether the threads are either clients using the
web app, or clients buying products on the physical shop using the mobile app. The lifecycle of any
client interaction is summerised by ClientLifecycle: Each client interacts with the shop through
the RainforestShop via the login method, through which each client can add items to its basket and
perform re-shelving operations (moving the items back to the physical/virtual shelf from the basket).
Each client can get a list of available items at the time of the query, basket a given product by name,
(re)shelf the product (thus removing it from the basket), checkout and proceed with the payment
(thus either buying all the items on the basket or none of those entirely), and logging out of the system
while losing the information of all the items being previously put in the basket from the real/virtual
shelf (thus entailing implicit re-shelving).
Each time an allowed user logs in, a non-empty transaction will be created with an unique transaction
ID. The unavailability of the product shall be confirmed not while basketing the items, rather than
after purchasing those. At this stage, the shop supplier (SupplierLifecycle) might be notified that
some products are missing (getNextMissingItem) and refurbish the show with a non-zero amount
of products of the same type (refurbishWithItems). For simplicity sake, the refurbishWithItems
method will be in charge of creating the number of desired product and to place them on the shelf.
As in any industrial setting where teams split up the duties, you are assigned an API that you need to
implement. Such an API is provided both on Canvas and at https://github.com/jackbergus/NCL_
CSC8016/tree/main/src/main/java/uk/ncl/CSC8016/jackbergus/coursework/project2. This will
then require to finalise the implementation of RainforestShop and the integration of concurrency
mechanisms in ProductMonitor; the Transaction class shall not be changed! The Testing solves a
twofold task: showing how Clients, Suppliers, and the Shop system are communicating, as well as
providing some preliminary guidelines on how the coursework is going to be assessed. The student
is free to choose whichever is the best way to pass the tests (not fully disclosed to the students) in
the Testing class. E.g., the RainforestShop could be either modelled as a finer-grained monitor, but
inside this monitor at least one thread per logged user should be running; also, such a RainforestShop
could be also implemented as a consumer threads handling all of the clients’ messages.
Assumptions
• In a realistic example, communications happen between processes via UDP messages. In this
module, we don’t require that. We can freely assume that each client (Physical person buying
items in the show using the mobile app, OnLine Shopper) is mimicked by one single thread. We
assume they directly exploit such an interface (no FrontEnd is required!)
1
• If the RainforestShop is implemented as a server, such a thread might receive the “client messages” through shared variables.
• The RainforestShop already comes with a Transaction class keeping track of the transactions
that are performed for handling basketing operations. You are not required to tolerate the
server crash (this is more of a back-up task rather than a concurrent programming one), but
you must correcly handle client log outs (withdrawn items from the shelves after log-out should
be automatically re-shelved with a cookie-free assumption, where the basket is not “rembered”
after re-logging in)!
• We assume that the RainforestShop class is initialized with the users allowed to shop using
the mobile app or OnLine website (Collection<String> client_ids), the association between
the name of the product (String), its cost (Double) and a non-zero Integer number of available items to purchase (Map<String, Pair<Double, Integer» available_products). The students are encouraged to change the studentId so to return their student ID, as well as setting
isGlobalLock to true if the students use a pessimistic protocol, and false otherwise. in The
system should not allow to register/unroll new users/shoppers.
• The server should allow a single user contemporarily loggin in with the same username as far
as different transaction IDs are given to distinguish different concurrent operations. In order
to maximise seriality and concurrency requirements, the students might investigate optimistic
protocols for transactions, but this is not strictly required.
• A solution might be deemed incorrect for the following reasons:
1. Products that were originally basketed cannot be bought any more (e.g., both users attempted to basket a product but only one of them was able to buy it).
2. The same product name with the same product id cannot be bought multiple times.
3. Somehow, the computations are “logically” correct with single-threaded scenarios, that is
basket, reshelf, checkout, and logout implement the expected semantics. Still, this is not
sufficient for passing the coursework with full marks.
Submission Requirements
1. RainforestShop and ProductMonitor should be finalised, as the current implementation does
not pass the provided tests!
2. Submit the code as a zipped Maven project. with no jar and classes. The source code will be
recompiled from scratch, and no jar/class is going to be run.
3. If you want to use an external Java library, please consider the following:
• The Java library should be explicitly described as a <dependency> in the pom.xml file, and
should only access the libraries from the default Maven Central Repository.
• A library might provide single concurrency mechanisms primitives, but not ready-made
solutions already composing those: semaphores, monitors, locks, just logs, thread barriers,
thread pools, passing le baton mechanisms are allowed. Code reuse from the exercises and
examples seen in class is permitted.
• Systems completely solving the coursework for you are strictly prohibited: e.g., any kind
of (data) management system having concurrency control (ensuring safe concurrent thread
access to any data representation) and supporting concurrent transactions (implementing
2
any kind of transaction protocol, either pessimistic or optimistic) must be avoided, as they
both implement commit/aborts and thread-safe operations on data.
• None of the (direct or indirect) dependencies of the coursework should rely on external
servers or processes to run or to be installed.
• The solution should not include external jar files.
• If unsure whether the solution might be exploited, please ask before submitting.
4. Attached to the source code, please provide a short report motivating the compliance of the
source code to each point and sub-point of the marking scheme. Providing such report in form
of comments in the implementation is also fine. New classes might be created for supporting the
implementation, but existing classes should be neither renamed or moved to a different package.
Marking Scheme
The marking scheme is capped at 100%.
• Single-Thread Correctness [+52%]
+4%: I cannot open a transaction if the user does not appear in the users’ collection.
■ (You) cannot login (and therefore, start a transaction) if a user is not listed (no user
appearing in the initial RainforestShop collection).
■ Cannot login (and therefore, start a transaction) if a user is not listed (User not appearing
in the RainforestShop collection).
+3%: I can always open a transaction if the user, on the other hand, appears on the users’
collection.
+7%: I cannot log-out multiple times using the same transaction, but it should be possible to
re-log in, and the novel transaction shall have a different id.
■ Can immediately log-out after logging in on the same transaction.
■ Logging out multiple times on the same transaction is not permitted (returns false).
■ The same user can open multiple transactions (not necessarily being contemporarily
open).
■ Each transaction opened by the user should come with a distinct transaction id.
+7%: I must neither basket nor purchase unavailable products.
■ Cannot basket items when the map is empty.
■ Cannot basket items not listed in the map.
■ Cannot basket more items than specified in the map.
■ Can basket available products.
■ Can shelf previously-basketed products.
■ Can re-basket a product that was previously shelved.
■ After the last point, I cannot re-basket the same item another time.
3
+3%: Logging out automatically re-shelves all the remaining product non-purchased in the
basket, and therefore it shall be possible to re-basket the products.
+3%: Logging out should also automatically disable all the remaining operations available
through the transaction (mainly basketProduct, shelfProduct, and basketCheckout).
+20%: Correctly purchasing the available items (single-threaded).
■ It should be possible to basket checkout when the basket is empty, with any given
amount of money
■ After successfully purchasing one item, the checkout returns the correct information.
■ After successfully purchasing two items, the checkout returns the correct information.
■ When attempting to purchase three items where only two are available, the checkout
correctly purchases two items.
+5%: Correctly shelving the products.
■ Cannot shelf a product that did not originally exist.
■ Cannot shelf a product that was not basketed (empty basket).
■ Cannot shelf a product that was not basketed (non-empty basket).
■ Can shelf a product that was originally basketed.
• Multi-Threaded Correctness [+38%]
+6%: The same user can log-in multiple times.
■ The same user can open multiple transactions (contemporarily open).
+6%: Two threads shall never be able (in any possible run) to contemporary access to the same
object on the shelf.
+5%: A client running without a supplier shall always dispose the available resources.
■ In particular, a ClientLifecycle should be able to buy all the available elements if
given an adequate amount of money.
+6%: Correct Client/Shop/Supplier interaction. This might be tested with at least one
ClientLifecycle and one SupplierLifecycle running.
■ The supplier shall not be triggered if the products are basketed but not bought (as they
can be later on re-shelved).
■ The supplier shall be triggered when a shelf for a given product is emptied.
■ After refurbishment, a client shall be able to buy at least one more product.
+12%: Correct Client/Client interaction (two distinct users and two transactions from the
same user).
■ The clients bought the maximum number of available items.
■ The clients bought 3 distinct items.
■ The clients cannot contemporarily buy the same item.
+3%: Correct Supplier Stopping.
4
■ The supplier is stopped by receiving a @stop! message only when the stopSupplier
method is invoked.
■ Currency is handled correctly.
• Advanced Features
■ [+5%] The RainforestShop is emulated realistically as a separate thread.
■ [+1%] The code exploits Java’s concurrent collections.
■ [+1%] The program allows to visually determine the correctness of the operations performed by the threads (e.g., terminal prints or graphical user interfaces).
■ [+1%] The student correctly uses ReentrantLocks and Conditions.
■ [+2%] The student correctly exploits semaphores.
■ [+2%] The student exploited the optimistic transaction principle, where multiple users can
log-in (not only the same user multiple times!).
■ [+2%] Usage of monitors or multithreaded producers and consumers on the interaction
with the supplier (semaphores might be also exploited).
■ [+3%] Thread pools are used to handle multiple requests from multiple users.
■ [+3%] Any Java library imported via pom.xml ‘not violating the 3rd Submission Requirement.


Coursework CSC8016
Use Case Scenario
We want to implement a virtual shopping system, whether the threads are either clients using the
web app, or clients buying products on the physical shop using the mobile app. The lifecycle of any
client interaction is summerised by ClientLifecycle: Each client interacts with the shop through
the RainforestShop via the login method, through which each client can add items to its basket and
perform re-shelving operations (moving the items back to the physical/virtual shelf from the basket).
Each client can get a list of available items at the time of the query, basket a given product by name,
(re)shelf the product (thus removing it from the basket), checkout and proceed with the payment
(thus either buying all the items on the basket or none of those entirely), and logging out of the system
while losing the information of all the items being previously put in the basket from the real/virtual
shelf (thus entailing implicit re-shelving).
Each time an allowed user logs in, a non-empty transaction will be created with an unique transaction
ID. The unavailability of the product shall be confirmed not while basketing the items, rather than
after purchasing those. At this stage, the shop supplier (SupplierLifecycle) might be notified that
some products are missing (getNextMissingItem) and refurbish the show with a non-zero amount
of products of the same type (refurbishWithItems). For simplicity sake, the refurbishWithItems
method will be in charge of creating the number of desired product and to place them on the shelf.
As in any industrial setting where teams split up the duties, you are assigned an API that you need to
implement. Such an API is provided both on Canvas and at https://github.com/jackbergus/NCL_
CSC8016/tree/main/src/main/java/uk/ncl/CSC8016/jackbergus/coursework/project2. This will
then require to finalise the implementation of RainforestShop and the integration of concurrency
mechanisms in ProductMonitor; the Transaction class shall not be changed! The Testing solves a
twofold task: showing how Clients, Suppliers, and the Shop system are communicating, as well as
providing some preliminary guidelines on how the coursework is going to be assessed. The student
is free to choose whichever is the best way to pass the tests (not fully disclosed to the students) in
the Testing class. E.g., the RainforestShop could be either modelled as a finer-grained monitor, but
inside this monitor at least one thread per logged user should be running; also, such a RainforestShop
could be also implemented as a consumer threads handling all of the clients’ messages.
Assumptions
• In a realistic example, communications happen between processes via UDP messages. In this
module, we don’t require that. We can freely assume that each client (Physical person buying
items in the show using the mobile app, OnLine Shopper) is mimicked by one single thread. We
assume they directly exploit such an interface (no FrontEnd is required!)
1
• If the RainforestShop is implemented as a server, such a thread might receive the “client messages” through shared variables.
• The RainforestShop already comes with a Transaction class keeping track of the transactions
that are performed for handling basketing operations. You are not required to tolerate the
server crash (this is more of a back-up task rather than a concurrent programming one), but
you must correcly handle client log outs (withdrawn items from the shelves after log-out should
be automatically re-shelved with a cookie-free assumption, where the basket is not “rembered”
after re-logging in)!
• We assume that the RainforestShop class is initialized with the users allowed to shop using
the mobile app or OnLine website (Collection<String> client_ids), the association between
the name of the product (String), its cost (Double) and a non-zero Integer number of available items to purchase (Map<String, Pair<Double, Integer» available_products). The students are encouraged to change the studentId so to return their student ID, as well as setting
isGlobalLock to true if the students use a pessimistic protocol, and false otherwise. in The
system should not allow to register/unroll new users/shoppers.
• The server should allow a single user contemporarily loggin in with the same username as far
as different transaction IDs are given to distinguish different concurrent operations. In order
to maximise seriality and concurrency requirements, the students might investigate optimistic
protocols for transactions, but this is not strictly required.
• A solution might be deemed incorrect for the following reasons:
1. Products that were originally basketed cannot be bought any more (e.g., both users attempted to basket a product but only one of them was able to buy it).
2. The same product name with the same product id cannot be bought multiple times.
3. Somehow, the computations are “logically” correct with single-threaded scenarios, that is
basket, reshelf, checkout, and logout implement the expected semantics. Still, this is not
sufficient for passing the coursework with full marks.
Submission Requirements
1. RainforestShop and ProductMonitor should be finalised, as the current implementation does
not pass the provided tests!
2. Submit the code as a zipped Maven project. with no jar and classes. The source code will be
recompiled from scratch, and no jar/class is going to be run.
3. If you want to use an external Java library, please consider the following:
• The Java library should be explicitly described as a <dependency> in the pom.xml file, and
should only access the libraries from the default Maven Central Repository.
• A library might provide single concurrency mechanisms primitives, but not ready-made
solutions already composing those: semaphores, monitors, locks, just logs, thread barriers,
thread pools, passing le baton mechanisms are allowed. Code reuse from the exercises and
examples seen in class is permitted.
• Systems completely solving the coursework for you are strictly prohibited: e.g., any kind
of (data) management system having concurrency control (ensuring safe concurrent thread
access to any data representation) and supporting concurrent transactions (implementing
2
any kind of transaction protocol, either pessimistic or optimistic) must be avoided, as they
both implement commit/aborts and thread-safe operations on data.
• None of the (direct or indirect) dependencies of the coursework should rely on external
servers or processes to run or to be installed.
• The solution should not include external jar files.
• If unsure whether the solution might be exploited, please ask before submitting.
4. Attached to the source code, please provide a short report motivating the compliance of the
source code to each point and sub-point of the marking scheme. Providing such report in form
of comments in the implementation is also fine. New classes might be created for supporting the
implementation, but existing classes should be neither renamed or moved to a different package.
Marking Scheme
The marking scheme is capped at 100%.
• Single-Thread Correctness [+52%]
+4%: I cannot open a transaction if the user does not appear in the users’ collection.
■ (You) cannot login (and therefore, start a transaction) if a user is not listed (no user
appearing in the initial RainforestShop collection).
■ Cannot login (and therefore, start a transaction) if a user is not listed (User not appearing
in the RainforestShop collection).
+3%: I can always open a transaction if the user, on the other hand, appears on the users’
collection.
+7%: I cannot log-out multiple times using the same transaction, but it should be possible to
re-log in, and the novel transaction shall have a different id.
■ Can immediately log-out after logging in on the same transaction.
■ Logging out multiple times on the same transaction is not permitted (returns false).
■ The same user can open multiple transactions (not necessarily being contemporarily
open).
■ Each transaction opened by the user should come with a distinct transaction id.
+7%: I must neither basket nor purchase unavailable products.
■ Cannot basket items when the map is empty.
■ Cannot basket items not listed in the map.
■ Cannot basket more items than specified in the map.
■ Can basket available products.
■ Can shelf previously-basketed products.
■ Can re-basket a product that was previously shelved.
■ After the last point, I cannot re-basket the same item another time.
3
+3%: Logging out automatically re-shelves all the remaining product non-purchased in the
basket, and therefore it shall be possible to re-basket the products.
+3%: Logging out should also automatically disable all the remaining operations available
through the transaction (mainly basketProduct, shelfProduct, and basketCheckout).
+20%: Correctly purchasing the available items (single-threaded).
■ It should be possible to basket checkout when the basket is empty, with any given
amount of money
■ After successfully purchasing one item, the checkout returns the correct information.
■ After successfully purchasing two items, the checkout returns the correct information.
■ When attempting to purchase three items where only two are available, the checkout
correctly purchases two items.
+5%: Correctly shelving the products.
■ Cannot shelf a product that did not originally exist.
■ Cannot shelf a product that was not basketed (empty basket).
■ Cannot shelf a product that was not basketed (non-empty basket).
■ Can shelf a product that was originally basketed.
• Multi-Threaded Correctness [+38%]
+6%: The same user can log-in multiple times.
■ The same user can open multiple transactions (contemporarily open).
+6%: Two threads shall never be able (in any possible run) to contemporary access to the same
object on the shelf.
+5%: A client running without a supplier shall always dispose the available resources.
■ In particular, a ClientLifecycle should be able to buy all the available elements if
given an adequate amount of money.
+6%: Correct Client/Shop/Supplier interaction. This might be tested with at least one
ClientLifecycle and one SupplierLifecycle running.
■ The supplier shall not be triggered if the products are basketed but not bought (as they
can be later on re-shelved).
■ The supplier shall be triggered when a shelf for a given product is emptied.
■ After refurbishment, a client shall be able to buy at least one more product.
+12%: Correct Client/Client interaction (two distinct users and two transactions from the
same user).
■ The clients bought the maximum number of available items.
■ The clients bought 3 distinct items.
■ The clients cannot contemporarily buy the same item.
+3%: Correct Supplier Stopping.
4
■ The supplier is stopped by receiving a @stop! message only when the stopSupplier
method is invoked.
■ Currency is handled correctly.
• Advanced Features
■ [+5%] The RainforestShop is emulated realistically as a separate thread.
■ [+1%] The code exploits Java’s concurrent collections.
■ [+1%] The program allows to visually determine the correctness of the operations performed by the threads (e.g., terminal prints or graphical user interfaces).
■ [+1%] The student correctly uses ReentrantLocks and Conditions.
■ [+2%] The student correctly exploits semaphores.
■ [+2%] The student exploited the optimistic transaction principle, where multiple users can
log-in (not only the same user multiple times!).
■ [+2%] Usage of monitors or multithreaded producers and consumers on the interaction
with the supplier (semaphores might be also exploited).
■ [+3%] Thread pools are used to handle multiple requests from multiple users.
■ [+3%] Any Java library imported via pom.xml ‘not violating the 3rd Submission Requirement.

WX:codehelp

标签:product,场景,items,用户,transaction,CSC8016,user,basket,should
From: https://www.cnblogs.com/tongu1/p/17373797.html

相关文章

  • 适合专精特新企业的CRM系统5大场景、6个CRM软件盘点
    当前,世界正经历百年未有之大变局,全球产业分工和转移呈现新趋势,科技创新日益成为产业发展核心驱动力,社会经济数字化转型日益深化。专精特新中小企业作为数字经济发展的主力军,也是数字化转型的主战场,作为中国制造的重要支撑,是聚焦产业链关键环节、解决“卡脖子”技术难题、构建新发......
  • 小程序和外卖app系统如何协同发力,促进用户增长
    小程序作为一种轻量级应用,也逐渐被广泛应用于各个领域。如何让小程序和外卖APP系统协同发力,促进用户增长呢?本文将结合代码分析,从以下几个方面进行阐述:1.提供一致性的用户体验对于用户来说,最重要的是一个良好的用户体验。为了提供一致的用户体验,我们可以在小程序和外卖APP中采用相同......
  • 关于菜单-角色-用户那点事
    1.菜单,一般菜单都会有好几级,通常每一级都基本上不会超过10,在菜单表里面我们可以这样设计,首先第一个关键字段上级菜单,这个字段用来确定这个菜单是属于哪个菜单的子菜单,顶级的话就是空了。第二个关键字段就是主键了,这里不要用自增的形式,这里我们可以按照我们的需要自己定义,比如第一......
  • CentOS 7 history显示命令操作记录的时间和用户身份
     centos7中,history命令中不显示操作命令的时间和用户身份解决该问题只需要在/etc/profile中添加如下变量即可:设置环境变量exportHISTTIMEFORMAT="%Y-%m-%d%H:%M:%S`whoami`"刷新环境变量然后运行source/etc/profile命令即可,注意引号中的空格 history命令输出......
  • 用户故事与敏捷方法 二
    对一个项目来说,客户团队里包括一个或多个真实用户是极其重要的。遗憾的是,我们很难与实际用户一起工作。我们期望与尽可能多的用户接触,这些用户代表了产品的不同角度,当我们无法接触到他们时,我们就需要求助各种用户代理,他们不是用户,但在项目中扮演用户角色。用户的经理:不要得罪用户......
  • 电子商务网站用户行为分析
    电子商务网站用户行为分析 #-*-coding:utf-8-*-#代码11-1importosimportpandasaspd#修改工作路径到指定文件夹#os.chdir("D:/chapter11/demo")os.chdir("D:\\大三下\\大数据实验课\\data\\Unit11")#第一种连接方式#fromsqlalchemyimportcreate_engi......
  • 19 17 | Web 应用防火墙:怎样拦截恶意用户的非法请求?
    你好,我是李智慧。Web应用防火墙(WebApplicationFirewall,WAF)通过对HTTP(S)请求进行检测,识别并阻断SQL注入、跨站脚本攻击、跨站请求伪造等攻击,保护Web服务安全稳定。Web安全是所有互联网应用必须具备的功能,没有安全防护的应用犹如怀揣珠宝的儿童独自行走在盗贼环伺的黑夜里。我......
  • 24 22 | 大数据平台设计:如何用数据为用户创造价值?
    特别说明:本文相关技术仅用于技术展示,具体实践中,数据收集和算法应用需要遵循国家个人信息保护法与信息安全法等有关法律制度。你好,我是李智慧。现在,业界普遍认为互联网创新已经进入下半场,依靠技术创新或者商业模式创新取得爆发性发展的机会越来越少。于是大家把目光转向精细化运......
  • 23-2期中测试获奖用户名单及参考答案:通达系统架构设计
    你好,我是李智慧。今天我们来公布一下期中测试的获奖用户名单和对应的答案。我们期中测试的要求是写一个同城快送业务的系统架构设计文档,这个测试主要考察的目标包括:使用UML进行系统建模的能力,用文档表达设计思路的能力,完整思考一个系统整体架构的能力,以及识别设计落地关键技术问......
  • Apache Pulsar 在火山引擎 EMR 的集成与场景
    更多技术交流、求职机会,欢迎关注字节跳动数据平台微信公众号,回复【1】进入官方交流群 近年来,基于云原生架构的新一代消息队列和流处理引擎ApachePulsar在大数据领域发挥着愈发重要的作用,其应用场景和客户案例也在不断地丰富与扩充。 火山引擎是字节跳动的企业服务品牌,......