SSL + NIO的线程安全(Thread Safety with SSL + NIO)
有一些有用的信息可用于使用Java实现
SSL
与NIO (SocketChannel and SSLEngine)
,而不是使用netty等框架。我试图提出一个
SSL
实现,可以使用blocking/non
非阻塞通道,并获得一些基本的qns
。当操作appData和Net缓冲区时,关于线程安全性要处理的问题没有太多信息。 根据
SSLEngine
的文档,“有两个并发问题需要注意:
wrap()
和unwrap()
方法可以彼此同时执行。
SSL/TLS
协议使用有序数据包。 应用程序必须注意确保生成的数据包按顺序传递。 如果数据包无序到达,可能会发生意外或致命的结果。“这适用于阻塞和非阻塞吗? 有人可以解释一下。 谢谢。
此外,设置初始缓冲区大小的一般建议似乎是基于(
session.getApplicationBufferSize()/getPacketBufferSize()
),这些值将如何设置? 是否更好地使用这些标准缓冲区大小为32k
左右?There is some helpful information available on implementing the
SSL
withNIO (SocketChannel and SSLEngine)
using java, not using a framework such as netty etc.I am trying to come up with an
SSL
implementation that could work withblocking/non
blocking channels and got some basicqns
.There is not much info on the issues to be dealt with thread safety, when the appData and Net buffers are being manipulated. Per the documentation of
SSLEngine
,"There are two concurrency issues to be aware of:
The
wrap()
andunwrap()
methods may execute concurrently of each other.The
SSL/TLS
protocols employ ordered packets. Applications must take care to ensure that generated packets are delivered in sequence. If packets arrive out-of-order, unexpected or fatal results may occur."Would this be applicable to both blocking and non blocking ? Could somebody explain. thanks.
Also, the general recommendation for setting up the initial buffer sizes seems to based of (
session.getApplicationBufferSize()/getPacketBufferSize()
), how would these values be set ? Are these better to be used instead of some standard buffer size of32k
or so ?
原文:https://stackoverflow.com/questions/39792626
最满意答案
如果要对“帐户”实例执行嵌套连接,则必须使用括号。
LEFT JOIN Account AccountA ON Opportunity.AccountId = AccountA.Id LEFT JOIN (Account AccountB JOIN RecordType RecordTypeB ON AccountB.RecordTypeId = RecordTypeB.Id) ON Opportunity.AccountId = AccountB.Id LEFT JOIN (Account AccountC JOIN User UserB ON AccountC.OwnerId = UserB.Id) ON Opportunity.AccountId = AccountC.Id LEFT JOIN (Account AccountD JOIN User UserC ON AccountD.OwnerId = UserC.Id JOIN UserRole UserRoleA ON UserC.UserRoleId = UserRoleA.Id) ON Opportunity.AccountId = AccountD.Id
编辑:我修复了最后一行(带有AccountD的那一行)。
If you want to do nested joins to your "Account" instances, you have to use parentheses.
LEFT JOIN Account AccountA ON Opportunity.AccountId = AccountA.Id LEFT JOIN (Account AccountB JOIN RecordType RecordTypeB ON AccountB.RecordTypeId = RecordTypeB.Id) ON Opportunity.AccountId = AccountB.Id LEFT JOIN (Account AccountC JOIN User UserB ON AccountC.OwnerId = UserB.Id) ON Opportunity.AccountId = AccountC.Id LEFT JOIN (Account AccountD JOIN User UserC ON AccountD.OwnerId = UserC.Id JOIN UserRole UserRoleA ON UserC.UserRoleId = UserRoleA.Id) ON Opportunity.AccountId = AccountD.Id
Edit: I fixed the last line (the one with AccountD).
相关问答
更多-
对于'急切加载'你使用.include ; .join用于执行INNER JOIN功能。 对于你的情况,你可能会同时使用这两种方式(加入获取照片,包含获得更多人)。 我明白这一点,因为.join本身不会执行急切的加载(所以在访问关联实体时会进行查询)。 如果您希望加载嵌套关联,则可以使用http://guides.rubyonrails.org/active_record_querying.html#eager-loading-multiple-associations上的Ruby on Rails指南中概 ...
-
(SELECT product.maker, laptop.model, laptop.price FROM Product INNER JOIN laptop ON product.model = laptop.model WHERE product.maker = "A" ) UNION (SELECT product.maker, pc.model, pc.price FROM Product INNER JOIN pc ON product.model = pc.model WHER ...
-
HQL Hibernate嵌套连接(HQL Hibernate nested joins)[2022-01-10]
弄清楚了。 这是查询: select from TableAObj where TableAOb.someCol = ? and TableAObj.TableBObj.TableCObj.someCol = ? 不需要重载的构造函数或显式连接。 Figured it out. Here's the query: select from TableAObj where TableAOb.someCol = ? and TableAObj.TableBObj.TableCObj.someCol = ? ... -
如果要对“帐户”实例执行嵌套连接,则必须使用括号。 LEFT JOIN Account AccountA ON Opportunity.AccountId = AccountA.Id LEFT JOIN (Account AccountB JOIN RecordType RecordTypeB ON AccountB.RecordTypeId = RecordTypeB.Id) ON Opportunity.AccountId = AccountB.Id LEFT JOIN (Account Ac ...
-
Mysql与嵌套选择连接(Mysql Joins with nested Select)[2021-11-18]
You need to set ON clause on every join table not only the lastone. 问候 JOIN `orders` ON ??? = ???, (SELECT SUM( orders.orderPrice ) FROM `orders` WHERE YEAR( orderDate ) = YEAR( CURDATE( ) ) ) AS year ON orders.sellerid = sellers.sellerid, ... -
Rails嵌套连接(Rails Nested Joins)[2022-01-10]
scope :incoming_requests, lambda{|mid| joins(:part => :product).where(:product => {:manufacturer_id => mid}) } scope :incoming_requests, lambda{|mid| joins(:part => :product).where(:product => {:manufacturer_id => mid}) } -
在MySQL中使用JOINS(Using JOINS in MySQL)[2021-11-06]
这是一个开始: SELECT * FROM Customer c INNER JOIN CustAppointments ca ON ca.CxId = c.CustomerID INNER JOIN ClinicRooms cr ON cr.AppRoomID = ca.AppRoomID INNER JOIN AppClinics ac ON ac.ClinID = cr.ClinID WHERE ap.ClinDate BETWEEN '20090101' AND '20 ... -
事实证明,你不能。 至少不是上面提供的语法,而不是CakePHP 1.2.6。 我检查了源代码(对开源框架!),并找到了包含连接代码的文件cake/libs/model/datasources/dbo_source.php 。 这一切都从DboSource::renderStatement()开始,它执行$query['joins']数组的浅步行过程,通过DboSource::buildJoinStatement($join)替换那些带有SQL片段的连接定义,它会完成一些整理参数(填充空白等),然后调用Db ...
-
联接成为嵌套选择(Joins become nested selects)[2022-10-11]
是的,你的怀疑是正确的 - 你放置sortBy / filter地方。 您可能需要将它们提取为单独的方法,并且可能需要将它们组合成方法,而不是使用filter / sortBy进行完整查询。 def partialReviewByPlaceIds(q: ReviewQuery, placeIds: Long*)(implicit psDAO: PlaceStatusDAO, upDAO: UserProfileDAO) = for { ((r, up), ps) <- Reviews join up ... -
嵌套连接隐藏表名(Nested joins hide table names)[2023-06-14]
您的ANSI-92 JOIN语法不正确 - 使用: CREATE VIEW Everything AS SELECT Suppliers.name as supplier, Parts.id, Parts.description, Types.typedesc as type FROM Suppliers JOIN Parts ON Suppliers.id = Parts.supplier_id JOIN Types ...