当前位置: 首页 > 编程日记 > 正文

网络编程 -- RPC实现原理 -- RPC -- 迭代版本V3 -- 远程方法调用 整合 Spring

网络编程 -- RPC实现原理 -- 目录

啦啦啦

V3——RPC -- 远程方法调用 及 null的传输 + Spring

服务提供商:

1. 配置 rpc03_server.xml 注入 服务提供商 rpcServiceProvider并指定初始化方法 及 服务实例 IUserService

2. 读取 服务消费者 请求的 MethodStaics ,通过反射获取服务端实例方法的返回值。返回值为null值,则映射为NullWritable实例返回。不为null,则不加以约束。

服务代理商:

1. 配置 rpc03_client.xml 注入 服务代理商 RPCObjectProxy并指定 目标对象 RPCClient 及 代理的接口 lime.pri.limeNio.netty.rpc03.service.IUserService

2. List<User> users = userService.queryAll(10, 4); : 调用 目标对象的  Object invokeMethod(MethodStaics methodStaics);  方法,通过TCP/IP将MethodStaics实例发送至服务提供商。

3. 读取 服务提供商返回值。返回值为NullWritable实例,则映射为null值。其他实例,则不加以约束。

服务提供商:

XML : rpc03_server.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:p="http://www.springframework.org/schema/p"xsi:schemaLocation="   http://www.springframework.org/schema/beans classpath:/org/springframework/beans/factory/xml/spring-beans-4.1.xsd http://www.springframework.org/schema/context classpath:/org/springframework/context/config/spring-context-4.1.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd http://www.springframework.org/schema/aop classpath:org/springframework/aop/config/spring-aop-4.1.xsd"
    default-lazy-init="false"><bean id="rpcServiceProvider" class="lime.pri.limeNio.netty.rpc03.core.server.RPCServiceProvider"init-method="start" destroy-method="close"><constructor-arg index="0" value="9999" /></bean><bean id="IUserService" class="lime.pri.limeNio.netty.rpc03.service.impl.UserService" /></beans>

Class : RPCServiceProvider 实现ApplicationContextAware 获取通过容器的getBean()方法获取 服务实例

package lime.pri.limeNio.netty.rpc03.core.server;import java.lang.reflect.Method;
import java.util.List;import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
import io.netty.handler.codec.MessageToMessageCodec;
import io.netty.util.CharsetUtil;
import lime.pri.limeNio.netty.rpc03.core.assist.MethodStaics;
import lime.pri.limeNio.netty.rpc03.core.assist.NullWritable;public class RPCServiceProvider implements ApplicationContextAware {private ServerBootstrap serverBootstrap;private EventLoopGroup boss;private EventLoopGroup worker;private int port;private ApplicationContext act;public RPCServiceProvider() {super();}public RPCServiceProvider(int port) {this.serverBootstrap = new ServerBootstrap();this.boss = new NioEventLoopGroup();this.worker = new NioEventLoopGroup();this.serverBootstrap.group(boss, worker);this.serverBootstrap.channel(NioServerSocketChannel.class);this.port = port;}public void start() {serverBootstrap.childHandler(new ChannelInitializer<SocketChannel>() {@Overrideprotected void initChannel(SocketChannel ch) throws Exception {ChannelPipeline pipeline = ch.pipeline();pipeline.addLast(new LengthFieldPrepender(2)).addLast(new LengthFieldBasedFrameDecoder(65535, 0, 2, 0, 2)).addLast(new MessageToMessageCodec<ByteBuf, Object>() {@Overrideprotected void encode(ChannelHandlerContext ctx, Object msg, List<Object> out)throws Exception {out.add(Unpooled.buffer().writeBytes(JSON.toJSONString(msg, SerializerFeature.WriteClassName).getBytes(CharsetUtil.UTF_8)));}@Overrideprotected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out)throws Exception {out.add(JSON.parse(msg.toString(CharsetUtil.UTF_8)));}}).addLast(new ChannelHandlerAdapter() {@Overridepublic void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {MethodStaics methodStaics = (MethodStaics) msg;Object bean = act.getBean(methodStaics.getTargetInterface().getSimpleName());Method method = bean.getClass().getDeclaredMethod(methodStaics.getMethod(),methodStaics.getParameterTypes());Object invoke = method.invoke(bean, methodStaics.getArgs());// 如果返回值为空,则返回NullWritable实例代替传输invoke = null == invoke ? new NullWritable() : invoke;ChannelFuture channelFuture = ctx.writeAndFlush(invoke);channelFuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);channelFuture.addListener(ChannelFutureListener.CLOSE_ON_FAILURE);channelFuture.addListener(ChannelFutureListener.CLOSE);}@Overridepublic void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {System.err.println(cause);}});}});/*** 绑定监听端口并启动服务 注意 : 启动的服务是阻塞的,防止阻塞Spring工厂需要采用异步启动*/new Thread() {public void run() {try {System.out.println("服务启动@" + port + " ...");ChannelFuture channelFuture = serverBootstrap.bind(port).sync();channelFuture.channel().closeFuture().sync();} catch (InterruptedException e) {System.out.println(e);} finally {}};}.start();}public void close() {boss.shutdownGracefully();worker.shutdownGracefully();}public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {this.act = applicationContext;}
}

Class : IUserService

package lime.pri.limeNio.netty.rpc03.service;import java.util.List;import lime.pri.limeNio.netty.rpc03.entity.User;public interface IUserService {User queryById(Integer id);List<User> queryByName(String name);List<User> queryAll(Integer pageSize, Integer pageNum);
}

Class : UserService

package lime.pri.limeNio.netty.rpc03.service.impl;import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;import lime.pri.limeNio.netty.rpc03.entity.User;
import lime.pri.limeNio.netty.rpc03.service.IUserService;public class UserService implements IUserService {private static Map<Integer, User> userMap = new ConcurrentHashMap<Integer, User>();static {for (int i = 1; i <= 100; i++) {userMap.put(i, new User(i, "lime_" + i, new Date()));}}public User queryById(Integer id) {return userMap.get(id);}public List<User> queryAll(Integer pageSize, Integer pageNum) {int stNum = (pageNum - 1) * pageSize + 1;int enNum = pageNum * pageSize;List<User> result = new ArrayList<User>();for (int i = stNum; i <= enNum; i++) {result.add(userMap.get(i));}return result;}public List<User> queryByName(String name) {List<User> result = null;Iterator<User> iterator = userMap.values().iterator();while (iterator.hasNext()) {User user = iterator.next();if (user.getName().equals(name)) {if (null == result)result = new ArrayList<User>();result.add(user);}}return result;}}

服务代理商:

Class :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:p="http://www.springframework.org/schema/p"xsi:schemaLocation="   http://www.springframework.org/schema/beans classpath:/org/springframework/beans/factory/xml/spring-beans-4.1.xsd http://www.springframework.org/schema/context classpath:/org/springframework/context/config/spring-context-4.1.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd http://www.springframework.org/schema/aop classpath:org/springframework/aop/config/spring-aop-4.1.xsd"
    default-lazy-init="false"><bean id="userService" class="lime.pri.limeNio.netty.rpc03.core.client.proxy.RPCObjectProxy"><constructor-arg index="0" ref="rpcClient" /><constructor-arg index="1" value="lime.pri.limeNio.netty.rpc03.service.IUserService" /></bean><bean id="rpcClient" class="lime.pri.limeNio.netty.rpc03.core.client.impl.RemoteRPCClient"destroy-method="close"><constructor-arg index="0" ref="hostAndPort" /></bean><bean id="hostAndPort" class="lime.pri.limeNio.netty.rpc03.core.client.assist.HostAndPort"><constructor-arg index="0" value="127.0.0.1" /><constructor-arg index="1" value="9999" /></bean></beans>

Class : RPCObjectProxy

package lime.pri.limeNio.netty.rpc03.core.client.proxy;import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;import org.springframework.beans.factory.FactoryBean;import lime.pri.limeNio.netty.rpc03.core.assist.MethodStaics;
import lime.pri.limeNio.netty.rpc03.core.client.rpcClient.RPCClient;/*** 通过接口动态创建代理对象* * @author lime* @param <T>**            实现FactoryBean接口,与Spring整合* */
public class RPCObjectProxy implements InvocationHandler, FactoryBean<Object> {private RPCClient rpcClient;private Class<?> targetInterface;public RPCObjectProxy() {super();}public RPCObjectProxy(RPCClient rpcClient, Class<?> targetInterface) {super();this.rpcClient = rpcClient;this.targetInterface = targetInterface;}public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {return rpcClient.invokeMethod(new MethodStaics(targetInterface, method.getName(), args, method.getParameterTypes()));}// 产生代理对象public Object getObject() throws Exception {return Proxy.newProxyInstance(RPCObjectProxy.class.getClassLoader(), new Class[] { targetInterface }, this);}public Class<?> getObjectType() {return targetInterface;}public boolean isSingleton() {return true;}
}

Class : RPCClient

package lime.pri.limeNio.netty.rpc03.core.client.rpcClient;import lime.pri.limeNio.netty.rpc03.core.assist.MethodStaics;/*** 通过RPCClient实现对远程方法的调用* * @author lime**/
public interface RPCClient {Object invokeMethod(MethodStaics methodStaics);void close();
}

Class : RemoteRPCClient

package lime.pri.limeNio.netty.rpc03.core.client.rpcClient.impl;import java.net.InetSocketAddress;
import java.util.List;import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
import io.netty.handler.codec.MessageToMessageCodec;
import io.netty.util.CharsetUtil;
import lime.pri.limeNio.netty.rpc03.core.assist.MethodStaics;
import lime.pri.limeNio.netty.rpc03.core.assist.NullWritable;
import lime.pri.limeNio.netty.rpc03.core.client.assist.HostAndPort;
import lime.pri.limeNio.netty.rpc03.core.client.rpcClient.RPCClient;/*** 通过TCP/IP协议实现远程方法调用* * @author lime**/
public class RemoteRPCClient implements RPCClient {private Bootstrap bootstrap;private EventLoopGroup worker;private HostAndPort hostAndPort;public RemoteRPCClient() {super();}public RemoteRPCClient(HostAndPort hostAndPost) {this.hostAndPort = hostAndPost;// 初始化数据this.bootstrap = new Bootstrap();this.worker = new NioEventLoopGroup();this.bootstrap.group(this.worker);this.bootstrap.channel(NioSocketChannel.class);}public Object invokeMethod(final MethodStaics methodStaics) {bootstrap.handler(new ChannelInitializer<SocketChannel>() {@Overrideprotected void initChannel(SocketChannel ch) throws Exception {ChannelPipeline pipeline = ch.pipeline();pipeline.addLast(new LengthFieldBasedFrameDecoder(65535, 0, 2, 0, 2)).addLast(new LengthFieldPrepender(2)).addLast(new MessageToMessageCodec<ByteBuf, Object>() {@Overrideprotected void encode(ChannelHandlerContext ctx, Object msg, List<Object> out)throws Exception {out.add(Unpooled.buffer().writeBytes(JSON.toJSONString(msg, SerializerFeature.WriteClassName).getBytes(CharsetUtil.UTF_8)));}@Overrideprotected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out)throws Exception {out.add(JSON.parse(msg.toString(CharsetUtil.UTF_8)));}}).addLast(new ChannelHandlerAdapter() {@Overridepublic void channelActive(ChannelHandlerContext ctx) throws Exception {ChannelFuture channelFuture = ctx.writeAndFlush(methodStaics);channelFuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);channelFuture.addListener(ChannelFutureListener.CLOSE_ON_FAILURE);}@Overridepublic void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {methodStaics.setResult(msg);}@Overridepublic void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {System.err.println(cause);}});}});ChannelFuture channelFuture;try {channelFuture = bootstrap.connect(new InetSocketAddress(hostAndPort.getHost(), hostAndPort.getPort())).sync();channelFuture.channel().closeFuture().sync();} catch (InterruptedException e) {// TODO Auto-generated catch block
            e.printStackTrace();}// 服务端返回值为null,处理方式return methodStaics.getResult() instanceof NullWritable ? null : methodStaics.getResult();}public void close() {worker.shutdownGracefully();}}

Class : HostAndPort

package lime.pri.limeNio.netty.rpc03.core.client.assist;import java.io.Serializable;public class HostAndPort implements Serializable{/*** */private static final long serialVersionUID = 1L;private String host;private int port;public HostAndPort() {super();// TODO Auto-generated constructor stub
    }public HostAndPort(String host, int port) {super();this.host = host;this.port = port;}public String getHost() {return host;}public void setHost(String host) {this.host = host;}public int getPort() {return port;}public void setPort(int port) {this.port = port;}@Overridepublic String toString() {return "HostAndPort [host=" + host + ", port=" + port + "]";}}

辅助类:

Class : MethodStaics

package lime.pri.limeNio.netty.rpc03.core.assist;import java.io.Serializable;
import java.util.Arrays;/*** @author lime**/
public class MethodStaics implements Serializable{/*** */private static final long serialVersionUID = 1L;private Class<?> targetInterface;private String method;private Object[] args;private Class[] parameterTypes;private Object result;public MethodStaics() {super();// TODO Auto-generated constructor stub
    }public MethodStaics(Class<?> targetInterface, String method, Object[] args, Class[] parameterTypes) {super();this.targetInterface = targetInterface;this.method = method;this.args = args;this.parameterTypes = parameterTypes;}@Overridepublic String toString() {return "MethodStaics [targetInterface=" + targetInterface + ", method=" + method + ", args="+ Arrays.toString(args) + ", parameterTypes=" + Arrays.toString(parameterTypes) + "]";}public Class<?> getTargetInterface() {return targetInterface;}public void setTargetInterface(Class<?> targetInterface) {this.targetInterface = targetInterface;}public String getMethod() {return method;}public void setMethod(String method) {this.method = method;}public Object[] getArgs() {return args;}public void setArgs(Object[] args) {this.args = args;}public Class[] getParameterTypes() {return parameterTypes;}public void setParameterTypes(Class[] parameterTypes) {this.parameterTypes = parameterTypes;}public Object getResult() {return result;}public void setResult(Object result) {this.result = result;}}

Class : NullWritable

package lime.pri.limeNio.netty.rpc03.core.assist;import java.io.Serializable;public class NullWritable implements Serializable{/*** */private static final long serialVersionUID = 1L;}

Class : User

package lime.pri.limeNio.netty.rpc03.entity;import java.io.Serializable;
import java.util.Date;public class User implements Serializable {/*** */private static final long serialVersionUID = 1L;private int id;private String name;private Date birth;public User() {super();// TODO Auto-generated constructor stub
    }public User(int id, String name, Date birth) {super();this.id = id;this.name = name;this.birth = birth;}@Overridepublic String toString() {return "User [id=" + id + ", name=" + name + ", birth=" + birth + "]";}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Date getBirth() {return birth;}public void setBirth(Date birth) {this.birth = birth;}}

测试类:

Class : TtServer

package lime.pri.limeNio.netty.rpc03.tT;import org.springframework.context.support.ClassPathXmlApplicationContext;public class TtServer {public static void main(String[] args) throws Exception {new ClassPathXmlApplicationContext("classpath:spring/rpc03_server.xml");}
}

Class : TtClient

package lime.pri.limeNio.netty.rpc03.tT;import java.util.List;import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;import lime.pri.limeNio.netty.rpc03.entity.User;
import lime.pri.limeNio.netty.rpc03.service.IUserService;public class TtClient {public static void main(String[] args) throws Exception {ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:spring/rpc03_client.xml");IUserService userService = (IUserService) ctx.getBean("userService");System.out.println("queryByName");List<User> usersWithName = userService.queryByName("lime");System.out.println(usersWithName);System.out.println("queryAll");List<User> users = userService.queryAll(10, 3);for (User user : users) {System.out.println(user);}System.out.println("queryById");User user = userService.queryById(23);System.out.println(user);}
}

Console : Server

六月 25, 2017 2:08:04 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@17f052a3: startup date [Sun Jun 25 14:08:04 CST 2017]; root of context hierarchy
六月 25, 2017 2:08:04 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [spring/rpc03_server.xml]
服务启动@9999 ...

Console : Client

六月 25, 2017 2:08:18 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@17f052a3: startup date [Sun Jun 25 14:08:18 CST 2017]; root of context hierarchy
六月 25, 2017 2:08:18 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [spring/rpc03_client.xml]
queryByName
null
queryAll
User [id=21, name=lime_21, birth=Sun Jun 25 14:08:04 CST 2017]
User [id=22, name=lime_22, birth=Sun Jun 25 14:08:04 CST 2017]
User [id=23, name=lime_23, birth=Sun Jun 25 14:08:04 CST 2017]
User [id=24, name=lime_24, birth=Sun Jun 25 14:08:04 CST 2017]
User [id=25, name=lime_25, birth=Sun Jun 25 14:08:04 CST 2017]
User [id=26, name=lime_26, birth=Sun Jun 25 14:08:04 CST 2017]
User [id=27, name=lime_27, birth=Sun Jun 25 14:08:04 CST 2017]
User [id=28, name=lime_28, birth=Sun Jun 25 14:08:04 CST 2017]
User [id=29, name=lime_29, birth=Sun Jun 25 14:08:04 CST 2017]
User [id=30, name=lime_30, birth=Sun Jun 25 14:08:04 CST 2017]
queryById
User [id=23, name=lime_23, birth=Sun Jun 25 14:08:04 CST 2017]

啦啦啦

相关文章:

Rootkit之SSDT hook(通过CR0)

SSDT即System Service Dispath Table&#xff0c;它是一个表&#xff0c;这个表中有内核调用的函数地址。KeServiceDescriptorTable&#xff1a;是由内核&#xff08;Ntoskrnl.exe&#xff09;导出的一个表&#xff0c;这个表是访问SSDT的关键&#xff0c;具体结构是typedef st…

禁止validateRequest的办法

A potentially dangerous Request.Form value was detected from the client (txtTest"<b>"). 由于在.net中&#xff0c;Request时出现有HTML或Javascript等字符串时&#xff0c;系统会认为是危险性值。立马报错。 解决方案一&#xff1a; 在.a…

多画面、实时投票,这场上了一晚热搜的超级晚,背后的技术出圈了

"让观众当导演&#xff0c;自己决定演出顺序&#xff1f;" "不仅直播前台演出&#xff0c;还可以看到候场区明星吃火锅&#xff1f;" 你没听错&#xff0c;在各种直播、晚会频出的岁末年初&#xff0c;最近有一台超级晚出圈了。 1月15日&#xff0c;2021爱…

linux下挂载硬盘

2019独角兽企业重金招聘Python工程师标准>>> 切换到root用户 su - root 查看硬盘信息 fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units cylinders of 16065 * 512 8225280 bytes Sector size (logical/ph…

通过创建 HttpCookie 对象的实例编写 Cookie

通过创建 HttpCookie 对象的实例编写 Cookie HttpCookie myCookie new HttpCookie("UserSettings");myCookie["Font"] "Arial";myCookie["Color"] "Blue";myCookie.Expires DateTime.Now.AddDays(1d);Response.Cookies…

亚马逊云服务(AWS)云原生自研处理器首次落地中国区域!

2021年1月28日&#xff0c;亚马逊云服务&#xff08;AWS&#xff09;正式宣布&#xff0c;由 AWS Graviton2 处理器提供支持的 Amazon Elastic Compute Cloud &#xff08;Amazon EC2&#xff09; M6g、C6g 和 R6g 实例已在由光环新网运营的 AWS 中国&#xff08;北京&#xff…

一个古老的问题HashMap与Hashtable区别

HashTable的应用非常广泛&#xff0c;HashMap是新框架中用来代替HashTable的类&#xff0c;也就是说建议使用HashMap&#xff0c;不要使用HashTable。可能你觉得HashTable很好用&#xff0c;为什么不用呢&#xff1f;这里简单分析他们的区别。 1.HashTable的方法是同步的&#…

如何修改可运行Jar包,如何反编译Jar包

将可运行Jar包&#xff0c;反编译成项目&#xff0c;修改代码&#xff0c;再次编译&#xff0c;打包。 需要工具&#xff1a;jd-gui、myeclipse 具体步骤&#xff1a; 1、使用jd-gui打开原始的Jar包&#xff0c;选择File-->Save All Sources&#xff0c;会生成一个zip压缩包…

告别手敲 SQL ?GPT-3 自动帮你写

作者 | Brian Kane SeekWell 编译 | 伍杏玲 出品 | AI科技大本营&#xff08;ID&#xff1a;rgznai100&#xff09; 【导语】手写业务 SQL 很繁琐&#xff1f;GPT-3来帮你&#xff01;本文作者通过手动输入简单的英文描述秒 Get 到 SQL 了。听说 AI 又来抢开发者饭碗&#xff0…

Java IO 体系结构

参考文章地址: http://blog.csdn.net/oracle_microsoft/article/details/2634231 Java IO体系结构看似庞大复杂,其实有规律可循,要弄清楚其结构,需要明白两点: 1. 其对称性质:InputStream 与 OutputStream, Reader 与 Writer,他们分别是一套字节输入-输出,字符输入-输出体系 2.…

ACCESS数据库防止下载

1. 修改数据库名。这是常用方法&#xff0c;将数据库名该成怪异名字或长名字&#xff0c;以防别人猜测。一旦被人猜到&#xff0c;别人还是能下载数据库文件&#xff0c;但几率不大。如将数据库database.mdb改成dslfjds$^&ijjkgf.mdb等 2. 修改数据库后缀。一般改成databa…

CentOS 7 SSH 免密登录的方法

先决条件 3 台 CentOS 7 HOSTNAMEIPROLEserver110.8.26.197Masterserver210.8.26.196Slave1server310.8.26.195Slave21. 用 root 用户登录。每台服务器都生成公钥&#xff0c;再合并到 authorized_keys。 2. CentOS 默认没有启动 ssh 无密登录&#xff0c;去掉 /etc/ssh/sshd_c…

webconfig加密

退到根目录 cd/跳到某盘 c: ..跳到某目录 cd Documents and Settings/All Users上一层 cd .. cd WINDOWS/Microsoft.NET/Framework/v2.0.50727 回车 aspnet_regiis -pef connectionStrings D:/NET aspnet_regiis -pe connectionStrings -app /NET 虚拟目录aspnet_regiis -pd…

WIN7 任务栏放右侧 有个BUG

不能变窄啊&#xff0c;微软又在设计上。转载于:https://www.cnblogs.com/whitetiger/p/3269827.html

全领域通吃,12个经典Python数据可视化库盘点

责编 | 寇雪芹头图 | 下载于视觉中国来源 | 博文视点BroadviewPython有很多数据可视化库&#xff0c;这些数据可视化库主要分为探索式可视化库和交互式可视化库。前者透过简单直接的视觉图形&#xff0c;更方便用户看懂原数据&#xff0c;后者主要用于与业务结合过程中展现总体…

add nodes to the swarm

一旦你们创建了一个带有管理节点的swarm集群&#xff0c;你就可以开始添加 worker节点$ docker-machine ssh worker1 $ docker swarm join \--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \192.168.99.100:2377 This node …

三种方法,用Python轻松提取PDF中的全部图片

作者 | 陈熹、刘早起来源 | 早起Python头图 | 下载于视觉中国有时我们需要将一份或者多份PDF文件中的图片提取出来&#xff0c;如果采取在线的网站实现的话又担心图片泄漏&#xff0c;手动操作又觉得麻烦&#xff0c;其实用Python也可以轻松搞定&#xff01;今天就跟大家系统分…

ASP.NET中如何防范SQL注入式攻击

1将sql中使用的一些特殊符号&#xff0c;如 -- /* ; %等用Replace()过滤&#xff1b;2限制文本框输入字符的长度&#xff1b;3检查用户输入的合法性&#xff1b;客户端与服务器端都要执行&#xff0c;可以使用正则。4使用带参数的SQL语句形式。 ASP.NET中如何防范SQL注入式攻击…

iOS下的类似Android的toast提示

一般人会说&#xff0c;就是用那个MBProgressHUD不就行了吗&#xff1f; 的确是&#xff0c;MBProgressHUD能为我们做了好多loading指示器&#xff0c;但是toast不一样&#xff0c;它是在屏幕某个地方出现一行小提示&#xff0c;例如网络状态&#xff0c;出现的时候不会妨碍用户…

配置Activiti Explorer使用MYSQL

http://blog.csdn.net/lxxxzzl/article/details/39583977

初学者SQL语句介绍

初学者SQL语句介绍 1.用 Select 子句检索记录 Select 子句是每一个检索数据的查询核心。它告诉数据库引擎返回什么字段。 Select 子句的常见形式是&#xff1a; Select * 该子句的意思是“返回在所指定的记录源中能找到的所有字段”。这种命令形式很方便&#xff…

转型AI成功几率有几分?太真实了......

技术转型&#xff0c;这两年一直是程序员圈子里的热门话题。对于大部分基层程序员来说&#xff0c;基础岗位上薪资的涨幅很难跟上年龄的增长。而近些年&#xff0c;AI技术发展势头迅猛&#xff0c;优秀人才短缺。在这种情况下&#xff0c;无疑是谁先转型成功&#xff0c;谁就占…

如何使用聚簇索引

2019独角兽企业重金招聘Python工程师标准>>> 聚簇索引是一种对磁盘上实际数据重新组织以按指定的一个或多个列的值排序。由于聚簇索引的索引页面指针指向数据页面&#xff0c;所以使用聚簇索引查找数据几乎 总是比使用非聚簇索引快。每张表只能建一个聚簇索引&#…

C语言实现汉诺塔问题

代码如下&#xff1a; #include <stdio.h> #include <stdlib.h> void move(int n,char x,char y,char z) {if (n1) {printf("%c--->%c\n",x,z);}else {move(n-1,x,z,y);printf("%c--->%c\n",x,z);move(n-1,y,x,z);} } int main() {int n…

将Session值储存于SQL Server中

一般情况下&#xff0c;我们喜欢使用Session储存我们的变量。Asp.Net提供了下面一些方法储存Session的值&#xff1a; InProc State Server SQL Server “InProc”表示我们使用传统ASP一样的方法储存Session的值&#xff0c;而且“State Server”则表示使用另外一台主机来…

系统定时关机的方法

曾经在网上搜索过关于windows XP定时关机的方法&#xff0c;很多人都说下载一个定时关机的软件。其实根本不需要这么麻烦&#xff0c;windowsXP本身就自带有定时关机这个功能&#xff0c;而且有两种方法。方法一&#xff1a;使用at命令(1)"开始"->"运行"…

让线上学习不打折扣,作业帮如何用技术促进课堂高频互动场?

“在大班直播课上&#xff0c;可能有数千甚至上万学员同时上课&#xff0c;但是他们彼此看不见也听不见&#xff0c;是千千万万个‘孤独的个体’&#xff0c;而‘小组直播间’却可以让他们随时随刻感觉到自己置身于一个温暖的集体之中。” “小组直播间”是曹越一直主张在大班…

在python中调用js或者nodejs要使用PyExecJs第三方包。

在python中调用js或者nodejs要使用PyExecJs第三方包。 使用时&#xff1a;import execjs这是没有用到nodejs的情况&#xff1b;如果用到nodejs&#xff0c;这种写法会报“Cannot find module xxx”的错误。 如果要用nodejs&#xff0c;要在环境变量中指定node_modules的路径。转…

超越Google,快手落地业界首个万亿参数推荐精排模型

整理 | 兆雨 责编 | 阿司匹林 出品 | AI科技大本营 精准的推荐系统模型是很多互联网产品的核心竞争力&#xff0c;个性化推荐系统旨在根据用户的行为数据提供“定制化”的产品体验。国民级短视频App快手&#xff0c;每天为数亿用户推荐百亿的视频&#xff0c;遇到的挑战之一是推…

Cache总义Cache用法之页面声明

Cache总义Cache用法之页面声明 <% outputCacheDuration"#ofseconds"Location"Any|Client|Downstream|Server|None"VaryByControl"ControlName"VaryByCustom"browser|customstring"VaryByHeader"headers"VaryByParam&quo…